(* Content-type: application/vnd.wolfram.mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 8.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 157, 7] NotebookDataLength[ 15465, 399] NotebookOptionsPosition[ 14810, 374] NotebookOutlinePosition[ 15177, 390] CellTagsIndexPosition[ 15134, 387] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[BoxData[ RowBox[{ RowBox[{"linearImageDistance", "[", "fileName_", "]"}], " ", ":=", " ", RowBox[{"Manipulate", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{ "xs", ",", "ys", ",", "fd", ",", " ", "id", ",", "ig", ",", "lg", ",", "dx", ",", "dy", ",", "dxtg", ",", "dytg"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"xs", " ", "=", " ", RowBox[{ RowBox[{"Import", "[", RowBox[{"fileName", ",", "\"\\""}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"ys", " ", "=", " ", RowBox[{ RowBox[{"Import", "[", RowBox[{"fileName", ",", "\"\\""}], "]"}], "[", RowBox[{"[", "2", "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"fd", " ", "=", " ", RowBox[{"Import", "[", "fileName", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"id", " ", "=", " ", RowBox[{"ImageData", "[", "fd", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"dx", " ", "=", " ", RowBox[{"x2", "-", "x1"}]}], ";", "\[IndentingNewLine]", RowBox[{"dy", " ", "=", " ", RowBox[{"y2", "-", "y1"}]}], ";", "\[IndentingNewLine]", RowBox[{"ig", " ", "=", RowBox[{"Image", "[", RowBox[{"id", ",", RowBox[{"ImageSize", "\[Rule]", "xs"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"lg", " ", "=", " ", RowBox[{"Graphics", "[", RowBox[{"{", RowBox[{ RowBox[{"Arrowheads", "[", RowBox[{"{", RowBox[{ RowBox[{"-", "0.025"}], ",", "0.025"}], "}"}], "]"}], ",", " ", RowBox[{"Hue", "[", "lh", "]"}], ",", RowBox[{"Arrow", "[", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"x1", ",", "y1"}], "}"}], ",", RowBox[{"{", RowBox[{"x2", ",", "y2"}], "}"}]}], "}"}], "]"}]}], "}"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"dxtg", " ", "=", " ", RowBox[{"Graphics", "[", RowBox[{"{", RowBox[{ RowBox[{"Hue", "[", "lh", "]"}], ",", RowBox[{"Text", "[", RowBox[{ RowBox[{"Style", "[", RowBox[{ RowBox[{"StringJoin", "[", RowBox[{"\"\\"", ",", RowBox[{"ToString", "[", "dx", "]"}]}], "]"}], ",", "18"}], "]"}], ",", RowBox[{"{", RowBox[{ RowBox[{"xs", "-", "150"}], ",", RowBox[{"ys", "-", "20"}]}], "}"}]}], "]"}]}], "}"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"dytg", " ", "=", " ", RowBox[{"Graphics", "[", RowBox[{"{", RowBox[{ RowBox[{"Hue", "[", "lh", "]"}], ",", RowBox[{"Text", "[", RowBox[{ RowBox[{"Style", "[", RowBox[{ RowBox[{"StringJoin", "[", RowBox[{"\"\\"", ",", RowBox[{"ToString", "[", "dy", "]"}]}], "]"}], ",", "18"}], "]"}], ",", RowBox[{"{", RowBox[{ RowBox[{"xs", "-", "150"}], ",", RowBox[{"ys", "-", "50"}]}], "}"}]}], "]"}]}], "}"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Show", "[", RowBox[{"ig", ",", "lg", ",", "dxtg", ",", "dytg"}], "]"}]}]}], "\[IndentingNewLine]", "]"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"x1", ",", "1"}], "}"}], ",", "1", ",", RowBox[{ RowBox[{"Import", "[", RowBox[{"fileName", ",", "\"\\""}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}], ",", "1"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"y1", ",", "1"}], "}"}], ",", "1", ",", RowBox[{ RowBox[{"Import", "[", RowBox[{"fileName", ",", "\"\\""}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}], ",", "1"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"x2", ",", "100"}], "}"}], ",", "1", ",", RowBox[{ RowBox[{"Import", "[", RowBox[{"fileName", ",", "\"\\""}], "]"}], "[", RowBox[{"[", "2", "]"}], "]"}], ",", "1"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"y2", ",", "100"}], "}"}], ",", "1", ",", RowBox[{ RowBox[{"Import", "[", RowBox[{"fileName", ",", "\"\\""}], "]"}], "[", RowBox[{"[", "2", "]"}], "]"}], ",", "1"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"lh", ",", "0.3", ",", "\"\\""}], "}"}], ",", "0", ",", "1", ",", "0.01"}], "}"}]}], "\[IndentingNewLine]", "]"}]}]], "Input", CellChangeTimes->{{3.526790971924752*^9, 3.526791132868367*^9}, { 3.526791214639097*^9, 3.526791234467572*^9}, {3.5267913384976*^9, 3.526791386925997*^9}, {3.526791474481058*^9, 3.526791537672534*^9}, { 3.5267915938104887`*^9, 3.526791712732432*^9}, {3.526791767510131*^9, 3.5267917876658697`*^9}, {3.5267918440476418`*^9, 3.526791858642354*^9}, { 3.5267919265852013`*^9, 3.526792012477829*^9}, {3.526792046198196*^9, 3.526792181356225*^9}, {3.5267922123753223`*^9, 3.526792277964867*^9}, { 3.526792333459003*^9, 3.526792375659746*^9}, {3.526792431161147*^9, 3.526792431737916*^9}, {3.526792656300928*^9, 3.526792659728649*^9}, { 3.526792714544734*^9, 3.526792750122096*^9}, {3.526792847616394*^9, 3.526792862101509*^9}, {3.5267929664127197`*^9, 3.526793004537108*^9}, { 3.5267930408709297`*^9, 3.5267930444025917`*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"areaOfInterestAnalysis", "[", "fileName_", "]"}], " ", ":=", " ", RowBox[{"Manipulate", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{ "xs", ",", "ys", ",", "fd", ",", " ", "id", ",", "ig", ",", "xp", ",", "yp", ",", " ", "rg", ",", "imageArea", ",", " ", "xpPlot", ",", "ypPlot"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"xs", " ", "=", " ", RowBox[{ RowBox[{"Import", "[", RowBox[{"fileName", ",", "\"\\""}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"ys", " ", "=", " ", RowBox[{ RowBox[{"Import", "[", RowBox[{"fileName", ",", "\"\\""}], "]"}], "[", RowBox[{"[", "2", "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"fd", " ", "=", " ", RowBox[{"Import", "[", "fileName", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"id", " ", "=", " ", RowBox[{"ImageData", "[", "fd", "]"}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"Projections", " ", "in", " ", "x", " ", "and", " ", "y"}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{"xp", " ", "=", " ", RowBox[{"Total", "[", RowBox[{"id", "[", RowBox[{"[", RowBox[{ RowBox[{"x0", ";;", RowBox[{"x0", "+", "xw"}]}], ",", RowBox[{"y0", ";;", RowBox[{"y0", "+", "yw"}]}], ",", "1"}], "]"}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"yp", " ", "=", " ", RowBox[{"Total", "[", RowBox[{"Transpose", "[", RowBox[{"id", "[", RowBox[{"[", RowBox[{ RowBox[{"x0", ";;", RowBox[{"x0", "+", "xw"}]}], ",", RowBox[{"y0", ";;", RowBox[{"y0", "+", "yw"}]}], ",", "1"}], "]"}], "]"}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"xp", " ", "=", " ", RowBox[{"xp", "-", RowBox[{"xp", "[", RowBox[{"[", "1", "]"}], "]"}]}]}], ";", "\[IndentingNewLine]", RowBox[{"yp", " ", "=", " ", RowBox[{"yp", "-", RowBox[{"yp", "[", RowBox[{"[", "1", "]"}], "]"}]}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"Image", " ", "for", " ", "plotting"}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{"ig", " ", "=", RowBox[{"Image", "[", RowBox[{"id", ",", RowBox[{"ImageSize", "\[Rule]", "xs"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ "Create", " ", "area", " ", "of", " ", "interest", " ", "rectange"}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{"rg", " ", "=", " ", RowBox[{"Graphics", "[", RowBox[{"{", RowBox[{ RowBox[{"EdgeForm", "[", "Dashed", "]"}], ",", "Pink", ",", RowBox[{"FaceForm", "[", RowBox[{"Directive", "[", RowBox[{ RowBox[{"Opacity", "[", "0.2", "]"}], ",", RowBox[{"Hue", "[", "aoiHue", "]"}]}], "]"}], "]"}], ",", RowBox[{"Rectangle", "[", RowBox[{ RowBox[{"{", RowBox[{"x0", ",", "y0"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"x0", "+", "xw"}], ",", RowBox[{"y0", "+", "yw"}]}], "}"}]}], "]"}]}], "}"}], "]"}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{"Display", " ", "graphics"}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{"gg", " ", "=", " ", RowBox[{"GraphicsGrid", "[", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"ig", ",", "ypPlot"}], "}"}], ",", RowBox[{"{", RowBox[{"xpPlot", ",", "Null"}], "}"}]}], "}"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Show", "[", "gg", "]"}]}]}], "\[IndentingNewLine]", "]"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"x0", ",", "1"}], "}"}], ",", "0", ",", " ", RowBox[{ RowBox[{"Import", "[", RowBox[{"fileName", ",", "\"\\""}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}], ",", "1"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"xw", ",", "10"}], "}"}], ",", "0", ",", RowBox[{ RowBox[{"Import", "[", RowBox[{"fileName", ",", "\"\\""}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}], ",", "1"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"y0", ",", "1"}], "}"}], ",", "0", ",", " ", RowBox[{ RowBox[{"Import", "[", RowBox[{"fileName", ",", "\"\\""}], "]"}], "[", RowBox[{"[", "2", "]"}], "]"}], ",", "1"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"yw", ",", "10"}], "}"}], ",", "0", ",", RowBox[{ RowBox[{"Import", "[", RowBox[{"fileName", ",", "\"\\""}], "]"}], "[", RowBox[{"[", "2", "]"}], "]"}], ",", "1"}], "}"}]}], "\[IndentingNewLine]", "]"}]}]], "Input", CellChangeTimes->{{3.5267925826704063`*^9, 3.5267926442459793`*^9}, { 3.526964762765864*^9, 3.52696479416549*^9}, {3.52696486051626*^9, 3.526964926247115*^9}, {3.526964966767301*^9, 3.526965111115406*^9}, { 3.526965143002955*^9, 3.52696515435299*^9}, {3.526965286915875*^9, 3.5269653051187983`*^9}, {3.5269653700509157`*^9, 3.526965497606999*^9}, { 3.5269655581322536`*^9, 3.526965578596285*^9}, {3.526965726735607*^9, 3.526965854549899*^9}, {3.5269659094585457`*^9, 3.52696591167093*^9}, { 3.5269659527146482`*^9, 3.526965956201066*^9}, {3.526966051393755*^9, 3.5269660983049097`*^9}, {3.5269690286232195`*^9, 3.526969086625144*^9}, { 3.526969913508322*^9, 3.5269699171176043`*^9}, {3.5269699504216056`*^9, 3.5269699678666945`*^9}, {3.5269704059592466`*^9, 3.5269704268342466`*^9}, { 3.526970576779559*^9, 3.526970577099871*^9}}], Cell[BoxData[""], "Input", CellChangeTimes->{{3.526965577796006*^9, 3.526965580789747*^9}}], Cell[CellGroupData[{ Cell["Examples ", "Section", CellChangeTimes->{{3.526791189386588*^9, 3.526791198740531*^9}}], Cell[BoxData[ RowBox[{"linearImageDistance", "[", "\"\\"", "]"}]], "Input", CellChangeTimes->{{3.526791019899602*^9, 3.526791026165698*^9}, { 3.526792323423689*^9, 3.5267923259729223`*^9}, {3.526964893450407*^9, 3.5269648950823593`*^9}, 3.526966111069371*^9, {3.526968465571181*^9, 3.526968466125762*^9}}, EmphasizeSyntaxErrors->True], Cell[BoxData[ RowBox[{"areaOfInterestAnalysis", "[", "\"\\"", "]"}]], "Input", CellChangeTimes->{{3.526964835649906*^9, 3.526964840776369*^9}, { 3.5269690451143017`*^9, 3.5269690468250422`*^9}, 3.5269698105578327`*^9}, EmphasizeSyntaxErrors->True], Cell[BoxData[{ RowBox[{"id", " ", "=", " ", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"0.5", ",", "0.25"}], "}"}], ",", RowBox[{"{", RowBox[{"0.75", ",", "0.9"}], "}"}]}], "}"}]}], "\[IndentingNewLine]", RowBox[{"Image", "[", RowBox[{"id", ",", RowBox[{"ImageSize", "\[Rule]", "256"}]}], "]"}]}], "Input", CellChangeTimes->{{3.5269695708070107`*^9, 3.526969647030769*^9}}], Cell[BoxData[ RowBox[{"MatrixForm", "[", "id", "]"}]], "Input", CellChangeTimes->{{3.5269696217894278`*^9, 3.5269696544993277`*^9}}], Cell[BoxData[ RowBox[{"Total", "[", "id", "]"}]], "Input", CellChangeTimes->{{3.526969707193291*^9, 3.5269697100135317`*^9}}], Cell[BoxData[ RowBox[{"Total", "[", RowBox[{"Transpose", "[", "id", "]"}], "]"}]], "Input", CellChangeTimes->{{3.526969733622302*^9, 3.526969738801857*^9}}] }, Open ]] }, WindowSize->{1279, 637}, WindowMargins->{{-17, Automatic}, {Automatic, 2}}, ShowSelection->True, FrontEndVersion->"8.0 for Microsoft Windows (32-bit) (February 23, 2011)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[557, 20, 6039, 146, 412, "Input"], Cell[6599, 168, 6486, 154, 572, "Input"], Cell[13088, 324, 92, 1, 31, "Input"], Cell[CellGroupData[{ Cell[13205, 329, 94, 1, 71, "Section"], Cell[13302, 332, 364, 6, 31, "Input"], Cell[13669, 340, 279, 5, 31, "Input"], Cell[13951, 347, 412, 11, 52, "Input"], Cell[14366, 360, 134, 2, 31, "Input"], Cell[14503, 364, 127, 2, 31, "Input"], Cell[14633, 368, 161, 3, 31, "Input"] }, Open ]] } ] *) (* End of internal cache information *)