(* Content-type: application/vnd.wolfram.mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 9.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 157, 7] NotebookDataLength[ 230141, 5836] NotebookOptionsPosition[ 224251, 5643] NotebookOutlinePosition[ 224616, 5659] CellTagsIndexPosition[ 224573, 5656] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell["\<\ Diploma thesis - Metrics for determination of patterns similarity Tom\[AAcute]\[SHacek] Kr\[CHacek] 2014\ \>", "Subtitle", CellChangeTimes->{{3.618836424694003*^9, 3.618836500160656*^9}}, TextAlignment->Center], Cell["\<\ All the sections and subsections can be collapsed and opened in order to \ manage the readibility of this document. First step should be to evaluate the \ initialization cells.\ \>", "Text", CellChangeTimes->{{3.618849864503448*^9, 3.6188498732536683`*^9}, { 3.6188499284218793`*^9, 3.6188499309316864`*^9}, {3.6188500233593736`*^9, 3.6188500835931573`*^9}, {3.6188503746870565`*^9, 3.618850392981057*^9}, { 3.618851185841503*^9, 3.618851222066248*^9}}], Cell[CellGroupData[{ Cell["\<\ 1. Loading ink jet paper images and computing their SVD\[CloseCurlyQuote]s\ \>", "Section", CellChangeTimes->{{3.6188365140014925`*^9, 3.6188365145418496`*^9}, 3.6188365465085735`*^9}], Cell[CellGroupData[{ Cell["Functions definition", "Subsection", CellChangeTimes->{{3.618836605574545*^9, 3.6188366090550184`*^9}}], Cell[TextData[{ StyleBox["LoadImageNames[path]", "Input"], " will load all the ink jet paper filenames from specified path into one \ vector.\n", StyleBox["importImageAndCalculateSVD[fileName,sizeSVD,numPatches,PatchSize]", "Input"], " imports one image at a time specified by it\[CloseCurlyQuote]s filename to \ prevent memory issues and calculates it\[CloseCurlyQuote]s SVD matrices using \ 3 parameters.\n", StyleBox["SVDsofAllImages[path,sizeSVD,numPtches,patchSize]", "Input"], " basically just calls ", StyleBox["importImageAndCalculateSVD[]", "Input"], " for all the images in specified path, not just one.\n", StyleBox["calculateSVDs[images,sizeSVD,numPatches,patchSize]", "Input"], " works the same way as ", StyleBox["SVDsofALLImages[]", "Input"], ", except the input can be any array of actual images, instead of importing \ them form defined folder.\n", StyleBox["readFunOne[filename, slices,{mh,mw}]", "Input"], " generates a given number of random patches (slices) of given size (mh,mw) \ from image that it imports using it\[CloseCurlyQuote]s filename.\n", StyleBox["readFun[image,slices,{mh,mw}] ", "Input"], "does exactly the same thing as", StyleBox[" readFunOne[],", "Input"], " except it doesn\[CloseCurlyQuote]", "t import the image but is given one as an input parameter.\n", StyleBox["buildFeatures[img]", "Input"], " collapses the patch into a single vector, substracts the mean from it.\n", StyleBox["loadSVDs[uAllname,wAllname]", "Input"], " just loads the SVD matrices from previously exported files, saving time \ and calculations." }], "Text", CellChangeTimes->{{3.594082793343889*^9, 3.594082837180856*^9}, { 3.5962343070434637`*^9, 3.5962343105409346`*^9}, {3.5962432473476024`*^9, 3.596243476406118*^9}, {3.5962441171869507`*^9, 3.596244124635214*^9}, { 3.596244238890816*^9, 3.5962442646810017`*^9}, {3.5962447344512014`*^9, 3.5962447588694677`*^9}, {3.6056363710650144`*^9, 3.6056363846896534`*^9}, { 3.6188366700493937`*^9, 3.618836739156479*^9}, {3.6188367737740817`*^9, 3.6188368855345135`*^9}, {3.6188375146686287`*^9, 3.618837560304083*^9}, { 3.6188388421680555`*^9, 3.6188389643759336`*^9}, {3.6188441780812287`*^9, 3.618844312579788*^9}, {3.618850234589464*^9, 3.6188502409319787`*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{ RowBox[{"LoadImageNames", "[", "path_", "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"microRakingPath", ",", "microImages"}], "}"}], ",", RowBox[{ RowBox[{"SetDirectory", "[", RowBox[{"NotebookDirectory", "[", "]"}], "]"}], ";", "\n", RowBox[{"microImages", "=", RowBox[{"FileNames", "[", RowBox[{"\"\<*.tif\>\"", ",", "path"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Return", "[", "microImages", "]"}], ";"}]}], "]"}]}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"importImageAndCalculateSVD", "[", RowBox[{ "fileName_", ",", "sizeSVD_", ",", "numPatches_", ",", "patchSize_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{ "allPatches", ",", "allFeatures", ",", "j", ",", "uAll", ",", "wAll", ",", "v"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"allPatches", "=", RowBox[{"Flatten", "[", RowBox[{"readFunOne", "[", RowBox[{"fileName", ",", "numPatches", ",", RowBox[{"{", RowBox[{"patchSize", ",", "patchSize"}], "}"}]}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"allFeatures", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"buildFeatures", "[", RowBox[{"allPatches", "[", RowBox[{"[", "j", "]"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", "numPatches"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"{", RowBox[{"uAll", ",", "wAll", ",", "v"}], "}"}], "=", RowBox[{"SingularValueDecomposition", "[", RowBox[{ RowBox[{"Transpose", "[", "allFeatures", "]"}], ",", "sizeSVD"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Return", "[", RowBox[{"{", RowBox[{"uAll", ",", "wAll"}], "}"}], "]"}]}]}], "]"}]}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"SVDsofAllImages", "[", RowBox[{"path_", ",", "sizeSVD_", ",", "numPatches_", ",", "patchSize_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{ "microImages", ",", "variable", ",", "uAll", ",", "wAll", ",", "i"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"microImages", "=", RowBox[{"LoadImageNames", "[", "path", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"variable", "=", RowBox[{ RowBox[{ RowBox[{"importImageAndCalculateSVD", "[", RowBox[{"#", ",", "sizeSVD", ",", "numPatches", ",", "patchSize"}], "]"}], "&"}], "/@", "microImages"}]}], ";", "\[IndentingNewLine]", RowBox[{"uAll", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"variable", "[", RowBox[{"[", RowBox[{"i", ",", "1"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", RowBox[{"Length", "[", "microImages", "]"}]}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"wAll", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"variable", "[", RowBox[{"[", RowBox[{"i", ",", "2"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", RowBox[{"Length", "[", "microImages", "]"}]}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Return", "[", RowBox[{"{", RowBox[{"uAll", ",", "wAll"}], "}"}], "]"}]}]}], "]"}]}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"calculateSVDs", "[", RowBox[{ "images_", ",", "sizeSVD_", ",", "numPatches_", ",", "patchSize_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{ "allPatches", ",", "allFeatures", ",", "uAll", ",", "wAll", ",", "numPics", ",", "i", ",", "j", ",", "u", ",", "w", ",", "v"}], "}"}], ",", RowBox[{ RowBox[{"numPics", "=", RowBox[{"Length", "[", "images", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"allPatches", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"Flatten", "[", RowBox[{"readFun", "[", RowBox[{ RowBox[{"images", "[", RowBox[{"[", "i", "]"}], "]"}], ",", "numPatches", ",", RowBox[{"{", RowBox[{"patchSize", ",", "patchSize"}], "}"}]}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "numPics"}], "}"}]}], "]"}]}], ";", RowBox[{"allFeatures", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"buildFeatures", "[", RowBox[{"allPatches", "[", RowBox[{"[", RowBox[{"i", ",", "j"}], "]"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "numPics"}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", "numPatches"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"uAll", "=", RowBox[{"ConstantArray", "[", RowBox[{ RowBox[{"{", "}"}], ",", "numPics"}], "]"}]}], ";", "\n", RowBox[{"wAll", "=", RowBox[{"ConstantArray", "[", RowBox[{ RowBox[{"{", "}"}], ",", "numPics"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"{", RowBox[{"u", ",", "w", ",", "v"}], "}"}], "=", RowBox[{"SingularValueDecomposition", "[", RowBox[{ RowBox[{"Transpose", "[", RowBox[{"allFeatures", "[", RowBox[{"[", "i", "]"}], "]"}], "]"}], ",", "sizeSVD"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"uAll", "[", RowBox[{"[", "i", "]"}], "]"}], "=", "u"}], ";", RowBox[{ RowBox[{"wAll", "[", RowBox[{"[", "i", "]"}], "]"}], "=", "w"}], ";"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "numPics"}], "}"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"Return", "[", RowBox[{"{", RowBox[{"uAll", ",", "wAll"}], "}"}], "]"}]}]}], "]"}]}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{ RowBox[{"readFunOne", "[", RowBox[{"fileName_", ",", "slices_", ",", RowBox[{"{", RowBox[{"mh_", ",", "mw_"}], "}"}]}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{ "img", ",", "imgH", ",", "imgW", ",", "subImgs", ",", "indH", ",", "indW", ",", "p"}], "}"}], ",", RowBox[{ RowBox[{"img", "=", RowBox[{"Import", "[", "fileName", "]"}]}], ";", "\n", RowBox[{ RowBox[{"{", RowBox[{"imgW", ",", "imgH"}], "}"}], "=", RowBox[{"ImageDimensions", "[", "img", "]"}]}], ";", "\n", RowBox[{"indH", "=", RowBox[{"RandomVariate", "[", RowBox[{ RowBox[{"DiscreteUniformDistribution", "[", RowBox[{"{", RowBox[{"1", ",", RowBox[{"imgH", "-", "mh"}]}], "}"}], "]"}], ",", "slices"}], "]"}]}], ";", "\n", RowBox[{"indW", "=", RowBox[{"RandomVariate", "[", RowBox[{ RowBox[{"DiscreteUniformDistribution", "[", RowBox[{"{", RowBox[{"1", ",", RowBox[{"imgW", "-", "mw"}]}], "}"}], "]"}], ",", "slices"}], "]"}]}], ";", "\n", RowBox[{"Table", "[", RowBox[{ RowBox[{"ImageTake", "[", RowBox[{"img", ",", RowBox[{"{", RowBox[{ RowBox[{"indH", "[", RowBox[{"[", "p", "]"}], "]"}], ",", RowBox[{ RowBox[{"indH", "[", RowBox[{"[", "p", "]"}], "]"}], "+", "mh", "-", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"indW", "[", RowBox[{"[", "p", "]"}], "]"}], ",", RowBox[{ RowBox[{"indW", "[", RowBox[{"[", "p", "]"}], "]"}], "+", "mw", "-", "1"}]}], "}"}]}], "]"}], ",", RowBox[{"{", RowBox[{"p", ",", "1", ",", "slices"}], "}"}]}], "]"}]}]}], "]"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{ RowBox[{"readFun", "[", RowBox[{"image_", ",", "slices_", ",", RowBox[{"{", RowBox[{"mh_", ",", "mw_"}], "}"}]}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{ "img", ",", "imgH", ",", "imgW", ",", "subImgs", ",", "indH", ",", "indW", ",", "p"}], "}"}], ",", RowBox[{ RowBox[{"img", "=", "image"}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"{", RowBox[{"imgW", ",", "imgH"}], "}"}], "=", RowBox[{"ImageDimensions", "[", "img", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"indH", "=", RowBox[{"RandomVariate", "[", RowBox[{ RowBox[{"DiscreteUniformDistribution", "[", RowBox[{"{", RowBox[{"1", ",", RowBox[{"imgH", "-", "mh"}]}], "}"}], "]"}], ",", "slices"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"indW", "=", RowBox[{"RandomVariate", "[", RowBox[{ RowBox[{"DiscreteUniformDistribution", "[", RowBox[{"{", RowBox[{"1", ",", RowBox[{"imgW", "-", "mw"}]}], "}"}], "]"}], ",", "slices"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Table", "[", RowBox[{ RowBox[{"ImageTake", "[", RowBox[{"img", ",", RowBox[{"{", RowBox[{ RowBox[{"indH", "[", RowBox[{"[", "p", "]"}], "]"}], ",", RowBox[{ RowBox[{"indH", "[", RowBox[{"[", "p", "]"}], "]"}], "+", "mh", "-", "1"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"indW", "[", RowBox[{"[", "p", "]"}], "]"}], ",", RowBox[{ RowBox[{"indW", "[", RowBox[{"[", "p", "]"}], "]"}], "+", "mw", "-", "1"}]}], "}"}]}], "]"}], ",", RowBox[{"{", RowBox[{"p", ",", "1", ",", "slices"}], "}"}]}], "]"}]}]}], "]"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{ RowBox[{"buildFeatures", "[", "img_", "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "flatImg", "}"}], ",", RowBox[{ RowBox[{"flatImg", "=", RowBox[{"Flatten", "[", RowBox[{"ImageData", "[", "img", "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"flatImg", "-", RowBox[{"Mean", "[", "flatImg", "]"}]}]}]}], "]"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"loadSVDs", "[", RowBox[{"uAllname_", ",", "wAllname_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"uAll", ",", "wAll"}], "}"}], ",", RowBox[{ RowBox[{"SetDirectory", "[", RowBox[{"NotebookDirectory", "[", "]"}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"uAll", "=", RowBox[{"Import", "[", "uAllname", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"wAll", "=", RowBox[{"Import", "[", "wAllname", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Return", "[", RowBox[{"{", RowBox[{"uAll", ",", "wAll"}], "}"}], "]"}]}]}], "]"}]}]}], "Input", InitializationCell->True, CellChangeTimes->{{3.594126267070262*^9, 3.594126318166314*^9}, { 3.594126373372265*^9, 3.5941263926028323`*^9}, {3.5945009294926343`*^9, 3.5945009759914865`*^9}, 3.594501054125677*^9, {3.594501172953618*^9, 3.5945014465979214`*^9}, {3.5945015057697096`*^9, 3.5945015124804544`*^9}, 3.594501546766694*^9, {3.59450197667638*^9, 3.594502014462073*^9}, { 3.59450210362706*^9, 3.5945021070884876`*^9}, {3.5948184019022026`*^9, 3.594818447889758*^9}, {3.5956395976969314`*^9, 3.595639597707939*^9}, { 3.596135184065552*^9, 3.596135237489306*^9}, 3.5961354354402204`*^9, 3.5961354754815235`*^9, {3.5961994322974415`*^9, 3.5961994341387224`*^9}, { 3.5962342746716394`*^9, 3.5962343163750496`*^9}, {3.596234373228134*^9, 3.596234373859579*^9}, {3.5962432320988493`*^9, 3.596243233275678*^9}, { 3.596243266345999*^9, 3.5962432675578527`*^9}, {3.596243584211134*^9, 3.596243608284108*^9}, {3.596244719617753*^9, 3.596244720250188*^9}, 3.6013325021281676`*^9, 3.601333734974062*^9, {3.6013339024523706`*^9, 3.6013339127186227`*^9}, {3.601338985968419*^9, 3.6013390015614333`*^9}, { 3.601412427160694*^9, 3.6014124283555326`*^9}, {3.6014124655247784`*^9, 3.601412469993952*^9}, 3.601412517731657*^9, {3.601420507195115*^9, 3.6014205580150313`*^9}, {3.601421169875255*^9, 3.6014211712542295`*^9}, { 3.6054377759561453`*^9, 3.605437804894639*^9}, {3.605437910665478*^9, 3.6054379177865176`*^9}, {3.60543795765475*^9, 3.6054379883454523`*^9}, 3.6054382160956287`*^9, {3.6056361137831573`*^9, 3.605636151138568*^9}, { 3.6056362881664233`*^9, 3.6056363034822454`*^9}, {3.6056363579037113`*^9, 3.605636358865393*^9}, 3.605638439831297*^9, 3.606047998706786*^9, { 3.606249823474062*^9, 3.606249824018446*^9}, 3.606332849862663*^9, { 3.609620604071958*^9, 3.609620627310403*^9}, 3.617447192495923*^9, { 3.6180433842950344`*^9, 3.6180433900601144`*^9}, {3.6188366341868873`*^9, 3.6188366355678873`*^9}, {3.6188374761282606`*^9, 3.618837508024929*^9}, { 3.6188388329765224`*^9, 3.618838833610982*^9}, {3.618844162004778*^9, 3.6188441626742606`*^9}}] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["2. Matrix distance", "Section", CellChangeTimes->{{3.6188377908679433`*^9, 3.6188378232639637`*^9}}], Cell[CellGroupData[{ Cell["Usual distance metrics", "Subsection", CellChangeTimes->{{3.618837893037551*^9, 3.6188378967181463`*^9}, { 3.6188380109213305`*^9, 3.61883801323295*^9}, {3.618838049295602*^9, 3.618838049397673*^9}}], Cell["\<\ Three usual distance metrics are defined below. Minkowski distance, ASM \ distance and Yang distance. Output of those function is a corresponding \ similarity matrix.\ \>", "Text", CellChangeTimes->{{3.6188379821648655`*^9, 3.6188379839881887`*^9}, { 3.6188380203580356`*^9, 3.6188380847357645`*^9}, {3.618838451729577*^9, 3.618838471389576*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{ RowBox[{"minkowskiDist", "[", RowBox[{"matrix1_", ",", "matrix2_", ",", "x_"}], "]"}], ":=", RowBox[{ RowBox[{"(", RowBox[{"Total", "[", RowBox[{ RowBox[{"Total", "[", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"Abs", "[", RowBox[{"matrix1", "-", "matrix2"}], "]"}], ")"}], "^", "x"}], ",", RowBox[{"{", "2", "}"}]}], "]"}], ",", RowBox[{"{", "1", "}"}]}], "]"}], ")"}], "^", RowBox[{"(", RowBox[{"1", "/", "x"}], ")"}]}]}], " ", "\[IndentingNewLine]", RowBox[{"(*", "\[IndentingNewLine]", RowBox[{ RowBox[{"Parameter", " ", "x"}], "=", RowBox[{ RowBox[{"1", "\[Rule]", RowBox[{"Manhattan", " ", "model", "\n", "Parameter", " ", "x"}]}], "=", RowBox[{ RowBox[{"2", "\[Rule]", RowBox[{"Euclidean", " ", "distance", " ", RowBox[{"(", RowBox[{"=", RowBox[{"Frobenius", " ", "distance"}]}], ")"}], "\n", "Parameter", " ", "x"}]}], "=", RowBox[{ RowBox[{">", "inf"}], "\[Rule]", RowBox[{"Chebyshev", " ", "distance"}]}]}]}]}], "\[IndentingNewLine]", "*)"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"asmDistance", "[", RowBox[{"matrix1_", ",", "matrix2_", ",", "x_"}], "]"}], ":=", RowBox[{ RowBox[{"(", RowBox[{"Total", "[", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"Total", "[", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"matrix1", "-", "matrix2"}], ")"}], "^", "2"}], ",", RowBox[{"{", "2", "}"}]}], "]"}], ")"}], "^", RowBox[{"(", RowBox[{ RowBox[{"(", RowBox[{"1", "*", "x"}], ")"}], "/", "2"}], ")"}]}], ",", RowBox[{"{", "1", "}"}]}], "]"}], ")"}], "^", RowBox[{"(", RowBox[{"1", "/", "x"}], ")"}]}]}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"yangDistance", "[", RowBox[{"matrix1_", ",", "matrix2_"}], "]"}], ":=", RowBox[{"Total", "[", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"Total", "[", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"matrix1", "-", "matrix2"}], ")"}], "^", "2"}], ",", RowBox[{"{", "2", "}"}]}], "]"}], ")"}], "^", RowBox[{"(", RowBox[{"1", "/", "2"}], ")"}]}], ",", RowBox[{"{", "1", "}"}]}], "]"}]}]}], "Input", InitializationCell->True, CellChangeTimes->CompressedData[" 1:eJxTTMoPSmViYGAQB2IQfWqD+uKcva8cd7vFLgHRHUea7oHo5+7TwfS9Zh32 XCAd/cyaF0TP7mSWA9Fqn/i0QLRcSWIIiFYtSgPTOn9ezwPRoa36i0D0Ejdz gTwgXRLvDqbXnJghC6Ln63DKgenLWhog+tLyBjC9ZZ3ChXwgfeHz8ysgetsa zn8gWuHOEdYCIP1FgJ0LRBf0MnCDaPHiJeIgun7NCjC9p7FHGkRf6fOXAdEi l/T3FYL4+cZgelmMqnoxkOb6MwNMT1rPrw+ixVwiwPSxFzmuIHrjh6dg+sy0 F4t27n/lmLBOdh2I7ulj2wOiX96U3Aeineaw7Uj69sox3evbThC9ZtGqfSDa w+c0mL7WyncOROfUyl4A0QB468br "]] }, Open ]], Cell[CellGroupData[{ Cell["Distance similarities", "Subsection", CellChangeTimes->{{3.6188380972876883`*^9, 3.618838102447348*^9}}], Cell["\<\ Functions to compue weight vector, EROS similarity, PCA similarity and Cosine \ similarity are below. Again, output of the similarities is similarity matrix.\ \>", "Text", CellChangeTimes->{{3.618838218710001*^9, 3.618838267342537*^9}, { 3.618838474981129*^9, 3.618838521171934*^9}, 3.6188502047782774`*^9}], Cell[BoxData[{ RowBox[{ RowBox[{ RowBox[{ RowBox[{"weightVector", "[", RowBox[{"wAll_", ",", "dimensions_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{ "diagonalW", ",", "diagonalW2", ",", "wiTemp", ",", "wiTemp2", ",", "i"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"diagonalW", "=", RowBox[{"Transpose", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{"Diagonal", "[", RowBox[{"wAll", "[", RowBox[{"[", "i", "]"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", RowBox[{"dimensions", "[", RowBox[{"[", "1", "]"}], "]"}]}], "}"}]}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"diagonalW2", "=", RowBox[{"Transpose", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"diagonalW", "[", RowBox[{"[", RowBox[{"All", ",", "i"}], "]"}], "]"}], "/", RowBox[{"Total", "[", RowBox[{"diagonalW", "[", RowBox[{"[", RowBox[{"All", ",", "i"}], "]"}], "]"}], "]"}]}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", RowBox[{"dimensions", "[", RowBox[{"[", "1", "]"}], "]"}]}], "}"}]}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"wiTemp", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"Mean", "[", RowBox[{"diagonalW2", "[", RowBox[{"[", RowBox[{"i", ",", "All"}], "]"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", RowBox[{"dimensions", "[", RowBox[{"[", "3", "]"}], "]"}]}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"wiTemp2", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"wiTemp", "[", RowBox[{"[", "i", "]"}], "]"}], "/", RowBox[{"Total", "[", "wiTemp", "]"}]}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", RowBox[{"dimensions", "[", RowBox[{"[", "3", "]"}], "]"}]}], "}"}]}], "]"}]}]}]}], "]"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"erosDistance", "[", RowBox[{"uAll_", ",", "wAll_", ",", "dimensions_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"i", ",", "k", ",", "l"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"Table", "[", RowBox[{ RowBox[{"Total", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"weightVector", "[", RowBox[{"wAll", ",", "dimensions"}], "]"}], "[", RowBox[{"[", "i", "]"}], "]"}], " ", RowBox[{"Abs", "[", RowBox[{ RowBox[{"uAll", "[", RowBox[{"[", RowBox[{"k", ",", "All", ",", "i"}], "]"}], "]"}], ".", RowBox[{"uAll", "[", RowBox[{"[", RowBox[{"l", ",", "All", ",", "i"}], "]"}], "]"}]}], "]"}]}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"dimensions", "[", RowBox[{"[", "3", "]"}], "]"}]}], "}"}]}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"k", ",", RowBox[{"dimensions", "[", RowBox[{"[", "1", "]"}], "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"l", ",", RowBox[{"dimensions", "[", RowBox[{"[", "1", "]"}], "]"}]}], "}"}]}], "]"}]}], "]"}]}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"pcaDistance", "[", RowBox[{"uAll_", ",", "wAll_", ",", "dimensions_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"em", ",", "el", ",", "i", ",", "j"}], "}"}], ",", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"em", "=", RowBox[{"Transpose", "[", RowBox[{"uAll", "[", RowBox[{"[", "i", "]"}], "]"}], "]"}]}], ";", RowBox[{"el", "=", RowBox[{"Transpose", "[", RowBox[{"uAll", "[", RowBox[{"[", "j", "]"}], "]"}], "]"}]}], ";", RowBox[{"Tr", "[", RowBox[{"el", ".", RowBox[{"Transpose", "[", "em", "]"}], ".", RowBox[{"DiagonalMatrix", "[", RowBox[{"weightVector", "[", RowBox[{"wAll", ",", "dimensions"}], "]"}], "]"}], ".", "em", ".", RowBox[{"Transpose", "[", "el", "]"}]}], "]"}]}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", RowBox[{"dimensions", "[", RowBox[{"[", "1", "]"}], "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", RowBox[{"dimensions", "[", RowBox[{"[", "1", "]"}], "]"}]}], "}"}]}], "]"}]}], "]"}]}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"cosDistance", "[", RowBox[{"uAll_", ",", "wAll_", ",", "dimensions_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"i", ",", "k", ",", "l"}], "}"}], ",", RowBox[{ RowBox[{"weightVector", "[", RowBox[{"wAll", ",", "dimensions"}], "]"}], ".", RowBox[{"Table", "[", RowBox[{ RowBox[{"Max", "[", RowBox[{"Abs", "[", RowBox[{ RowBox[{"uAll", "[", RowBox[{"[", RowBox[{"l", ",", "All", ",", "i"}], "]"}], "]"}], ".", RowBox[{"uAll", "[", RowBox[{"[", RowBox[{"k", ",", "All", ",", "All"}], "]"}], "]"}]}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"dimensions", "[", RowBox[{"[", "3", "]"}], "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"k", ",", RowBox[{"dimensions", "[", RowBox[{"[", "1", "]"}], "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"l", ",", RowBox[{"dimensions", "[", RowBox[{"[", "1", "]"}], "]"}]}], "}"}]}], "]"}]}]}], "]"}]}]}], "Input", InitializationCell->True, CellChangeTimes->{{3.618838277964091*^9, 3.618838285923748*^9}, { 3.6188383167436523`*^9, 3.618838318678046*^9}, {3.6188383673476133`*^9, 3.6188383779831724`*^9}, {3.618838493724449*^9, 3.6188384961251345`*^9}}], Cell["\<\ Functions bellow can be used to classify just one SVD matrix instead of all \ of them.\ \>", "Text", CellChangeTimes->{{3.6188467174528985`*^9, 3.618846749861952*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{ RowBox[{"erosDistanceOne", "[", RowBox[{"uAll_", ",", "thisuAll_", ",", "weightV_", ",", "dimensions_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"i", ",", "k"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"Table", "[", RowBox[{ RowBox[{"Total", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"weightV", "[", RowBox[{"[", "i", "]"}], "]"}], " ", RowBox[{"Abs", "[", RowBox[{ RowBox[{"uAll", "[", RowBox[{"[", RowBox[{"k", ",", "All", ",", "i"}], "]"}], "]"}], ".", RowBox[{"thisuAll", "[", RowBox[{"[", RowBox[{"All", ",", "i"}], "]"}], "]"}]}], "]"}]}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"dimensions", "[", RowBox[{"[", "3", "]"}], "]"}]}], "}"}]}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"k", ",", "1", ",", RowBox[{"dimensions", "[", RowBox[{"[", "1", "]"}], "]"}]}], "}"}]}], "]"}]}], "]"}]}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"pcaDistanceOne", "[", RowBox[{"uAll_", ",", "thisuAll_", ",", "weightV_", ",", "dimensions_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"el", ",", "em", ",", "i"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"em", "=", RowBox[{"Transpose", "[", RowBox[{"uAll", "[", RowBox[{"[", "i", "]"}], "]"}], "]"}]}], ";", RowBox[{"el", "=", RowBox[{"Transpose", "[", "thisuAll", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Tr", "[", RowBox[{"el", ".", RowBox[{"Transpose", "[", "em", "]"}], ".", RowBox[{"DiagonalMatrix", "[", "weightV", "]"}], ".", "em", ".", RowBox[{"Transpose", "[", "el", "]"}]}], "]"}]}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", RowBox[{"dimensions", "[", RowBox[{"[", "1", "]"}], "]"}]}], "}"}]}], "]"}]}], "]"}]}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"cosDistanceOne", "[", RowBox[{"uAll_", ",", "thisuAll_", ",", "weightV_", ",", "dimensions_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "}"}], ",", "\[IndentingNewLine]", RowBox[{"weightV", ".", RowBox[{"Table", "[", RowBox[{ RowBox[{"Max", "[", RowBox[{"Abs", "[", RowBox[{ RowBox[{"thisuAll", "[", RowBox[{"[", RowBox[{"All", ",", "i"}], "]"}], "]"}], ".", RowBox[{"uAll", "[", RowBox[{"[", RowBox[{"k", ",", "All", ",", "All"}], "]"}], "]"}]}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"dimensions", "[", RowBox[{"[", "3", "]"}], "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"k", ",", RowBox[{"dimensions", "[", RowBox[{"[", "1", "]"}], "]"}]}], "}"}]}], "]"}]}]}], "]"}]}]}], "Input", InitializationCell->True, CellChangeTimes->{{3.618846764824586*^9, 3.618846785665377*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["\<\ Functions for calculating and plotting both usual metrics and similarities\ \>", "Subsection", CellChangeTimes->{{3.618838547994991*^9, 3.618838607865567*^9}, { 3.618838762681594*^9, 3.618838766191063*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{ RowBox[{"calculateUsualDistances", "[", "uAll_", "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"dMinkowski", ",", "dASM", ",", "dYang"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"dMinkowski", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"minkowskiDist", "[", RowBox[{ RowBox[{"uAll", "[", RowBox[{"[", "i", "]"}], "]"}], ",", "#", ",", "2"}], "]"}], "&"}], "/@", "uAll"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", RowBox[{"Length", "[", "uAll", "]"}]}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"dASM", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"asmDistance", "[", RowBox[{ RowBox[{"uAll", "[", RowBox[{"[", "i", "]"}], "]"}], ",", "#", ",", "0.125"}], "]"}], "&"}], "/@", "uAll"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", RowBox[{"Length", "[", "uAll", "]"}]}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"dYang", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"yangDistance", "[", RowBox[{ RowBox[{"uAll", "[", RowBox[{"[", "i", "]"}], "]"}], ",", "#"}], "]"}], "&"}], "/@", "uAll"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", RowBox[{"Length", "[", "uAll", "]"}]}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Return", "[", RowBox[{"{", RowBox[{"dMinkowski", ",", "dASM", ",", "dYang"}], "}"}], "]"}]}]}], "\[IndentingNewLine]", "]"}]}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"calculateDistances", "[", RowBox[{"uAll_", ",", "wAll_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"ed", ",", "epca", ",", "ecos", ",", "dimensions"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"dimensions", "=", RowBox[{"Dimensions", "[", "uAll", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"ed", "=", RowBox[{"erosDistance", "[", RowBox[{"uAll", ",", "wAll", ",", "dimensions"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"epca", "=", RowBox[{"pcaDistance", "[", RowBox[{"uAll", ",", "wAll", ",", "dimensions"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"ecos", "=", RowBox[{"cosDistance", "[", RowBox[{"uAll", ",", "wAll", ",", "dimensions"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Return", "[", RowBox[{"{", RowBox[{"ed", ",", "epca", ",", "ecos"}], "}"}], "]"}]}]}], "\[IndentingNewLine]", "]"}]}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"drawDistances", "[", RowBox[{"dEROS_", ",", "dPCA_", ",", "dCOS_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "}"}], ",", "\[IndentingNewLine]", RowBox[{"Labeled", "[", RowBox[{ RowBox[{"Grid", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{ RowBox[{ RowBox[{"Text", "@", RowBox[{"Style", "[", RowBox[{"#", ",", "\"\\"", ",", "Larger"}], "]"}]}], "&"}], "/@", RowBox[{"{", RowBox[{ "\"\\"", ",", "\"\\"", ",", "\"\\""}], "}"}]}], ",", RowBox[{"{", RowBox[{ RowBox[{"ArrayPlot", "[", RowBox[{ RowBox[{"dEROS", "-", RowBox[{"Min", "[", "dEROS", "]"}]}], ",", RowBox[{"ImageSize", "\[Rule]", "270"}]}], "]"}], ",", RowBox[{"ArrayPlot", "[", RowBox[{ RowBox[{"dPCA", "-", RowBox[{"Min", "[", "dPCA", "]"}]}], ",", RowBox[{"ImageSize", "\[Rule]", "270"}]}], "]"}], ",", RowBox[{"ArrayPlot", "[", RowBox[{ RowBox[{"dCOS", "-", RowBox[{"Min", "[", "dCOS", "]"}]}], ",", RowBox[{"ImageSize", "\[Rule]", "270"}]}], "]"}]}], "}"}], ",", RowBox[{ RowBox[{ RowBox[{"Text", "@", RowBox[{"Style", "[", RowBox[{"#", ",", "\"\\"", ",", "Larger"}], "]"}]}], "&"}], "/@", RowBox[{"{", RowBox[{ RowBox[{"Min", "[", "dEROS", "]"}], ",", RowBox[{"Min", "[", "dPCA", "]"}], ",", RowBox[{"Min", "[", "dCOS", "]"}]}], "}"}]}]}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"Alignment", "\[Rule]", RowBox[{"{", RowBox[{"Center", ",", RowBox[{"{", RowBox[{"Bottom", ",", "Top"}], "}"}]}], "}"}]}], ",", RowBox[{"Frame", "\[Rule]", "All"}], ",", RowBox[{"Spacings", "\[Rule]", RowBox[{"{", RowBox[{"0", ",", "1"}], "}"}]}]}], "]"}], ",", RowBox[{"Text", "@", RowBox[{"Style", "[", RowBox[{ "\"\\"", ",", "\"\\"", ",", "Larger"}], "]"}]}], ",", RowBox[{"{", RowBox[{"{", RowBox[{"Bottom", ",", "Center"}], "}"}], "}"}]}], "]"}]}], "]"}]}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"drawUsualDistances", "[", RowBox[{"dMinkowski_", ",", "dASM_", ",", "dYang_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "}"}], ",", "\[IndentingNewLine]", RowBox[{"Labeled", "[", RowBox[{ RowBox[{"Grid", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{ RowBox[{ RowBox[{"Text", "@", RowBox[{"Style", "[", RowBox[{"#", ",", "\"\\"", ",", "Larger"}], "]"}]}], "&"}], "/@", RowBox[{"{", RowBox[{ "\"\\"", ",", "\"\\"", ",", "\"\\""}], "}"}]}], ",", RowBox[{"{", RowBox[{ RowBox[{"Image", "[", RowBox[{ RowBox[{"ColorNegate", "[", RowBox[{"ArrayPlot", "[", "dMinkowski", "]"}], "]"}], ",", RowBox[{"ImageSize", "\[Rule]", "270"}]}], "]"}], ",", RowBox[{"Image", "[", RowBox[{ RowBox[{"ColorNegate", "[", RowBox[{"ArrayPlot", "[", "dASM", "]"}], "]"}], ",", RowBox[{"ImageSize", "\[Rule]", "270"}]}], "]"}], ",", RowBox[{"Image", "[", RowBox[{ RowBox[{"ColorNegate", "[", RowBox[{"ArrayPlot", "[", "dYang", "]"}], "]"}], ",", RowBox[{"ImageSize", "\[Rule]", "270"}]}], "]"}]}], "}"}]}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"Alignment", "\[Rule]", RowBox[{"{", RowBox[{"Center", ",", RowBox[{"{", RowBox[{"Bottom", ",", "Top"}], "}"}]}], "}"}]}], ",", RowBox[{"Frame", "\[Rule]", "All"}], ",", RowBox[{"Spacings", "\[Rule]", RowBox[{"{", RowBox[{"0", ",", "1"}], "}"}]}]}], "]"}], ",", RowBox[{"Text", "@", RowBox[{"Style", "[", RowBox[{ "\"\\"", ",", "\"\\"", ",", "Larger"}], "]"}]}], ",", RowBox[{"{", RowBox[{"{", RowBox[{"Bottom", ",", "Center"}], "}"}], "}"}]}], "]"}]}], "]"}]}]}], "Input", InitializationCell->True, CellChangeTimes->{{3.6188387753375673`*^9, 3.6188387932162724`*^9}, { 3.6188438045627756`*^9, 3.6188438612880745`*^9}, 3.6188444505848722`*^9, { 3.61884550649128*^9, 3.618845510458109*^9}, {3.6188456492707796`*^9, 3.618845668095138*^9}, {3.6188457712464657`*^9, 3.6188457963612943`*^9}, { 3.618845918954418*^9, 3.618845921571299*^9}, {3.6188460162095575`*^9, 3.618846039404041*^9}, {3.61884607069125*^9, 3.6188460761591625`*^9}, { 3.618846145036113*^9, 3.618846165011308*^9}}] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["3. Voting algorithm", "Section", CellChangeTimes->{{3.618838752094068*^9, 3.6188387527615433`*^9}, { 3.6188390014392586`*^9, 3.618839006239686*^9}}], Cell[TextData[{ "Function ", StyleBox["doClassification[]", "Input"], " is used for computing the original voting algorithm and all the \ combinations of voting algorithm with matrix similarities. One can needs to \ specify the type of algorithm (", "\[OpenCurlyDoubleQuote]EROS\[CloseCurlyDoubleQuote],\[CloseCurlyDoubleQuote]\ PCA\[CloseCurlyDoubleQuote],\[CloseCurlyDoubleQuote]COS\ \[CloseCurlyDoubleQuote],\[CloseCurlyDoubleQuote]SimWI\[CloseCurlyDoubleQuote]\ ", "), SVD matrices and path where to find the images, and also select the \ number of image that should be classified with certain number of drawn \ patches (noted as \[OpenCurlyDoubleQuote]Q\[CloseCurlyDoubleQuote] in the \ text).\nFunction ", StyleBox["simWI[]", "Input"], " can be used to calculate the overal assesment (noted as \ \[OpenCurlyDoubleQuote]g\[CloseCurlyDoubleQuote] in text) from the sorted \ counts obtained by ", StyleBox["doClassification[]", "Input"], "." }], "Text", CellChangeTimes->{{3.6188391241564603`*^9, 3.6188391456197405`*^9}, { 3.6188391773993254`*^9, 3.618839223813311*^9}, {3.6188392564364767`*^9, 3.6188394465556107`*^9}, {3.6188395003738585`*^9, 3.6188395373541136`*^9}, { 3.618839603669269*^9, 3.618839625092474*^9}, {3.618840341337491*^9, 3.6188404824938354`*^9}, {3.618840820918327*^9, 3.618840822040146*^9}, { 3.6188422994090605`*^9, 3.618842301638672*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{ RowBox[{ RowBox[{"doClassification", "[", RowBox[{ "distanceType_", ",", "uAll_", ",", "wAll_", ",", "path_", ",", "images_", ",", "thisClass_", ",", "numTests_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{ "allImages", ",", "thisImage", ",", "imgTest", ",", "testFeatures", ",", "distClasses", ",", "closestOnes", ",", "result", ",", "weightV", ",", "uAllNew", ",", "wAllNew", ",", "v", ",", "tempVector", ",", "dimensions", ",", "el", ",", "em"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"allImages", "=", RowBox[{ RowBox[{"LoadImageNames", "[", "path", "]"}], "[", RowBox[{"[", "images", "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"thisImage", "=", RowBox[{ RowBox[{"LoadImageNames", "[", "path", "]"}], "[", RowBox[{"[", "thisClass", "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"dimensions", "=", RowBox[{"Dimensions", "[", "uAll", "]"}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"distanceType", "==", "\"\\""}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"imgTest", "=", RowBox[{"Flatten", "[", RowBox[{"readFunOne", "[", RowBox[{"thisImage", ",", "numTests", ",", RowBox[{"{", RowBox[{"patchSize", ",", "patchSize"}], "}"}]}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"testFeatures", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"buildFeatures", "[", RowBox[{"imgTest", "[", RowBox[{"[", "j", "]"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", "numTests"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"distClasses", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"Norm", "[", RowBox[{ RowBox[{"testFeatures", "[", RowBox[{"[", "i", "]"}], "]"}], "-", RowBox[{ RowBox[{"uAll", "[", RowBox[{"[", "j", "]"}], "]"}], ".", RowBox[{"(", RowBox[{ RowBox[{"Transpose", "[", RowBox[{"uAll", "[", RowBox[{"[", "j", "]"}], "]"}], "]"}], ".", RowBox[{"testFeatures", "[", RowBox[{"[", "i", "]"}], "]"}]}], ")"}]}]}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "numTests"}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", RowBox[{"dimensions", "[", RowBox[{"[", "1", "]"}], "]"}]}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"closestOnes", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"Ordering", "[", RowBox[{"distClasses", "[", RowBox[{"[", "i", "]"}], "]"}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "numTests"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"result", "=", RowBox[{"Reverse", "[", RowBox[{"Sort", "[", RowBox[{ RowBox[{"Tally", "[", "closestOnes", "]"}], ",", RowBox[{ RowBox[{ RowBox[{"#1", "[", RowBox[{"[", "2", "]"}], "]"}], "<", RowBox[{"#2", "[", RowBox[{"[", "2", "]"}], "]"}]}], "&"}]}], "]"}], "]"}]}]}], ",", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{ RowBox[{"weightV", "=", RowBox[{"weightVector", "[", RowBox[{"wAll", ",", "dimensions"}], "]"}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"closestOnes", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"imgTest", "=", RowBox[{"Flatten", "[", RowBox[{"readFunOne", "[", RowBox[{"thisImage", ",", "numTests", ",", RowBox[{"{", RowBox[{"patchSize", ",", "patchSize"}], "}"}]}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"testFeatures", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"buildFeatures", "[", RowBox[{"imgTest", "[", RowBox[{"[", "j", "]"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", " ", "numTests"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"{", RowBox[{"uAllNew", ",", "wAllNew", ",", "v"}], "}"}], "=", RowBox[{"SingularValueDecomposition", "[", RowBox[{ RowBox[{"Transpose", "[", "testFeatures", "]"}], ",", "sizeSVD"}], "]"}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"distanceType", "==", "\"\\""}], ",", "\[IndentingNewLine]", RowBox[{"tempVector", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"Total", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"weightV", "[", RowBox[{"[", "i", "]"}], "]"}], " ", RowBox[{"Abs", "[", RowBox[{ RowBox[{"uAll", "[", RowBox[{"[", RowBox[{"k", ",", "All", ",", "i"}], "]"}], "]"}], ".", RowBox[{"uAllNew", "[", RowBox[{"[", RowBox[{"All", ",", "i"}], "]"}], "]"}]}], "]"}]}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"dimensions", "[", RowBox[{"[", "3", "]"}], "]"}]}], "}"}]}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"k", ",", "1", ",", RowBox[{"dimensions", "[", RowBox[{"[", "1", "]"}], "]"}]}], "}"}]}], "]"}]}]}], "]"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"distanceType", "==", "\"\\""}], ",", "\[IndentingNewLine]", RowBox[{"tempVector", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"em", "=", RowBox[{"Transpose", "[", RowBox[{"uAll", "[", RowBox[{"[", RowBox[{"k", ",", "All"}], "]"}], "]"}], "]"}]}], ";", RowBox[{"el", "=", RowBox[{"Transpose", "[", "uAllNew", "]"}]}], ";", RowBox[{"Tr", "[", RowBox[{"el", ".", RowBox[{"Transpose", "[", "em", "]"}], ".", RowBox[{"DiagonalMatrix", "[", RowBox[{"weightV", ".", "em", ".", RowBox[{"Transpose", "[", "el", "]"}]}], "]"}]}], "]"}]}], ",", RowBox[{"{", RowBox[{"k", ",", "1", ",", RowBox[{"dimensions", "[", RowBox[{"[", "1", "]"}], "]"}]}], "}"}]}], "]"}]}]}], "]"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"distanceType", "==", "\"\\""}], ",", "\[IndentingNewLine]", RowBox[{"tempVector", "=", RowBox[{"weightV", ".", RowBox[{"Table", "[", RowBox[{ RowBox[{"Max", "[", RowBox[{"Abs", "[", RowBox[{ RowBox[{"uAllNew", "[", RowBox[{"[", RowBox[{"All", ",", "i"}], "]"}], "]"}], ".", RowBox[{"uAll", "[", RowBox[{"[", RowBox[{"k", ",", "All", ",", "All"}], "]"}], "]"}]}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"dimensions", "[", RowBox[{"[", "3", "]"}], "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"k", ",", RowBox[{"dimensions", "[", RowBox[{"[", "1", "]"}], "]"}]}], "}"}]}], "]"}]}]}]}], "]"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"Position", "[", RowBox[{"tempVector", ",", RowBox[{"Max", "[", "tempVector", "]"}]}], "]"}]}], ",", RowBox[{"{", RowBox[{"m", ",", "1", ",", "numTests"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"result", "=", RowBox[{"Reverse", "[", RowBox[{"Sort", "[", RowBox[{ RowBox[{"Tally", "[", RowBox[{"Flatten", "[", "closestOnes", "]"}], "]"}], ",", RowBox[{ RowBox[{ RowBox[{"#1", "[", RowBox[{"[", "2", "]"}], "]"}], "<", RowBox[{"#2", "[", RowBox[{"[", "2", "]"}], "]"}]}], "&"}]}], "]"}], "]"}]}]}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"result", "[", RowBox[{"[", RowBox[{"j", ",", "1"}], "]"}], "]"}], "=", RowBox[{"images", "[", RowBox[{"[", RowBox[{"result", "[", RowBox[{"[", RowBox[{"j", ",", "1"}], "]"}], "]"}], "]"}], "]"}]}], ",", RowBox[{"{", RowBox[{"j", ",", RowBox[{ RowBox[{"Dimensions", "[", "result", "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}], "}"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"Return", "[", "result", "]"}]}]}], "]"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{ RowBox[{"simWI", "[", "allTest_", "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"qual", ",", "res", ",", "pw", ",", "distWI", ",", "numPics"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"numPics", "=", RowBox[{"Length", "[", "allTest", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"qual", "=", RowBox[{"Total", "[", RowBox[{"1.0", "/", RowBox[{"Flatten", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"res", "=", RowBox[{"First", "[", RowBox[{"Transpose", "[", RowBox[{"Select", "[", RowBox[{ RowBox[{"allTest", "[", RowBox[{"[", "i", "]"}], "]"}], ",", RowBox[{ RowBox[{ RowBox[{"#", "[", RowBox[{"[", "2", "]"}], "]"}], ">", "10"}], "&"}]}], "]"}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Position", "[", RowBox[{"res", ",", "i"}], "]"}]}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "numPics"}], "}"}]}], "]"}], "]"}]}], "]"}]}], ";", "\n", RowBox[{"distWI", "=", RowBox[{"ConstantArray", "[", RowBox[{"1", ",", RowBox[{"{", RowBox[{"numPics", ",", "numPics"}], "}"}]}], "]"}]}], ";", "\n", RowBox[{"Do", "[", RowBox[{ RowBox[{ RowBox[{"pw", "=", RowBox[{"prunedWisc", "[", RowBox[{"k", ",", "0.1", ",", "allTest"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Do", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"distWI", "[", RowBox[{"[", RowBox[{"k", ",", RowBox[{"pw", "[", RowBox[{"[", RowBox[{"j", ",", "1"}], "]"}], "]"}]}], "]"}], "]"}], "=", RowBox[{"1", "-", RowBox[{"N", "[", RowBox[{ RowBox[{"pw", "[", RowBox[{"[", RowBox[{"j", ",", "2"}], "]"}], "]"}], "/", RowBox[{"valWisc", "[", RowBox[{"k", ",", "allTest"}], "]"}]}], "]"}]}]}], ";"}], ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", RowBox[{"Length", "[", "pw", "]"}]}], "}"}]}], "]"}]}], ",", RowBox[{"{", RowBox[{"k", ",", "1", ",", "numPics"}], "}"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"Return", "[", "distWI", "]"}]}]}], "\[IndentingNewLine]", "]"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"valWisc", "[", RowBox[{"i_", ",", "allTest_"}], "]"}], ":=", RowBox[{"First", "[", RowBox[{"Last", "[", RowBox[{"Transpose", "[", RowBox[{"allTest", "[", RowBox[{"[", "i", "]"}], "]"}], "]"}], "]"}], "]"}]}], "\n"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"prunedWisc", "[", RowBox[{"i_", ",", "per_", ",", "allTest_"}], "]"}], ":=", RowBox[{"Select", "[", RowBox[{ RowBox[{"allTest", "[", RowBox[{"[", "i", "]"}], "]"}], ",", RowBox[{ RowBox[{ RowBox[{"#", "[", RowBox[{"[", "2", "]"}], "]"}], ">", RowBox[{"per", " ", RowBox[{"valWisc", "[", RowBox[{"i", ",", "allTest"}], "]"}]}]}], "&"}]}], "]"}]}]}], "Input", InitializationCell->True, CellChangeTimes->{{3.618840931259766*^9, 3.6188409318781853`*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["4. Optimized voting algorithm", "Section", CellChangeTimes->{{3.61884051627084*^9, 3.6188405251150985`*^9}}], Cell[TextData[{ "Function ", StyleBox["doClassification2[]", "Input"], " is used for computing the optimized voting algorithm and all the \ combinations of optimized voting algorithm with matrix similarities. One can \ needs to specify the type of algorithm (", "\[OpenCurlyDoubleQuote]EROS\[CloseCurlyDoubleQuote],\[CloseCurlyDoubleQuote]\ PCA\[CloseCurlyDoubleQuote],\[CloseCurlyDoubleQuote]COS\ \[CloseCurlyDoubleQuote],\[CloseCurlyDoubleQuote]SimWI\[CloseCurlyDoubleQuote]\ ", "), SVD matrices and path where to find the images, and also select the \ number of image that should be classified. It also requires the maximum \ number of iterations (Noted as \[OpenCurlyDoubleQuote]\[Phi]\ \[CloseCurlyDoubleQuote] in text), number of tests performed during the first \ iteration (noted as \[OpenCurlyDoubleQuote]P\[CloseCurlyDoubleQuote] in text) \ and decreasing factor (noted as \[OpenCurlyDoubleQuote]\[Alpha]\ \[CloseCurlyDoubleQuote] in text)\nFunction ", StyleBox["simWI2[]", "Input"], " can be used to calculate the ratio used as distance measure (noted as ", Cell[BoxData[ FormBox[ RowBox[{"\[OpenCurlyDoubleQuote]", SubscriptBox["r", "i"]}], TraditionalForm]], FormatType->"TraditionalForm"], "\[CloseCurlyDoubleQuote] in text) from the sorted counts obtained by ", StyleBox["doClassification2[]", "Input"], "." }], "Text", CellChangeTimes->{{3.6188405368824883`*^9, 3.6188406213164673`*^9}, { 3.618840725006158*^9, 3.618840866403674*^9}, 3.6188411000457196`*^9, { 3.6188411403313503`*^9, 3.618841172241*^9}, {3.618842315914796*^9, 3.618842317670065*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{ RowBox[{ RowBox[{"doClassification2", "[", RowBox[{ "distanceType_", ",", "uAll_", ",", "wAll_", ",", "path_", ",", "images_", ",", "thisClass_", ",", "maxIterations_", ",", "firstStep_", ",", "stepControl_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{ "allImages", ",", "thisImage", ",", "imgTest", ",", "testFeatures", ",", "imagesToTest", ",", "const", ",", "len", ",", "iter", ",", "final", ",", "temp2", ",", "a", ",", "sortedResult", ",", "step", ",", "norms", ",", "dimensions", ",", "el", ",", "em", ",", "uAllNew", ",", "wAllNew", ",", "v", ",", "weightV", ",", " ", "distClasses", ",", " ", "closestOnes", ",", "result"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"allImages", "=", RowBox[{ RowBox[{"LoadImageNames", "[", "path", "]"}], "[", RowBox[{"[", "images", "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"thisImage", "=", RowBox[{ RowBox[{"LoadImageNames", "[", "path", "]"}], "[", RowBox[{"[", "thisClass", "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"imagesToTest", "=", RowBox[{"Accumulate", "[", RowBox[{"ConstantArray", "[", RowBox[{"1", ",", RowBox[{"Length", "[", "images", "]"}]}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"len", "=", RowBox[{"Length", "[", "imagesToTest", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"dimensions", "=", RowBox[{"Dimensions", "[", "uAll", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"step", "=", "firstStep"}], ";", "\[IndentingNewLine]", RowBox[{"iter", "=", "1"}], ";", "\[IndentingNewLine]", RowBox[{"final", "=", RowBox[{"ConstantArray", "[", RowBox[{"0", ",", RowBox[{"{", RowBox[{ RowBox[{"Length", "[", "images", "]"}], ",", "3"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"final", "[", RowBox[{"[", RowBox[{"i", ",", "1"}], "]"}], "]"}], "=", "i"}], ";"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", RowBox[{"Length", "[", "images", "]"}]}], "}"}]}], "]"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"weightV", "=", RowBox[{"weightVector", "[", RowBox[{"wAll", ",", "dimensions"}], "]"}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"While", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"Length", "[", "imagesToTest", "]"}], ">", RowBox[{"Round", "[", RowBox[{"len", "/", "10"}], "]"}]}], " ", "&&", " ", RowBox[{"iter", "<", "maxIterations"}], " ", "&&", " ", RowBox[{"step", ">", "9"}]}], ",", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{"distanceType", "\[Equal]", "\"\\""}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"imgTest", "=", RowBox[{"Flatten", "[", RowBox[{"readFunOne", "[", RowBox[{"thisImage", ",", "step", ",", RowBox[{"{", RowBox[{"patchSize", ",", "patchSize"}], "}"}]}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"testFeatures", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"buildFeatures", "[", RowBox[{"imgTest", "[", RowBox[{"[", "k", "]"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"k", ",", "1", ",", "step"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"norms", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"Norm", "[", RowBox[{ RowBox[{"testFeatures", "[", RowBox[{"[", "i", "]"}], "]"}], "-", RowBox[{ RowBox[{"uAll", "[", RowBox[{"[", "j", "]"}], "]"}], ".", RowBox[{"(", RowBox[{ RowBox[{"Transpose", "[", RowBox[{"uAll", "[", RowBox[{"[", "j", "]"}], "]"}], "]"}], ".", RowBox[{"testFeatures", "[", RowBox[{"[", "i", "]"}], "]"}]}], ")"}]}]}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "step"}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", "imagesToTest"}], "}"}]}], "]"}]}], ";"}], ",", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{ RowBox[{"norms", "=", RowBox[{"Table", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"imgTest", "=", RowBox[{"Flatten", "[", RowBox[{"readFunOne", "[", RowBox[{"thisImage", ",", "step", ",", RowBox[{"{", RowBox[{"patchSize", ",", "patchSize"}], "}"}]}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"testFeatures", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"buildFeatures", "[", RowBox[{"imgTest", "[", RowBox[{"[", "j", "]"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", " ", "step"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{ RowBox[{"{", RowBox[{"uAllNew", ",", "wAllNew", ",", "v"}], "}"}], "=", RowBox[{"SingularValueDecomposition", "[", RowBox[{ RowBox[{"Transpose", "[", "testFeatures", "]"}], ",", "sizeSVD"}], "]"}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{"distanceType", "\[Equal]", "\"\\""}], ",", "\[IndentingNewLine]", RowBox[{"Table", "[", RowBox[{ RowBox[{"Total", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"weightV", "[", RowBox[{"[", "i", "]"}], "]"}], " ", RowBox[{"Abs", "[", RowBox[{ RowBox[{"uAll", "[", RowBox[{"[", RowBox[{"k", ",", "All", ",", "i"}], "]"}], "]"}], ".", RowBox[{"uAllNew", "[", RowBox[{"[", RowBox[{"All", ",", "i"}], "]"}], "]"}]}], "]"}]}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"dimensions", "[", RowBox[{"[", "3", "]"}], "]"}]}], "}"}]}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"k", ",", "imagesToTest"}], "}"}]}], "]"}], ",", "\[IndentingNewLine]", ","}], "]"}], "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"distanceType", "\[Equal]", "\"\\""}], ",", "\[IndentingNewLine]", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"em", "=", RowBox[{"Transpose", "[", RowBox[{"uAll", "[", RowBox[{"[", RowBox[{"i", ",", "All"}], "]"}], "]"}], "]"}]}], ";", RowBox[{"el", "=", RowBox[{"Transpose", "[", "uAllNew", "]"}]}], ";", RowBox[{"Tr", "[", RowBox[{"el", ".", RowBox[{"Transpose", "[", "em", "]"}], ".", RowBox[{"DiagonalMatrix", "[", RowBox[{"weightV", ".", "em", ".", RowBox[{"Transpose", "[", "el", "]"}]}], "]"}]}], "]"}]}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "len"}], "}"}]}], "]"}], ",", "\[IndentingNewLine]", ","}], "]"}], "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"distanceType", "\[Equal]", "\"\\""}], ",", "\[IndentingNewLine]", RowBox[{"weightV", ".", RowBox[{"Table", "[", RowBox[{ RowBox[{"Max", "[", RowBox[{"Abs", "[", RowBox[{ RowBox[{"uAllNew", "[", RowBox[{"[", RowBox[{"All", ",", "i"}], "]"}], "]"}], ".", RowBox[{"uAll", "[", RowBox[{"[", RowBox[{"k", ",", "All", ",", "All"}], "]"}], "]"}]}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"dimensions", "[", RowBox[{"[", "3", "]"}], "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"k", ",", "len"}], "}"}]}], "]"}]}], ",", "\[IndentingNewLine]", ","}], "]"}]}]}], "\[IndentingNewLine]", ",", RowBox[{"{", RowBox[{"m", ",", "1", ",", "step"}], "}"}]}], "]"}]}], ";"}]}], "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"distClasses", "=", RowBox[{"ConstantArray", "[", RowBox[{"1", ",", RowBox[{"{", RowBox[{"step", ",", "len"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"a", "=", "1"}], ";", "\[IndentingNewLine]", RowBox[{"Table", "[", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"MemberQ", "[", RowBox[{"imagesToTest", ",", "m"}], "]"}], "\[Equal]", "True"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{ RowBox[{"distClasses", "[", RowBox[{"[", "n", "]"}], "]"}], "[", RowBox[{"[", "m", "]"}], "]"}], "=", RowBox[{ RowBox[{"norms", "[", RowBox[{"[", "n", "]"}], "]"}], "[", RowBox[{"[", "a", "]"}], "]"}]}], ";", RowBox[{"a", "=", RowBox[{"a", "+", "1"}]}], ";"}], ","}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{"m", ",", "1", ",", "len"}], "}"}]}], "]"}], ";"}], "\[IndentingNewLine]", ",", RowBox[{"{", RowBox[{"n", ",", "1", ",", "step"}], "}"}]}], "]"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"distanceType", "\[Equal]", "\"\\""}], ",", RowBox[{ RowBox[{"closestOnes", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"Ordering", "[", RowBox[{"distClasses", "[", RowBox[{"[", "l", "]"}], "]"}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}], ",", RowBox[{"{", RowBox[{"l", ",", "1", ",", "step"}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", ",", RowBox[{ RowBox[{"closestOnes", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"Ordering", "[", RowBox[{"distClasses", "[", RowBox[{"[", "l", "]"}], "]"}], "]"}], "[", RowBox[{"[", RowBox[{"dimensions", "[", RowBox[{"[", "1", "]"}], "]"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"l", ",", "1", ",", "step"}], "}"}]}], "]"}]}], ";"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"result", "=", RowBox[{"Reverse", "[", RowBox[{"Sort", "[", RowBox[{ RowBox[{"Tally", "[", "closestOnes", "]"}], ",", RowBox[{ RowBox[{ RowBox[{"#1", "[", RowBox[{"[", "2", "]"}], "]"}], "<", RowBox[{"#2", "[", RowBox[{"[", "2", "]"}], "]"}]}], "&"}]}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"sortedResult", "=", RowBox[{"Sort", "[", "result", "]"}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"temp2", "=", RowBox[{"ConstantArray", "[", RowBox[{"0", ",", "len"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"a", "=", "1"}], ";", "\[IndentingNewLine]", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"temp2", "[", RowBox[{"[", "i", "]"}], "]"}], "=", RowBox[{"sortedResult", "[", RowBox[{"[", RowBox[{"a", ",", "2"}], "]"}], "]"}]}], ";", " ", RowBox[{"a", "=", RowBox[{"a", "+", "1"}]}], ";"}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"sortedResult", "[", RowBox[{"[", RowBox[{"All", ",", "1"}], "]"}], "]"}]}], "}"}]}], "]"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{ RowBox[{"final", "[", RowBox[{"[", RowBox[{"All", ",", "2"}], "]"}], "]"}], "=", RowBox[{ RowBox[{"final", "[", RowBox[{"[", RowBox[{"All", ",", "2"}], "]"}], "]"}], "+", "temp2"}]}], ";", "\[IndentingNewLine]", RowBox[{"Table", "[", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"temp2", "[", RowBox[{"[", "i", "]"}], "]"}], "\[Equal]", "0"}], ",", ",", RowBox[{ RowBox[{ RowBox[{"final", "[", RowBox[{"[", RowBox[{"i", ",", "3"}], "]"}], "]"}], "=", RowBox[{ RowBox[{"final", "[", RowBox[{"[", RowBox[{"i", ",", "3"}], "]"}], "]"}], "+", "step"}]}], ";"}]}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "len"}], "}"}]}], "]"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{"imagesToTest", "=", RowBox[{"sortedResult", "[", RowBox[{"[", RowBox[{"All", ",", "1"}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"iter", "=", RowBox[{"iter", "+", "1"}]}], ";", "\[IndentingNewLine]", RowBox[{"step", "=", RowBox[{"Round", "[", RowBox[{"step", " ", "stepControl"}], "]"}]}], ";"}]}], "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", RowBox[{"Table", "[", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"final", "[", RowBox[{"[", RowBox[{"i", ",", "2"}], "]"}], "]"}], "\[Equal]", "0"}], ",", RowBox[{ RowBox[{ RowBox[{"final", "[", RowBox[{"[", RowBox[{"i", ",", "3"}], "]"}], "]"}], "=", "firstStep"}], ";"}], ","}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "len"}], "}"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"Reverse", "[", RowBox[{"Sort", "[", RowBox[{"final", ",", RowBox[{ RowBox[{ RowBox[{"#1", "[", RowBox[{"[", "2", "]"}], "]"}], "<", RowBox[{"#2", "[", RowBox[{"[", "2", "]"}], "]"}]}], "&"}]}], "]"}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"final", "[", RowBox[{"[", RowBox[{"j", ",", "1"}], "]"}], "]"}], "=", RowBox[{"images", "[", RowBox[{"[", RowBox[{"final", "[", RowBox[{"[", RowBox[{"j", ",", "1"}], "]"}], "]"}], "]"}], "]"}]}], ",", RowBox[{"{", RowBox[{"j", ",", RowBox[{ RowBox[{"Dimensions", "[", "final", "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}], "}"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"Return", "[", "final", "]"}]}]}], "\[IndentingNewLine]", "]"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"simWI2", "[", RowBox[{"allTest2_", ",", "numPics_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"scaled", ",", "sorted", ",", "distMat", ",", "ratio"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"scaled", "=", RowBox[{"ConstantArray", "[", RowBox[{"0", ",", RowBox[{"{", RowBox[{"numPics", ",", "numPics", ",", "3"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"sorted", "=", RowBox[{"ConstantArray", "[", RowBox[{"0", ",", RowBox[{"{", RowBox[{"numPics", ",", "numPics", ",", "3"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"distMat", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"sorted", "[", RowBox[{"[", "i", "]"}], "]"}], "=", RowBox[{"Sort", "[", RowBox[{"allTest2", "[", RowBox[{"[", "i", "]"}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"ratio", "=", RowBox[{ RowBox[{"sorted", "[", RowBox[{"[", RowBox[{"i", ",", "All", ",", "2"}], "]"}], "]"}], "/", RowBox[{"sorted", "[", RowBox[{"[", RowBox[{"i", ",", "All", ",", "3"}], "]"}], "]"}]}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"scaled", "[", RowBox[{"[", "i", "]"}], "]"}], "=", RowBox[{"ratio", "*", RowBox[{"(", RowBox[{ RowBox[{"Max", "[", "ratio", "]"}], "^", RowBox[{"-", "1"}]}], ")"}]}]}]}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "numPics"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Return", "[", RowBox[{"N", "[", "distMat", "]"}], "]"}]}]}], "\[IndentingNewLine]", "]"}]}]}], "Input", InitializationCell->True, CellChangeTimes->{{3.618841187254697*^9, 3.618841199387292*^9}}], Cell[CellGroupData[{ Cell["\<\ Analyzing parameters of the optimized voting algorithm\ \>", "Subsection", CellChangeTimes->{{3.6188414805711527`*^9, 3.6188415058130646`*^9}}], Cell[TextData[{ "Functions for computing the probability of correct match ", Cell[BoxData[ FormBox[ SubscriptBox["p", "j"], TraditionalForm]], FormatType->"TraditionalForm"], " tailored to data set consisting of blocks of 10 images from same or very \ similar paper." }], "Text", CellChangeTimes->{{3.618841769053172*^9, 3.618841818488282*^9}, { 3.618841872382579*^9, 3.618841951339693*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{"group1", "=", RowBox[{"Table", "[", RowBox[{"i", ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "10"}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"group2", "=", RowBox[{"Table", "[", RowBox[{"i", ",", RowBox[{"{", RowBox[{"i", ",", "11", ",", "20"}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"group3", "=", RowBox[{"Table", "[", RowBox[{"i", ",", RowBox[{"{", RowBox[{"i", ",", "21", ",", "30"}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"group4", "=", RowBox[{"Table", "[", RowBox[{"i", ",", RowBox[{"{", RowBox[{"i", ",", "31", ",", "40"}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"group5", "=", RowBox[{"Table", "[", RowBox[{"i", ",", RowBox[{"{", RowBox[{"i", ",", "41", ",", "50"}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"group6", "=", RowBox[{"Table", "[", RowBox[{"i", ",", RowBox[{"{", RowBox[{"i", ",", "51", ",", "60"}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"group7", "=", RowBox[{"Table", "[", RowBox[{"i", ",", RowBox[{"{", RowBox[{"i", ",", "61", ",", "70"}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"group8", "=", RowBox[{"Table", "[", RowBox[{"i", ",", RowBox[{"{", RowBox[{"i", ",", "71", ",", "80"}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"group9", "=", RowBox[{"Table", "[", RowBox[{"i", ",", RowBox[{"{", RowBox[{"i", ",", "81", ",", "90"}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"group10", "=", RowBox[{"Table", "[", RowBox[{"i", ",", RowBox[{"{", RowBox[{"i", ",", "91", ",", "120"}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"findCorrectGroup", "[", RowBox[{"temp_", ",", "thisClass_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "correctGroup", "}"}], ",", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"MemberQ", "[", RowBox[{"group1", ",", "thisClass"}], "]"}], "\[Equal]", "False"}], ",", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"MemberQ", "[", RowBox[{"group2", ",", "thisClass"}], "]"}], "\[Equal]", "False"}], ",", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"MemberQ", "[", RowBox[{"group3", ",", "thisClass"}], "]"}], "\[Equal]", "False"}], ",", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"MemberQ", "[", RowBox[{"group4", ",", "thisClass"}], "]"}], "\[Equal]", "False"}], ",", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"MemberQ", "[", RowBox[{"group5", ",", "thisClass"}], "]"}], "\[Equal]", "False"}], ",", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"MemberQ", "[", RowBox[{"group6", ",", "thisClass"}], "]"}], "\[Equal]", "False"}], ",", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"MemberQ", "[", RowBox[{"group7", ",", "thisClass"}], "]"}], "\[Equal]", "False"}], ",", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"MemberQ", "[", RowBox[{"group8", ",", "thisClass"}], "]"}], "\[Equal]", "False"}], ",", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"MemberQ", "[", RowBox[{"group9", ",", "thisClass"}], "]"}], "\[Equal]", "False"}], ",", RowBox[{"correctGroup", "=", "group10"}], "\[IndentingNewLine]", ",", RowBox[{"correctGroup", "=", "group9"}]}], "]"}], ",", RowBox[{"correctGroup", "=", "group8"}]}], "]"}], ",", RowBox[{"correctGroup", "=", "group7"}]}], "]"}], ",", RowBox[{"correctGroup", "=", "group6"}]}], "]"}], ",", RowBox[{"correctGroup", "=", "group5"}]}], "]"}], ",", RowBox[{"correctGroup", "=", "group4"}]}], "]"}], ",", RowBox[{"correctGroup", "=", "group3"}]}], "]"}], ",", RowBox[{"correctGroup", "=", "group2"}]}], "]"}], ",", RowBox[{"correctGroup", "=", "group1"}]}], "]"}]}], "]"}]}], "\n"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"findScore", "[", RowBox[{"temp_", ",", "thisClass_", ",", "testsForOne_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"score", ",", "newScore", ",", "correctGroup"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"correctGroup", "=", RowBox[{"findCorrectGroup", "[", RowBox[{"temp", ",", "thisClass"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"score", "=", RowBox[{"{", "}"}]}], ";", "\[IndentingNewLine]", RowBox[{"newScore", "=", RowBox[{"Total", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"MemberQ", "[", RowBox[{"correctGroup", ",", RowBox[{"temp", "[", RowBox[{"[", RowBox[{"i", ",", "1"}], "]"}], "]"}]}], "]"}], "\[Equal]", "True"}], ",", RowBox[{"Append", "[", RowBox[{"score", ",", RowBox[{"temp", "[", RowBox[{"[", RowBox[{"i", ",", "2"}], "]"}], "]"}]}], "]"}], ",", RowBox[{"Append", "[", RowBox[{"score", ",", "0"}], "]"}]}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{"Length", "[", "temp", "]"}]}], "}"}]}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"N", "[", RowBox[{"newScore", "/", "testsForOne"}], "]"}]}]}], "]"}]}]}], "Input", InitializationCell->True, CellChangeTimes->{{3.607643070074007*^9, 3.607643087611396*^9}, { 3.607643558924341*^9, 3.607643612399111*^9}, {3.607643865660022*^9, 3.6076438668708725`*^9}, {3.6078108938396544`*^9, 3.607810895440782*^9}, { 3.607811532732971*^9, 3.6078115389173403`*^9}, {3.6078522587334385`*^9, 3.607852269782243*^9}, {3.607853116101102*^9, 3.6078531512459307`*^9}, { 3.6079755539726667`*^9, 3.607975573066146*^9}, {3.617446465401986*^9, 3.6174465379442606`*^9}, {3.6174489661265917`*^9, 3.6174489665669036`*^9}, { 3.6174623243818865`*^9, 3.6174623249452844`*^9}, {3.617470240847297*^9, 3.617470247519*^9}, {3.617627511262735*^9, 3.6176275341789327`*^9}}], Cell[TextData[{ "Following code was used to analyse the dependance of ", Cell[BoxData[ FormBox[ SubscriptBox["p", "j"], TraditionalForm]], FormatType->"TraditionalForm"], " on size of dictionary M. The only input parameters (besides the data set) \ are describing number of classifications used on each image (", StyleBox["testsForOne", "Input"], ") and number of images tested. Depending on the input parameters, this \ calculation will take hours." }], "Text", CellChangeTimes->{{3.6188415649380836`*^9, 3.6188415864423943`*^9}, { 3.6188416763012543`*^9, 3.6188417227192435`*^9}, {3.61884201512403*^9, 3.618842038522659*^9}, {3.618842093883997*^9, 3.618842148602912*^9}, { 3.618843000190094*^9, 3.6188430238208995`*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{"SetDirectory", "[", RowBox[{"NotebookDirectory", "[", "]"}], "]"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"{", RowBox[{"uAll", ",", "wAll"}], "}"}], "=", RowBox[{"loadSVDs", "[", "]"}]}], ";"}]}], "Input", CellChangeTimes->{{3.6176192995813866`*^9, 3.617619305271406*^9}, { 3.6188419855039797`*^9, 3.6188420026962185`*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{"testsForOne", "=", "30"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"imagesTested", "=", "30"}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"scores", "=", RowBox[{"ConstantArray", "[", RowBox[{"0", ",", RowBox[{"Length", "[", "poolSize", "]"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"index", "=", "0"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"poolSize", "=", RowBox[{"{", RowBox[{ "20", ",", "30", ",", "40", ",", "50", ",", "60", ",", "70", ",", "80", ",", "90", ",", "100", ",", "110", ",", "120"}], "}"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"allPics", "=", RowBox[{"LoadImageNames", "[", "path", "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"numPics", "=", RowBox[{"Length", "[", "allPics", "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"dimensions", "=", RowBox[{"Dimensions", "[", "uAll", "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Table", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"var", "=", RowBox[{"ConstantArray", "[", RowBox[{"0", ",", RowBox[{"{", RowBox[{"testsForOne", ",", "imagesTested"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"temp", "=", RowBox[{"ConstantArray", "[", RowBox[{"0", ",", RowBox[{"{", RowBox[{"imagesTested", ",", "testsForOne"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"temp2", "=", RowBox[{"ConstantArray", "[", RowBox[{"0", ",", RowBox[{"{", RowBox[{"imagesTested", ",", "testsForOne"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"class", "=", RowBox[{"ConstantArray", "[", RowBox[{"0", ",", "imagesTested"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"res", "=", RowBox[{"ConstantArray", "[", RowBox[{"0", ",", RowBox[{"{", RowBox[{"imagesTested", ",", "testsForOne"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"res2", "=", RowBox[{"ConstantArray", "[", RowBox[{"0", ",", "imagesTested"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"var", "[", RowBox[{"[", "i", "]"}], "]"}], "=", RowBox[{"RandomInteger", "[", RowBox[{ RowBox[{"{", RowBox[{"1", ",", "120"}], "}"}], ",", "l"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"uAll2", "=", RowBox[{"uAll", "[", RowBox[{"[", RowBox[{"var", "[", RowBox[{"[", "i", "]"}], "]"}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"wAll2", "=", RowBox[{"wAll", "[", RowBox[{"[", RowBox[{"var", "[", RowBox[{"[", "i", "]"}], "]"}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"class", "[", RowBox[{"[", "i", "]"}], "]"}], "=", RowBox[{"RandomChoice", "[", RowBox[{"Select", "[", RowBox[{ RowBox[{"var", "[", RowBox[{"[", "i", "]"}], "]"}], ",", RowBox[{ RowBox[{"#", "<=", "90"}], "&"}]}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Table", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{ RowBox[{"temp", "[", RowBox[{"[", RowBox[{"i", ",", "k"}], "]"}], "]"}], "=", RowBox[{"doClassification", "[", RowBox[{ "\"\\"", ",", "uAll2", ",", "wAll2", ",", "path", ",", RowBox[{"var", "[", RowBox[{"[", "i", "]"}], "]"}], ",", RowBox[{"class", "[", RowBox[{"[", "i", "]"}], "]"}], ",", "2000"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"temp2", "[", RowBox[{"[", RowBox[{"i", ",", "k"}], "]"}], "]"}], "=", RowBox[{"1", "-", RowBox[{ RowBox[{"simWI", "[", RowBox[{"ConstantArray", "[", RowBox[{ RowBox[{"temp", "[", RowBox[{"[", RowBox[{"i", ",", "k"}], "]"}], "]"}], ",", "120"}], "]"}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"res", "[", RowBox[{"[", RowBox[{"i", ",", "k"}], "]"}], "]"}], "=", RowBox[{"Position", "[", RowBox[{ RowBox[{"temp2", "[", RowBox[{"[", RowBox[{"i", ",", "k"}], "]"}], "]"}], ",", RowBox[{"Max", "[", RowBox[{"temp2", "[", RowBox[{"[", RowBox[{"i", ",", "k"}], "]"}], "]"}], "]"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", ",", RowBox[{"{", RowBox[{"k", ",", "1", ",", "testsForOne"}], "}"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"res2", "[", RowBox[{"[", "i", "]"}], "]"}], "=", RowBox[{"Reverse", "[", RowBox[{"Sort", "[", RowBox[{ RowBox[{"Tally", "[", RowBox[{"Flatten", "[", RowBox[{ RowBox[{"res", "[", RowBox[{"[", RowBox[{"i", ",", "All", ",", "1"}], "]"}], "]"}], ",", "1"}], "]"}], "]"}], ",", RowBox[{ RowBox[{ RowBox[{"#1", "[", RowBox[{"[", "2", "]"}], "]"}], "<", RowBox[{"#2", "[", RowBox[{"[", "2", "]"}], "]"}]}], "&"}]}], "]"}], "]"}]}], ";"}], "\[IndentingNewLine]", ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "imagesTested"}], "}"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"index", "=", RowBox[{"index", "+", "1"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"scores", "[", RowBox[{"[", "index", "]"}], "]"}], "=", RowBox[{"Mean", "[", RowBox[{"Flatten", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{"findScore", "[", RowBox[{ RowBox[{"res2", "[", RowBox[{"[", "i", "]"}], "]"}], ",", RowBox[{"class", "[", RowBox[{"[", "i", "]"}], "]"}], ",", "testsForOne"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "imagesTested"}], "}"}]}], "]"}], "]"}], "]"}]}], ";"}], "\[IndentingNewLine]", ",", RowBox[{"{", RowBox[{"l", ",", "poolSize"}], "}"}]}], "]"}], ";"}], "\[IndentingNewLine]", RowBox[{"Grid", "[", RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{"k", "==", "1"}], ",", RowBox[{"{", RowBox[{"\"\\"", ",", "\"\\""}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"poolSize", "[", RowBox[{"[", RowBox[{"k", "-", "1"}], "]"}], "]"}], ",", RowBox[{"scores", "[", RowBox[{"[", RowBox[{"k", "-", "1"}], "]"}], "]"}]}], "}"}]}], "]"}], ",", RowBox[{"{", RowBox[{"k", ",", "1", ",", RowBox[{ RowBox[{"Length", "[", "poolSize", "]"}], "+", "1"}]}], "}"}]}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"Alignment", "\[Rule]", RowBox[{"{", RowBox[{"Center", ",", RowBox[{"{", RowBox[{"Bottom", ",", "Top"}], "}"}]}], "}"}]}], ",", RowBox[{"Frame", "\[Rule]", "All"}], ",", RowBox[{"Spacings", "\[Rule]", RowBox[{"{", RowBox[{"2", ",", "1"}], "}"}]}]}], "]"}], "\[IndentingNewLine]"}], "Input", CellChangeTimes->{{3.6176187880387344`*^9, 3.6176187940829887`*^9}, { 3.6176188358355136`*^9, 3.6176189111627464`*^9}, {3.6176189616254263`*^9, 3.617619012785589*^9}, {3.617619053040042*^9, 3.6176190855730352`*^9}, { 3.617619127291531*^9, 3.6176192443052225`*^9}, {3.617619317941959*^9, 3.617619329846386*^9}, {3.61761951469427*^9, 3.617619560275491*^9}, { 3.617620223743205*^9, 3.617620229266111*^9}, {3.617620361360465*^9, 3.617620416734623*^9}, {3.6176279603761797`*^9, 3.6176280407850156`*^9}, { 3.617628070892297*^9, 3.6176281144600925`*^9}, {3.6176282742280273`*^9, 3.6176282834054966`*^9}, {3.6176283433618937`*^9, 3.6176284037926035`*^9}, {3.617628448115048*^9, 3.6176284559996214`*^9}, { 3.617628543116645*^9, 3.6176285542334843`*^9}, {3.617628590575184*^9, 3.617628607546179*^9}, {3.617628676242737*^9, 3.6176286966141357`*^9}, { 3.61762875281686*^9, 3.617628789074503*^9}, {3.617633139814762*^9, 3.617633254313689*^9}, {3.6176332881265774`*^9, 3.6176332979855647`*^9}, { 3.617633332936263*^9, 3.6176333340230308`*^9}, {3.617640099521121*^9, 3.6176401252403*^9}, 3.617642183604622*^9, {3.6176427254522943`*^9, 3.617642728360352*^9}, {3.6176427860991616`*^9, 3.6176428199120674`*^9}, { 3.61764293340629*^9, 3.6176429908849*^9}, {3.6176432125335827`*^9, 3.617643349927684*^9}, {3.6176434504717703`*^9, 3.617643450592857*^9}, { 3.617643527817441*^9, 3.6176435362494*^9}, {3.6176435708658695`*^9, 3.617643583346674*^9}, {3.617643644906186*^9, 3.617643691569187*^9}, { 3.6176437315164227`*^9, 3.6176438793198957`*^9}, {3.61764392309482*^9, 3.6176439888723316`*^9}, {3.6176444555889635`*^9, 3.61764447758753*^9}, { 3.617645036088295*^9, 3.6176451000174823`*^9}, {3.617645239072777*^9, 3.6176452406278763`*^9}, {3.6176454123072257`*^9, 3.6176454487879944`*^9}, {3.6176458116289263`*^9, 3.6176458255717983`*^9}, {3.6176460111561127`*^9, 3.617646014778681*^9}, { 3.6176468438377724`*^9, 3.6176470239881105`*^9}, {3.6176473706222897`*^9, 3.617647388936236*^9}, {3.6176480485264564`*^9, 3.6176480963422537`*^9}, { 3.6176482772951293`*^9, 3.617648297089121*^9}, {3.6176485424025173`*^9, 3.61764857821383*^9}, 3.617650472469462*^9, {3.6176520776865764`*^9, 3.6176520787263193`*^9}, {3.617653346779473*^9, 3.6176533531109486`*^9}, { 3.618052017830921*^9, 3.618052018196179*^9}, {3.618841605697057*^9, 3.6188416130342646`*^9}, {3.618841988175877*^9, 3.6188420005836973`*^9}}] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["\<\ 5. Actual computation and results\ \>", "Section", CellChangeTimes->{{3.618841231970476*^9, 3.6188412619788027`*^9}}], Cell[CellGroupData[{ Cell["\<\ Vizualization of all similarity matrices\ \>", "Subsection", CellChangeTimes->{{3.6188454069155197`*^9, 3.6188454204111056`*^9}}], Cell[TextData[{ "We need to import the images and compute corresponding SVD matrices. But \ first, there are some important input parameters to consider:", StyleBox["\nnumPatches", "Input"], " is how many patches to draw randomly from each picture. Noted as \ \[OpenCurlyDoubleQuote]N\[CloseCurlyDoubleQuote] in the text of the thesis. \ Suggested value = 3000, use 500 for faster computation.\n", StyleBox["patchSize", "Input"], " defines the height (and width) of the square patches. Noted as \ \[OpenCurlyDoubleQuote]p\[CloseCurlyDoubleQuote] in text Suggested value = \ 25, use 15 for faster computation.\n", StyleBox["sizeSVD", "Input"], " defines, how many columns from calculated SVD matrix will be take into \ account. Noted as ", Cell[BoxData[ FormBox[ RowBox[{"\[OpenCurlyDoubleQuote]", SubscriptBox["n", "u"]}], TraditionalForm]]], "\[CloseCurlyDoubleQuote] in text. Suggested value = 30, use 10 for faster \ computation.\n", StyleBox["path", "Input"], " is the absolute path to folder where images are stored." }], "Text", CellChangeTimes->{{3.618841284690916*^9, 3.618841341879571*^9}, { 3.61884218822405*^9, 3.6188422479575014`*^9}, {3.6188504443655753`*^9, 3.618850470535174*^9}, {3.618850901922727*^9, 3.618851043177142*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{"sizeSVD", "=", "10"}], ";"}], "\n", RowBox[{ RowBox[{"numPatches", "=", "500"}], ";"}], "\n", RowBox[{ RowBox[{"patchSize", "=", "15"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"path", "=", "\"\\""}], ";"}]}], "Input", InitializationCell->True, CellChangeTimes->{3.6188510635736136`*^9}], Cell[TextData[{ "Importing the images and calculating all their SVD matrices denoted as uAll \ and wAll ", Cell[BoxData[ FormBox[ RowBox[{"(", SubscriptBox["U", "j"]}], TraditionalForm]]], " and \[CapitalSigma]) (depending on the input data, it might take a while \ to compute):" }], "Text", CellChangeTimes->{3.6188507819655037`*^9}], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"{", RowBox[{"uAll", ",", "wAll"}], "}"}], "=", RowBox[{"SVDsofAllImages", "[", RowBox[{"path", ",", "sizeSVD", ",", "numPatches", ",", "patchSize"}], "]"}]}], ";"}]], "Input", CellChangeTimes->{3.618850810545814*^9}], Cell["\<\ Since the images are not changing, it certainly is worth it to export the \ calculated SVD\[CloseCurlyQuote]s once, and then just import the values \ instead of doing the whole computation again. If the input parameters of the \ SVD change, it is necessary to recompute it.\ \>", "Text", CellChangeTimes->{{3.618850795224905*^9, 3.6188508192659826`*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{"Export", "[", RowBox[{"\"\\"", ",", "uAll"}], "]"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Export", "[", RowBox[{"\"\\"", ",", "wAll"}], "]"}], ";"}]}], "Input", CellChangeTimes->{3.618850828021233*^9}], Cell["Importing back from the files:", "Text", CellChangeTimes->{{3.618850839659477*^9, 3.618850842252325*^9}}], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"{", RowBox[{"uAll", ",", "wAll"}], "}"}], "=", RowBox[{"loadSVDs", "[", RowBox[{"\"\\"", ",", "\"\\""}], "]"}]}], ";"}]], "Input", CellChangeTimes->{{3.6188508930314083`*^9, 3.61885089354478*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{"allPics", "=", RowBox[{"LoadImageNames", "[", "path", "]"}]}], ";"}], "\n", RowBox[{ RowBox[{"numPics", "=", RowBox[{"Length", "[", "allPics", "]"}]}], ";"}]}], "Input", InitializationCell->True], Cell["\<\ For comparison, here are visualized similarity matrices computed using usual \ matrix distances:\ \>", "Text", CellChangeTimes->{{3.6188426697892838`*^9, 3.6188427113728423`*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{ RowBox[{"{", RowBox[{"dMinkowski", ",", "dASM", ",", "dYang"}], "}"}], "=", RowBox[{"calculateUsualDistances", "[", "uAll", "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{"drawUsualDistances", "[", RowBox[{"dMinkowski", ",", "dASM", ",", "dYang"}], "]"}]}], "Input", CellChangeTimes->{{3.6188427542913446`*^9, 3.618842773549051*^9}, { 3.61884287304276*^9, 3.618842876837435*^9}, 3.6188460459896936`*^9, { 3.618846174500028*^9, 3.6188461762492676`*^9}}], Cell["\<\ Visualized similarity matrices for the distance similarities, and the minimum \ value in each matrix serves for context. Depending on the input SVD \ parameters, this will take several minutes.\ \>", "Text", CellChangeTimes->{{3.61884278671939*^9, 3.618842813840664*^9}, { 3.618843074147682*^9, 3.618843098619073*^9}, {3.6188455412489834`*^9, 3.618845563548832*^9}, 3.6188501731788273`*^9}], Cell[BoxData[{ RowBox[{ RowBox[{ RowBox[{"{", RowBox[{"dEROS", ",", "dPCA", ",", "dCOS"}], "}"}], "=", RowBox[{"calculateDistances", "[", RowBox[{"uAll", ",", "wAll"}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{"drawDistances", "[", RowBox[{"dEROS", ",", "dPCA", ",", "dCOS"}], "]"}]}], "Input", CellChangeTimes->{{3.6188428276524734`*^9, 3.6188428938685613`*^9}}], Cell["\<\ Calculating and visualizing all the voting algorithms will take quite a while \ (probably several hours, depending on input parameters). It might be a good \ idea to export the results in case they are needed later.\ \>", "Text", CellChangeTimes->{{3.618842929233694*^9, 3.6188429876792088`*^9}, { 3.618843218740422*^9, 3.618843307518507*^9}, {3.618845570708927*^9, 3.61884557681126*^9}, {3.618850263565067*^9, 3.6188502922584753`*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{"dVote", "=", RowBox[{"1", "-", RowBox[{"simWI", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{"doClassification", "[", RowBox[{"\"\\"", ",", "uAll", ",", "wAll", ",", "path", ",", RowBox[{"Accumulate", "[", RowBox[{"ConstantArray", "[", RowBox[{"1", ",", "120"}], "]"}], "]"}], ",", "i", ",", "1000"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "120"}], "}"}]}], "]"}], "]"}]}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"dVoteEROS", "=", RowBox[{"1", "-", RowBox[{"simWI", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{"doClassification", "[", RowBox[{"\"\\"", ",", "uAll", ",", "wAll", ",", "path", ",", RowBox[{"Accumulate", "[", RowBox[{"ConstantArray", "[", RowBox[{"1", ",", "120"}], "]"}], "]"}], ",", "i", ",", "200"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "120"}], "}"}]}], "]"}], "]"}]}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"dVotePCA", "=", RowBox[{"1", "-", RowBox[{"simWI", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{"doClassification", "[", RowBox[{"\"\\"", ",", "uAll", ",", "wAll", ",", "path", ",", RowBox[{"Accumulate", "[", RowBox[{"ConstantArray", "[", RowBox[{"1", ",", "120"}], "]"}], "]"}], ",", "i", ",", "200"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "120"}], "}"}]}], "]"}], "]"}]}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"dVoteCOS", "=", RowBox[{"1", "-", RowBox[{"simWI", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{"doClassification", "[", RowBox[{"\"\\"", ",", "uAll", ",", "wAll", ",", "path", ",", RowBox[{"Accumulate", "[", RowBox[{"ConstantArray", "[", RowBox[{"1", ",", "120"}], "]"}], "]"}], ",", "i", ",", "200"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "120"}], "}"}]}], "]"}], "]"}]}]}], ";"}]}], "Input", CellChangeTimes->{{3.618843182649765*^9, 3.6188432065777984`*^9}, { 3.618843324329481*^9, 3.6188434110831375`*^9}, {3.6188455829195967`*^9, 3.6188455832048044`*^9}, {3.6188468336044407`*^9, 3.618846862634098*^9}, { 3.618848461462344*^9, 3.6188484647496653`*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{"dOptimizedVote", "=", RowBox[{"simWI2", "[", RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{"doClassification2", "[", RowBox[{"\"\\"", ",", "uAll", ",", "wAll", ",", "path", ",", RowBox[{"Accumulate", "[", RowBox[{"ConstantArray", "[", RowBox[{"1", ",", "120"}], "]"}], "]"}], ",", "i", ",", "10", ",", "200", ",", "0.8"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "numPics"}], "}"}]}], "]"}], ",", "numPics"}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"dOptimizedVoteEROS", "=", RowBox[{"simWI2", "[", RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{"doClassification2", "[", RowBox[{"\"\\"", ",", "uAll", ",", "wAll", ",", "path", ",", RowBox[{"Accumulate", "[", RowBox[{"ConstantArray", "[", RowBox[{"1", ",", "120"}], "]"}], "]"}], ",", "i", ",", "10", ",", "50", ",", "0.8"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "numPics"}], "}"}]}], "]"}], ",", "numPics"}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"dOptimizedVotePCA", "=", RowBox[{"simWI2", "[", RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{"doClassification2", "[", RowBox[{"\"\\"", ",", "uAll", ",", "wAll", ",", "path", ",", RowBox[{"Accumulate", "[", RowBox[{"ConstantArray", "[", RowBox[{"1", ",", "120"}], "]"}], "]"}], ",", "i", ",", "10", ",", "50", ",", "0.8"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "numPics"}], "}"}]}], "]"}], ",", "numPics"}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"dOptimizedVoteCOS", "=", RowBox[{"simWI2", "[", RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{"doClassification2", "[", RowBox[{"\"\\"", ",", "uAll", ",", "wAll", ",", "path", ",", RowBox[{"Accumulate", "[", RowBox[{"ConstantArray", "[", RowBox[{"1", ",", "120"}], "]"}], "]"}], ",", "i", ",", "10", ",", "50", ",", "0.8"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "numPics"}], "}"}]}], "]"}], ",", "numPics"}], "]"}]}], ";"}]}], "Input", CellChangeTimes->{{3.6188434315656924`*^9, 3.618843540859366*^9}, { 3.618846842809998*^9, 3.6188468698912272`*^9}, {3.6188471690788555`*^9, 3.618847184545848*^9}, {3.6188490488508053`*^9, 3.618849051969022*^9}}], Cell[BoxData[{ RowBox[{"Labeled", "[", RowBox[{ RowBox[{"Grid", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{ RowBox[{ RowBox[{"Text", "@", RowBox[{"Style", "[", RowBox[{"#", ",", "\"\\"", ",", "Larger"}], "]"}]}], "&"}], "/@", RowBox[{"{", RowBox[{ "\"\\"", ",", "\"\\"", ",", " ", "\"\\"", ",", " ", "\"\\""}], "}"}]}], ",", RowBox[{"{", RowBox[{ RowBox[{"ArrayPlot", "[", RowBox[{"dEROS", ",", RowBox[{"ImageSize", "\[Rule]", "300"}]}], "]"}], ",", RowBox[{"ArrayPlot", "[", RowBox[{"dEROS", ",", RowBox[{"ImageSize", "\[Rule]", "300"}]}], "]"}], ",", RowBox[{"ArrayPlot", "[", RowBox[{"dEROS", ",", RowBox[{"ImageSize", "\[Rule]", "300"}]}], "]"}], ",", RowBox[{"ArrayPlot", "[", RowBox[{"dEROS", ",", RowBox[{"ImageSize", "\[Rule]", "300"}]}], "]"}]}], "}"}]}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"Alignment", "\[Rule]", RowBox[{"{", RowBox[{"Center", ",", RowBox[{"{", RowBox[{"Bottom", ",", "Top"}], "}"}]}], "}"}]}], ",", RowBox[{"Frame", "\[Rule]", "All"}], ",", RowBox[{"Spacings", "\[Rule]", RowBox[{"{", RowBox[{"0", ",", "1"}], "}"}]}]}], "]"}], ",", RowBox[{"Text", "@", RowBox[{"Style", "[", RowBox[{ "\"\\"", ",", "\"\\"", ",", "Larger"}], "]"}]}], ",", RowBox[{"{", RowBox[{"{", RowBox[{"Bottom", ",", "Center"}], "}"}], "}"}]}], "]"}], "\[IndentingNewLine]", RowBox[{"Labeled", "[", RowBox[{ RowBox[{"Grid", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{ RowBox[{ RowBox[{"Text", "@", RowBox[{"Style", "[", RowBox[{"#", ",", "\"\\"", ",", "Larger"}], "]"}]}], "&"}], "/@", RowBox[{"{", RowBox[{ "\"\\"", ",", "\"\\"", ",", " ", "\"\\"", ",", " ", "\"\\""}], "}"}]}], ",", RowBox[{"{", RowBox[{ RowBox[{"ArrayPlot", "[", RowBox[{"dEROS", ",", RowBox[{"ImageSize", "\[Rule]", "300"}]}], "]"}], ",", RowBox[{"ArrayPlot", "[", RowBox[{"dEROS", ",", RowBox[{"ImageSize", "\[Rule]", "300"}]}], "]"}], ",", RowBox[{"ArrayPlot", "[", RowBox[{"dEROS", ",", RowBox[{"ImageSize", "\[Rule]", "300"}]}], "]"}], ",", RowBox[{"ArrayPlot", "[", RowBox[{"dEROS", ",", RowBox[{"ImageSize", "\[Rule]", "300"}]}], "]"}]}], "}"}]}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"Alignment", "\[Rule]", RowBox[{"{", RowBox[{"Center", ",", RowBox[{"{", RowBox[{"Bottom", ",", "Top"}], "}"}]}], "}"}]}], ",", RowBox[{"Frame", "\[Rule]", "All"}], ",", RowBox[{"Spacings", "\[Rule]", RowBox[{"{", RowBox[{"0", ",", "1"}], "}"}]}]}], "]"}], ",", RowBox[{"Text", "@", RowBox[{"Style", "[", RowBox[{ "\"\\"", ",", "\"\\"", ",", "Larger"}], "]"}]}], ",", RowBox[{"{", RowBox[{"{", RowBox[{"Bottom", ",", "Center"}], "}"}], "}"}]}], "]"}]}], "Input", CellChangeTimes->{{3.6188435934787626`*^9, 3.6188437769241333`*^9}, { 3.618843908942937*^9, 3.6188440440599823`*^9}, {3.6188459768385763`*^9, 3.6188459815048676`*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["\<\ Objective assesment of all the classification methods\ \>", "Subsection", CellChangeTimes->{{3.6188454391194067`*^9, 3.61884547543421*^9}, { 3.61884567670525*^9, 3.6188456811994495`*^9}}], Cell["\<\ Once again, we assume that all the SVD matrices are computed from a given \ data set in Section 1. We can now objectively test the properties of all 11 \ methods as described in text (section Result). There are only 2 input \ parameters - numbers of pictures we want to test (can be selected manualy or \ randomly, should be < 90) and number of classifications performed on each \ picture. Depending on the input parameters, this might take hours or even \ days. Computers with small RAM might have problems with higher number of \ tests.\ \>", "Text", CellChangeTimes->{{3.6188457148904147`*^9, 3.618845716875826*^9}, { 3.6188462326103225`*^9, 3.6188463044253597`*^9}, {3.618846435175309*^9, 3.618846599039745*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{"thisClass", "=", RowBox[{"{", RowBox[{ "8", ",", "17", ",", "26", ",", "34", ",", "43", ",", "55", ",", "67", ",", "71", ",", "88"}], "}"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"testsForOne", "=", "50"}], ";"}], "\[IndentingNewLine]", "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"imageNumbers", "=", RowBox[{"Accumulate", "[", RowBox[{"ConstantArray", "[", RowBox[{"1", ",", "120"}], "]"}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"picturesTotal", "=", RowBox[{"Length", "[", "thisClass", "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"dimensions", "=", RowBox[{"Dimensions", "[", "uAll", "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"weightV", "=", RowBox[{"weightVector", "[", RowBox[{"wAll", ",", "dimensions"}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"d", "=", RowBox[{"ConstantArray", "[", RowBox[{"0", ",", RowBox[{"{", RowBox[{ "11", ",", "testsForOne", ",", "picturesTotal", ",", "numPics"}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"t", "=", RowBox[{"ConstantArray", "[", RowBox[{"0", ",", RowBox[{"{", RowBox[{ "11", ",", "testsForOne", ",", "picturesTotal", ",", "numPics"}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Do", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"Do", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"imgTest", "=", RowBox[{"Flatten", "[", RowBox[{"readFunOne", "[", RowBox[{ RowBox[{"allPics", "[", RowBox[{"[", RowBox[{"thisClass", "[", RowBox[{"[", "j", "]"}], "]"}], "]"}], "]"}], ",", "numPatches", ",", RowBox[{"{", RowBox[{"patchSize", ",", "patchSize"}], "}"}]}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"testFeatures", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"buildFeatures", "[", RowBox[{"imgTest", "[", RowBox[{"[", "k", "]"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"k", ",", "1", ",", "numPatches"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"{", RowBox[{"uAllNew", ",", "wAllNew", ",", "v"}], "}"}], "=", RowBox[{"SingularValueDecomposition", "[", RowBox[{ RowBox[{"Transpose", "[", "testFeatures", "]"}], ",", "sizeSVD"}], "]"}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{ RowBox[{"t", "[", RowBox[{"[", RowBox[{"1", ",", "i", ",", "j"}], "]"}], "]"}], "=", RowBox[{ RowBox[{"Timing", "[", RowBox[{ RowBox[{ RowBox[{"d", "[", RowBox[{"[", RowBox[{"1", ",", "i", ",", "j"}], "]"}], "]"}], "=", RowBox[{"erosDistanceOne", "[", RowBox[{ "uAll", ",", "uAllNew", ",", "weightV", ",", "dimensions"}], "]"}]}], ";"}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"t", "[", RowBox[{"[", RowBox[{"2", ",", "i", ",", "j"}], "]"}], "]"}], "=", RowBox[{ RowBox[{"Timing", "[", RowBox[{ RowBox[{ RowBox[{"d", "[", RowBox[{"[", RowBox[{"2", ",", "i", ",", "j"}], "]"}], "]"}], "=", RowBox[{"pcaDistanceOne", "[", RowBox[{ "uAll", ",", " ", "uAllNew", ",", " ", "weightV", ",", " ", "dimensions"}], "]"}]}], ";"}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"t", "[", RowBox[{"[", RowBox[{"3", ",", "i", ",", "j"}], "]"}], "]"}], "=", RowBox[{ RowBox[{"Timing", "[", RowBox[{ RowBox[{ RowBox[{"d", "[", RowBox[{"[", RowBox[{"3", ",", "i", ",", "j"}], "]"}], "]"}], "=", RowBox[{"cosDistanceOne", "[", RowBox[{ "uAll", ",", " ", "uAllNew", ",", " ", "weightV", ",", " ", "dimensions"}], "]"}]}], ";"}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{ RowBox[{"t", "[", RowBox[{"[", RowBox[{"4", ",", "i", ",", "j"}], "]"}], "]"}], "=", RowBox[{ RowBox[{"Timing", "[", RowBox[{ RowBox[{ RowBox[{"d", "[", RowBox[{"[", RowBox[{"4", ",", "i", ",", "j"}], "]"}], "]"}], "=", RowBox[{"1", "-", RowBox[{ RowBox[{"simWI", "[", RowBox[{"ConstantArray", "[", RowBox[{ RowBox[{"doClassification", "[", RowBox[{ "\"\\"", ",", "uAll", ",", "wAll", ",", "path", ",", "imageNumbers", ",", RowBox[{"thisClass", "[", RowBox[{"[", "j", "]"}], "]"}], ",", "3000"}], "]"}], ",", "numPics"}], "]"}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}]}], ";"}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"t", "[", RowBox[{"[", RowBox[{"5", ",", "i", ",", "j"}], "]"}], "]"}], "=", RowBox[{ RowBox[{"Timing", "[", RowBox[{ RowBox[{ RowBox[{"d", "[", RowBox[{"[", RowBox[{"5", ",", "i", ",", "j"}], "]"}], "]"}], "=", RowBox[{"1", "-", RowBox[{ RowBox[{"simWI", "[", RowBox[{"ConstantArray", "[", RowBox[{ RowBox[{"doClassification", "[", RowBox[{ "\"\\"", ",", "uAll", ",", "wAll", ",", "path", ",", "imageNumbers", ",", RowBox[{"thisClass", "[", RowBox[{"[", "j", "]"}], "]"}], ",", "300"}], "]"}], ",", "numPics"}], "]"}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}]}], ";"}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"t", "[", RowBox[{"[", RowBox[{"6", ",", "i", ",", "j"}], "]"}], "]"}], "=", RowBox[{ RowBox[{"Timing", "[", RowBox[{ RowBox[{ RowBox[{"d", "[", RowBox[{"[", RowBox[{"6", ",", "i", ",", "j"}], "]"}], "]"}], "=", RowBox[{"1", "-", RowBox[{ RowBox[{"simWI", "[", RowBox[{"ConstantArray", "[", RowBox[{ RowBox[{"doClassification", "[", RowBox[{ "\"\\"", ",", "uAll", ",", "wAll", ",", "path", ",", "imageNumbers", ",", RowBox[{"thisClass", "[", RowBox[{"[", "j", "]"}], "]"}], ",", "300"}], "]"}], ",", "numPics"}], "]"}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}]}], ";"}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"t", "[", RowBox[{"[", RowBox[{"7", ",", "i", ",", "j"}], "]"}], "]"}], "=", RowBox[{ RowBox[{"Timing", "[", RowBox[{ RowBox[{ RowBox[{"d", "[", RowBox[{"[", RowBox[{"7", ",", "i", ",", "j"}], "]"}], "]"}], "=", RowBox[{"1", "-", RowBox[{ RowBox[{"simWI", "[", RowBox[{"ConstantArray", "[", RowBox[{ RowBox[{"doClassification", "[", RowBox[{ "\"\\"", ",", "uAll", ",", "wAll", ",", "path", ",", "imageNumbers", ",", RowBox[{"thisClass", "[", RowBox[{"[", "j", "]"}], "]"}], ",", "300"}], "]"}], ",", "numPics"}], "]"}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}]}], ";"}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", RowBox[{ RowBox[{"t", "[", RowBox[{"[", RowBox[{"8", ",", "i", ",", "j"}], "]"}], "]"}], "=", RowBox[{ RowBox[{"Timing", "[", RowBox[{ RowBox[{ RowBox[{"d", "[", RowBox[{"[", RowBox[{"8", ",", "i", ",", "j"}], "]"}], "]"}], "=", RowBox[{ RowBox[{"simWI2", "[", RowBox[{ RowBox[{"ConstantArray", "[", RowBox[{ RowBox[{"doClassification2", "[", RowBox[{ "\"\\"", ",", "uAll", ",", "wAll", ",", "path", ",", "imageNumbers", ",", RowBox[{"thisClass", "[", RowBox[{"[", "j", "]"}], "]"}], ",", "10", ",", "200", ",", "0.8"}], "]"}], ",", "numPics"}], "]"}], ",", "numPics"}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}], ";"}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"t", "[", RowBox[{"[", RowBox[{"9", ",", "i", ",", "j"}], "]"}], "]"}], "=", RowBox[{ RowBox[{"Timing", "[", RowBox[{ RowBox[{ RowBox[{"d", "[", RowBox[{"[", RowBox[{"9", ",", "i", ",", "j"}], "]"}], "]"}], "=", RowBox[{ RowBox[{"simWI2", "[", RowBox[{ RowBox[{"ConstantArray", "[", RowBox[{ RowBox[{"doClassification2", "[", RowBox[{ "\"\\"", ",", "uAll", ",", "wAll", ",", "path", ",", "imageNumbers", ",", RowBox[{"thisClass", "[", RowBox[{"[", "j", "]"}], "]"}], ",", "10", ",", "50", ",", "0.8"}], "]"}], ",", "numPics"}], "]"}], ",", "numPics"}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}], ";"}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"t", "[", RowBox[{"[", RowBox[{"10", ",", "i", ",", "j"}], "]"}], "]"}], "=", RowBox[{ RowBox[{"Timing", "[", RowBox[{ RowBox[{ RowBox[{"d", "[", RowBox[{"[", RowBox[{"10", ",", "i", ",", "j"}], "]"}], "]"}], "=", RowBox[{ RowBox[{"simWI2", "[", RowBox[{ RowBox[{"ConstantArray", "[", RowBox[{ RowBox[{"doClassification2", "[", RowBox[{ "\"\\"", ",", "uAll", ",", "wAll", ",", "path", ",", "imageNumbers", ",", RowBox[{"thisClass", "[", RowBox[{"[", "j", "]"}], "]"}], ",", "10", ",", "50", ",", "0.8"}], "]"}], ",", "numPics"}], "]"}], ",", "numPics"}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}], ";"}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"t", "[", RowBox[{"[", RowBox[{"11", ",", "i", ",", "j"}], "]"}], "]"}], "=", RowBox[{ RowBox[{"Timing", "[", RowBox[{ RowBox[{ RowBox[{"d", "[", RowBox[{"[", RowBox[{"11", ",", "i", ",", "j"}], "]"}], "]"}], "=", RowBox[{ RowBox[{"simWI2", "[", RowBox[{ RowBox[{"ConstantArray", "[", RowBox[{ RowBox[{"doClassification2", "[", RowBox[{ "\"\\"", ",", "uAll", ",", "wAll", ",", "path", ",", "imageNumbers", ",", RowBox[{"thisClass", "[", RowBox[{"[", "j", "]"}], "]"}], ",", "10", ",", "50", ",", "0.8"}], "]"}], ",", "numPics"}], "]"}], ",", "numPics"}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}], ";"}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}], ";"}], "\[IndentingNewLine]", "\[IndentingNewLine]", ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "testsForOne"}], "}"}]}], "]"}], ";"}], "\[IndentingNewLine]", ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", RowBox[{"Length", "[", "thisClass", "]"}]}], "}"}]}], "]"}], ";"}]}], "Input", CellChangeTimes->{{3.618846646054178*^9, 3.618846661722293*^9}}], Cell["\<\ Now the results displayed for each image separately, and then the conclusive \ table.\ \>", "Text", CellChangeTimes->{{3.618846972730319*^9, 3.6188470126246653`*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{"rt", "=", RowBox[{"ConstantArray", "[", RowBox[{"0", ",", RowBox[{"{", RowBox[{"11", ",", "picturesTotal"}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"at", "=", RowBox[{"ConstantArray", "[", RowBox[{"0", ",", RowBox[{"{", RowBox[{"11", ",", "picturesTotal"}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"methodNames", "=", RowBox[{"{", RowBox[{ "\"\\"", ",", "\"\\"", ",", "\"\\"", ",", " ", "\"\\"", ",", "\"\\"", ",", " ", "\"\\"", ",", " ", "\"\\"", ",", " ", "\"\\"", ",", "\"\\"", ",", " ", "\"\\"", ",", " ", "\"\\""}], "}"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{"Grid", "[", RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{"k", "==", "1"}], ",", RowBox[{"{", RowBox[{ RowBox[{"StringForm", "[", RowBox[{"\"\\"", ",", RowBox[{"thisClass", "[", RowBox[{"[", "j", "]"}], "]"}]}], "]"}], ",", "\"\\"", ",", "\"\<% of correct matches\>\"", ",", " ", "\"\\""}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"methodNames", "[", RowBox[{"[", RowBox[{"k", "-", "1"}], "]"}], "]"}], ",", RowBox[{ RowBox[{"Clear", "[", "temp", "]"}], ";", RowBox[{"temp", "=", RowBox[{"Reverse", "[", RowBox[{"Sort", "[", RowBox[{ RowBox[{"Tally", "[", RowBox[{"Flatten", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"Position", "[", RowBox[{ RowBox[{"d", "[", RowBox[{"[", RowBox[{ RowBox[{"k", "-", "1"}], ",", "i", ",", "j"}], "]"}], "]"}], ",", RowBox[{"Max", "[", RowBox[{"d", "[", RowBox[{"[", RowBox[{ RowBox[{"k", "-", "1"}], ",", "i", ",", "j"}], "]"}], "]"}], "]"}]}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "testsForOne"}], "}"}]}], "]"}], "]"}], "]"}], ",", RowBox[{ RowBox[{ RowBox[{"#1", "[", RowBox[{"[", "2", "]"}], "]"}], "<", RowBox[{"#2", "[", RowBox[{"[", "2", "]"}], "]"}]}], "&"}]}], "]"}], "]"}]}], ";", " ", RowBox[{"temp", "[", RowBox[{"[", "1", "]"}], "]"}]}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"rt", "[", RowBox[{"[", RowBox[{ RowBox[{"k", "-", "1"}], ",", "j"}], "]"}], "]"}], "=", RowBox[{"findScore", "[", RowBox[{"temp", ",", RowBox[{"thisClass", "[", RowBox[{"[", "j", "]"}], "]"}], ",", "testsForOne"}], "]"}]}], ",", RowBox[{ RowBox[{"at", "[", RowBox[{"[", RowBox[{ RowBox[{"k", "-", "1"}], ",", "j"}], "]"}], "]"}], "=", RowBox[{ RowBox[{"Total", "[", RowBox[{"t", "[", RowBox[{"[", RowBox[{ RowBox[{"k", "-", "1"}], ",", "All", ",", "j"}], "]"}], "]"}], "]"}], "/", "testsForOne"}]}]}], "}"}]}], " ", "]"}], ",", RowBox[{"{", RowBox[{"k", ",", "1", ",", "12"}], "}"}]}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"Alignment", "\[Rule]", RowBox[{"{", RowBox[{"Center", ",", RowBox[{"{", RowBox[{"Bottom", ",", "Top"}], "}"}]}], "}"}]}], ",", RowBox[{"Frame", "\[Rule]", "All"}], ",", RowBox[{"Spacings", "\[Rule]", RowBox[{"{", RowBox[{"2", ",", "1"}], "}"}]}]}], "]"}], "\[IndentingNewLine]", ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", RowBox[{"Length", "[", "thisClass", "]"}]}], "}"}]}], "]"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{"Grid", "[", RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{"k", "==", "1"}], ",", RowBox[{"{", RowBox[{ "\"\< \>\"", ",", "\"\\"", ",", "\"\\"", ",", "\"\\""}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"methodNames", "[", RowBox[{"[", RowBox[{"k", "-", "1"}], "]"}], "]"}], ",", RowBox[{"Mean", "[", RowBox[{"Flatten", "[", RowBox[{"rt", "[", RowBox[{"[", RowBox[{"k", "-", "1"}], "]"}], "]"}], "]"}], "]"}], ",", RowBox[{"Sqrt", "[", RowBox[{"Variance", "[", RowBox[{"Flatten", "[", RowBox[{"rt", "[", RowBox[{"[", RowBox[{"k", "-", "1"}], "]"}], "]"}], "]"}], "]"}], "]"}], ",", RowBox[{ RowBox[{"Total", "[", RowBox[{"Flatten", "[", RowBox[{"at", "[", RowBox[{"[", RowBox[{"k", "-", "1"}], "]"}], "]"}], "]"}], "]"}], "/", "picturesTotal"}]}], "}"}]}], "]"}], ",", RowBox[{"{", RowBox[{"k", ",", "1", ",", "12"}], "}"}]}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"Alignment", "\[Rule]", RowBox[{"{", RowBox[{"Center", ",", RowBox[{"{", RowBox[{"Bottom", ",", "Top"}], "}"}]}], "}"}]}], ",", RowBox[{"Frame", "\[Rule]", "All"}], ",", RowBox[{"Spacings", "\[Rule]", RowBox[{"{", RowBox[{"2", ",", "1"}], "}"}]}]}], "]"}]}], "Input", CellChangeTimes->{{3.607807350334483*^9, 3.607807368311186*^9}, { 3.6078075028462315`*^9, 3.607807687446622*^9}, {3.6078077238073072`*^9, 3.6078077565694513`*^9}, {3.6078078477418566`*^9, 3.607808096531604*^9}, { 3.6078082016198573`*^9, 3.6078084834779477`*^9}, {3.607808548752057*^9, 3.6078085872912817`*^9}, {3.607808877485277*^9, 3.607808886719801*^9}, { 3.607810297664507*^9, 3.607810358139227*^9}, {3.6078105231928225`*^9, 3.607810533570153*^9}, {3.607810648707487*^9, 3.607810655592351*^9}, { 3.6078107894679213`*^9, 3.6078108499336367`*^9}, {3.6078110181164417`*^9, 3.607811055730012*^9}, {3.607811241066936*^9, 3.60781144400029*^9}, { 3.6078117056251044`*^9, 3.607811775955787*^9}, {3.6078162709324975`*^9, 3.607816305130658*^9}, {3.6078516333744907`*^9, 3.60785163375576*^9}, { 3.607854514957753*^9, 3.6078545265519257`*^9}, {3.607859088546315*^9, 3.6078590898082066`*^9}, {3.607987699053735*^9, 3.607987759242201*^9}, { 3.608122370628329*^9, 3.60812238393874*^9}, {3.6084244380264416`*^9, 3.6084244569798403`*^9}, {3.608424528771586*^9, 3.6084246193065777`*^9}, { 3.608424659668106*^9, 3.6084249451839194`*^9}, {3.6084249771885257`*^9, 3.6084251886620007`*^9}, {3.608425218875359*^9, 3.6084252890659714`*^9}, { 3.6084253570710573`*^9, 3.6084254162799077`*^9}, {3.6084255181949453`*^9, 3.608425542065818*^9}, {3.608425587462906*^9, 3.6084255879992933`*^9}, { 3.6084579121587687`*^9, 3.6084579214013195`*^9}, {3.6174552654912305`*^9, 3.6174553126545563`*^9}, {3.6174554782666173`*^9, 3.617455504051843*^9}, 3.6174620686861506`*^9, {3.617462385455067*^9, 3.617462386255638*^9}, { 3.6174702665654817`*^9, 3.617470268972164*^9}, {3.617627505572695*^9, 3.617627506687501*^9}, {3.617817020830448*^9, 3.6178170393845634`*^9}, { 3.61874805537037*^9, 3.618748171194684*^9}, {3.6187482051037626`*^9, 3.6187482103584957`*^9}, 3.618748345839774*^9, {3.6187484049498105`*^9, 3.6187484177208652`*^9}, {3.6187486474811535`*^9, 3.6187486598159175`*^9}, 3.6187487141575365`*^9, {3.6187488236583796`*^9, 3.6187488291652727`*^9}, { 3.6187777976933827`*^9, 3.6187778744529343`*^9}, 3.618777908410039*^9, { 3.618847017737298*^9, 3.6188471235855293`*^9}, {3.6188472114489946`*^9, 3.6188472750031404`*^9}}] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["\<\ 6. Artificial Data set creation\ \>", "Section", CellChangeTimes->{{3.6188472998828263`*^9, 3.6188473072410483`*^9}, { 3.6188475316795497`*^9, 3.6188475335809*^9}, {3.6188478213414135`*^9, 3.6188478221049557`*^9}}], Cell["\<\ Following functions can be used to generate artificial dataset consisting of \ images of desired size and desired number of such images. Theese two numbers \ are the only input parameters to all the functions.\ \>", "Text", CellChangeTimes->{{3.6188474911847763`*^9, 3.618847495345728*^9}, { 3.6188475651433325`*^9, 3.618847642792522*^9}}], Cell[CellGroupData[{ Cell["Standard Deviation", "Subsection", CellChangeTimes->{{3.5920139206094265`*^9, 3.592013929706902*^9}, { 3.592015045643253*^9, 3.59201504819801*^9}, {3.5920482834989543`*^9, 3.5920482852992296`*^9}, 3.596042469537608*^9, 3.618847545394296*^9}], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"standardDeviation", "[", RowBox[{"imageSize_", ",", "numberImages_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "i", "}"}], ",", RowBox[{"If", "[", RowBox[{ RowBox[{"numberImages", "==", "1"}], ",", RowBox[{"ImageClip", "[", RowBox[{ RowBox[{"RandomImage", "[", RowBox[{ RowBox[{"UniformDistribution", "[", RowBox[{"{", RowBox[{ RowBox[{"0.5", "-", RowBox[{"1", "/", "3"}]}], ",", RowBox[{"0.5", "+", RowBox[{"1", "/", "3"}]}]}], "}"}], "]"}], ",", RowBox[{"{", RowBox[{"imageSize", ",", "imageSize"}], "}"}]}], "]"}], ",", RowBox[{"{", RowBox[{"0", ",", "1"}], "}"}]}], "]"}], ",", RowBox[{"Table", "[", RowBox[{ RowBox[{"ImageClip", "[", RowBox[{ RowBox[{"RandomImage", "[", RowBox[{ RowBox[{"UniformDistribution", "[", RowBox[{"{", RowBox[{ RowBox[{"0.5", "-", RowBox[{"i", "/", "40"}]}], ",", RowBox[{"0.5", "+", RowBox[{"i", "/", "40"}]}]}], "}"}], "]"}], ",", RowBox[{"{", RowBox[{"imageSize", ",", "imageSize"}], "}"}]}], "]"}], ",", RowBox[{"{", RowBox[{"0", ",", "1"}], "}"}]}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "numberImages"}], "}"}]}], "]"}]}], "]"}]}], "]"}]}], ";"}]], "Input", InitializationCell->True, CellChangeTimes->{{3.5920135837917833`*^9, 3.592013855150241*^9}, { 3.5920150740272264`*^9, 3.5920150903047123`*^9}, {3.592045931602173*^9, 3.5920459335365443`*^9}, {3.592051396055273*^9, 3.5920514030852795`*^9}, { 3.592051561827729*^9, 3.592051589724493*^9}, {3.5920518377222137`*^9, 3.592051863498475*^9}, {3.592053383720624*^9, 3.5920533885770645`*^9}, { 3.592053447017475*^9, 3.592053449744405*^9}, {3.5927863021695857`*^9, 3.5927863175374303`*^9}, {3.592789607769066*^9, 3.592789682267642*^9}, { 3.592797254034298*^9, 3.592797267389722*^9}, 3.596243627368564*^9, { 3.6023760985668235`*^9, 3.6023761996546545`*^9}, {3.602376260292635*^9, 3.602376262612294*^9}, {3.602377565899292*^9, 3.6023775692436476`*^9}, { 3.6023776637356386`*^9, 3.602377666128336*^9}, {3.6035815110406723`*^9, 3.6035815436137056`*^9}, {3.6035822131472425`*^9, 3.603582221148902*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["Vertical Sinusoids", "Subsection", CellChangeTimes->{{3.5920455622284546`*^9, 3.5920455722805767`*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{ RowBox[{"r", "[", RowBox[{"f_", ",", "imageSize_"}], "]"}], ":=", RowBox[{"Table", "[", RowBox[{ RowBox[{"Sin", "[", RowBox[{"2", " ", "Pi", " ", "f", " ", "t"}], "]"}], ",", RowBox[{"{", RowBox[{"t", ",", "0", ",", "1", ",", RowBox[{"1", "/", RowBox[{"(", RowBox[{"imageSize", "-", "1"}], ")"}]}]}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{ RowBox[{"s", "[", RowBox[{"f_", ",", "imageSize_"}], "]"}], ":=", RowBox[{"Table", "[", RowBox[{ RowBox[{"Sin", "[", RowBox[{"2", " ", "Pi", " ", "f", " ", "t"}], "]"}], ",", RowBox[{"{", RowBox[{"t", ",", "0", ",", "1", ",", RowBox[{"1", "/", RowBox[{"(", RowBox[{"imageSize", "-", "1"}], ")"}]}]}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"verticalSin", "[", RowBox[{"imageSize_", ",", "numberImages_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"i", ",", "t"}], "}"}], ",", RowBox[{"If", "[", RowBox[{ RowBox[{"numberImages", "==", "1"}], ",", RowBox[{"ImageClip", "[", RowBox[{ RowBox[{"Image", "[", RowBox[{ RowBox[{"Outer", "[", RowBox[{"Times", ",", RowBox[{"r", "[", RowBox[{"20", ",", "imageSize"}], "]"}], ",", RowBox[{"s", "[", RowBox[{"20", ",", "imageSize"}], "]"}]}], "]"}], "+", RowBox[{"0.05", " ", RowBox[{"RandomReal", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"-", "1"}], ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"imageSize", ",", "imageSize"}], "}"}]}], "]"}]}]}], "]"}], ",", RowBox[{"{", RowBox[{"0", ",", "1"}], "}"}]}], "]"}], ",", RowBox[{"Table", "[", RowBox[{ RowBox[{"ImageClip", "[", RowBox[{ RowBox[{"Image", "[", RowBox[{ RowBox[{"Outer", "[", RowBox[{"Times", ",", RowBox[{"r", "[", RowBox[{ RowBox[{"2", "*", "i"}], ",", "imageSize"}], "]"}], ",", RowBox[{"s", "[", RowBox[{"i", ",", "imageSize"}], "]"}]}], "]"}], "+", RowBox[{"0.05", " ", RowBox[{"RandomReal", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"-", "1"}], ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{"imageSize", ",", "imageSize"}], "}"}]}], "]"}]}]}], "]"}], ",", RowBox[{"{", RowBox[{"0", ",", "1"}], "}"}]}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "numberImages"}], "}"}]}], "]"}]}], "]"}]}], "]"}]}]}], "Input", InitializationCell->True, CellChangeTimes->{{3.592045878679675*^9, 3.592045924242959*^9}, { 3.5920461579891853`*^9, 3.5920461813587437`*^9}, 3.5920472861682987`*^9, { 3.592047328235105*^9, 3.5920473745799427`*^9}, {3.5920474873808675`*^9, 3.592047549085588*^9}, {3.5920478478712916`*^9, 3.592047848391673*^9}, { 3.5920478969730825`*^9, 3.5920478972312655`*^9}, 3.592051900944007*^9, { 3.5920523019971733`*^9, 3.5920523527671604`*^9}, {3.5920524876016817`*^9, 3.5920525719874744`*^9}, {3.592052606327814*^9, 3.592052612244999*^9}, { 3.5920526546810775`*^9, 3.5920527110159826`*^9}, {3.592052742453257*^9, 3.5920527526825056`*^9}, {3.5920527872980304`*^9, 3.5920527927148685`*^9}, {3.5920530781090837`*^9, 3.592053106254039*^9}, { 3.592053189311877*^9, 3.5920531996051693`*^9}, {3.592786329131609*^9, 3.5927863710371885`*^9}, {3.592789771446562*^9, 3.5927897916027803`*^9}, { 3.5927898233641815`*^9, 3.5927898244999914`*^9}, {3.5927972904750075`*^9, 3.59279729934828*^9}, {3.5928339490744*^9, 3.5928339495177135`*^9}, { 3.5928381208580065`*^9, 3.5928381513225374`*^9}, {3.5962436380530996`*^9, 3.5962436511323338`*^9}, {3.6023762824293413`*^9, 3.6023763210887504`*^9}, {3.6023764238285933`*^9, 3.602376424620139*^9}, { 3.602377574447336*^9, 3.602377588056998*^9}, {3.602377652188467*^9, 3.60237765820772*^9}, {3.6035602632685533`*^9, 3.6035602828714066`*^9}, { 3.6035822288553457`*^9, 3.6035822364687634`*^9}, {3.6180469396671457`*^9, 3.6180469592480116`*^9}, {3.618047009766763*^9, 3.6180470179705687`*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["Scale", "Subsection", CellChangeTimes->{{3.592048211200739*^9, 3.592048212096362*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"scale", "[", RowBox[{"imageSize_", ",", "numberImages_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"tempImage", ",", "i"}], "}"}], ",", RowBox[{"If", "[", RowBox[{ RowBox[{"numberImages", "==", "1"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"tempImage", "=", RowBox[{"RandomImage", "[", RowBox[{ RowBox[{"UniformDistribution", "[", RowBox[{"{", RowBox[{"0", ",", "1"}], "}"}], "]"}], ",", RowBox[{"{", RowBox[{"imageSize", ",", "imageSize"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"ImageClip", "[", RowBox[{ RowBox[{"ImageCrop", "[", RowBox[{ RowBox[{"ImageResize", "[", RowBox[{"tempImage", ",", RowBox[{"imageSize", " ", "15"}]}], "]"}], ",", RowBox[{"{", RowBox[{"imageSize", ",", "imageSize"}], "}"}]}], "]"}], ",", RowBox[{"{", RowBox[{"0", ",", "1"}], "}"}]}], "]"}]}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"tempImage", "=", RowBox[{"RandomImage", "[", RowBox[{ RowBox[{"UniformDistribution", "[", RowBox[{"{", RowBox[{"0", ",", "1"}], "}"}], "]"}], ",", RowBox[{"{", RowBox[{"imageSize", ",", "imageSize"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Table", "[", RowBox[{ RowBox[{"ImageClip", "[", RowBox[{ RowBox[{"ImageCrop", "[", RowBox[{ RowBox[{"ImageResize", "[", RowBox[{"tempImage", ",", RowBox[{"imageSize", " ", "1.5", " ", "i"}]}], "]"}], ",", RowBox[{"{", RowBox[{"imageSize", ",", "imageSize"}], "}"}]}], "]"}], ",", RowBox[{"{", RowBox[{"0", ",", "1"}], "}"}]}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "numberImages"}], "}"}]}], "]"}]}]}], "]"}]}], "]"}]}]], "Input", InitializationCell->True, CellChangeTimes->{{3.5920482154387302`*^9, 3.5920482711492043`*^9}, { 3.5920483697930975`*^9, 3.592048480418481*^9}, {3.5920485434011087`*^9, 3.592048555692818*^9}, 3.592051905768425*^9, {3.5920535104003825`*^9, 3.592053514834524*^9}, {3.592053593910553*^9, 3.592053631265021*^9}, { 3.5920537083536415`*^9, 3.59205372305007*^9}, {3.5927863859687104`*^9, 3.5927864362101583`*^9}, {3.592789830220018*^9, 3.5927898511517982`*^9}, 3.592797328898117*^9, {3.5944749601080966`*^9, 3.594474983295475*^9}, { 3.5944750381512265`*^9, 3.5944751033913136`*^9}, 3.59447513642665*^9, { 3.594475183158673*^9, 3.594475193459939*^9}, {3.5962436586506343`*^9, 3.596243659222027*^9}, {3.602376466489826*^9, 3.6023765501371393`*^9}, { 3.6023775985684495`*^9, 3.6023776387939577`*^9}, {3.603581572795344*^9, 3.6035815892009344`*^9}, {3.603581640659341*^9, 3.603581658780158*^9}, { 3.6035819974676995`*^9, 3.603582013774233*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["Spatial Sinusoids", "Subsection", CellChangeTimes->{{3.59279688574645*^9, 3.5927968926643314`*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"spatialSin", "[", RowBox[{"imageSize_", ",", "numberImages_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"x", ",", "y", ",", "i"}], "}"}], ",", RowBox[{"If", "[", RowBox[{ RowBox[{"numberImages", "==", "1"}], ",", RowBox[{"ImageClip", "[", RowBox[{ RowBox[{"Image", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{"Sin", "[", RowBox[{"Sqrt", "[", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"x", "/", "10"}], ")"}], "^", "2"}], "+", RowBox[{ RowBox[{"(", RowBox[{"y", "/", "10"}], ")"}], "^", "2"}]}], "]"}], "]"}], " ", ",", RowBox[{"{", RowBox[{"x", ",", RowBox[{ RowBox[{"-", "imageSize"}], "/", "2"}], ",", RowBox[{"imageSize", "/", "2"}]}], "}"}], ",", RowBox[{"{", RowBox[{"y", ",", RowBox[{ RowBox[{"-", "imageSize"}], "/", "2"}], ",", RowBox[{"imageSize", "/", "2"}]}], "}"}]}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"0", ",", "1"}], "}"}]}], "]"}], ",", RowBox[{"Reverse", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{"ImageClip", "[", RowBox[{ RowBox[{"Image", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{"Sin", "[", RowBox[{"Sqrt", "[", RowBox[{ RowBox[{ RowBox[{"(", RowBox[{"x", "/", "i"}], ")"}], "^", "2"}], "+", RowBox[{ RowBox[{"(", RowBox[{"y", "/", "i"}], ")"}], "^", "2"}]}], "]"}], "]"}], " ", ",", RowBox[{"{", RowBox[{"x", ",", RowBox[{ RowBox[{"-", "imageSize"}], "/", "2"}], ",", RowBox[{"imageSize", "/", "2"}]}], "}"}], ",", RowBox[{"{", RowBox[{"y", ",", RowBox[{ RowBox[{"-", "imageSize"}], "/", "2"}], ",", RowBox[{"imageSize", "/", "2"}]}], "}"}]}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"0", ",", "1"}], "}"}]}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "numberImages"}], "}"}]}], "]"}], "]"}]}], "]"}]}], "]"}]}]], "Input", InitializationCell->True, CellChangeTimes->{{3.5927969248060255`*^9, 3.592796935153323*^9}, 3.592796965663837*^9, {3.5927970013380175`*^9, 3.5927970014931154`*^9}, { 3.5927973447823257`*^9, 3.5927973813511276`*^9}, {3.59283817617108*^9, 3.592838183718422*^9}, {3.5932581582997313`*^9, 3.593258179414662*^9}, { 3.593259583725869*^9, 3.5932595911361103`*^9}, {3.593264976190426*^9, 3.593264994869646*^9}, {3.602376579248779*^9, 3.602376612520365*^9}, { 3.603560318077306*^9, 3.603560342100306*^9}, {3.603582244399334*^9, 3.6035822514753513`*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["Rotated Sinusoids", "Subsection", CellChangeTimes->{{3.592798772368581*^9, 3.592798782095429*^9}, { 3.5932580414340734`*^9, 3.5932580430882435`*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"rotatedSin", "[", RowBox[{"imageSize_", ",", "numberImages_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"i", ",", "t"}], "}"}], ",", RowBox[{"If", "[", RowBox[{ RowBox[{"numberImages", "==", "1"}], ",", RowBox[{"ImageClip", "[", RowBox[{ RowBox[{"ImageCrop", "[", RowBox[{ RowBox[{"ImageRotate", "[", RowBox[{ RowBox[{"Image", "[", RowBox[{ RowBox[{"Outer", "[", RowBox[{"Times", ",", RowBox[{"r", "[", RowBox[{"10", ",", RowBox[{"imageSize", "+", "100"}]}], "]"}], ",", RowBox[{"s", "[", RowBox[{"5", ",", RowBox[{"imageSize", "+", "100"}]}], "]"}]}], "]"}], "+", RowBox[{"0.05", " ", RowBox[{"RandomReal", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"-", "1"}], ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"imageSize", "+", "100"}], ",", RowBox[{"imageSize", "+", "100"}]}], "}"}]}], "]"}]}]}], "]"}], ",", RowBox[{"Pi", "/", "4"}]}], "]"}], ",", "imageSize"}], "]"}], ",", RowBox[{"{", RowBox[{"0", ",", "1"}], "}"}]}], "]"}], ",", RowBox[{"Table", "[", RowBox[{ RowBox[{"ImageClip", "[", RowBox[{ RowBox[{"ImageCrop", "[", RowBox[{ RowBox[{"ImageRotate", "[", RowBox[{ RowBox[{"Image", "[", RowBox[{ RowBox[{"Outer", "[", RowBox[{"Times", ",", RowBox[{"r", "[", RowBox[{"10", ",", RowBox[{"imageSize", "+", "100"}]}], "]"}], ",", RowBox[{"s", "[", RowBox[{"5", ",", RowBox[{"imageSize", "+", "100"}]}], "]"}]}], "]"}], "+", RowBox[{"0.05", " ", RowBox[{"RandomReal", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"-", "1"}], ",", "1"}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"imageSize", "+", "100"}], ",", RowBox[{"imageSize", "+", "100"}]}], "}"}]}], "]"}]}]}], "]"}], ",", RowBox[{"i", " ", RowBox[{"Pi", "/", RowBox[{"(", RowBox[{"2", "*", RowBox[{"(", RowBox[{"numberImages", "-", "1"}], ")"}]}], ")"}]}]}]}], "]"}], ",", "imageSize"}], "]"}], ",", RowBox[{"{", RowBox[{"0", ",", "1"}], "}"}]}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "0", ",", RowBox[{"numberImages", "-", "1"}]}], "}"}]}], "]"}]}], "]"}]}], "]"}]}]], "Input", InitializationCell->True, CellChangeTimes->CompressedData[" 1:eJxTTMoPSmViYGAQAWIQLXz0kMiOI68cz3xoEAPRYWle8iDarmWdJoiWUA4z AdE7og+agWiXldk2IHq6CLMLiJ7swO8Poq9vFQLTT0rS750A0l8U+8F0VaLe axBd/9X7DYj+0cb4GUQn6WV8AdFXIngrTwLpO27SYHpPyMnFp4E00zOjpSBa 7vabS8qnXjmuu1BxBUT3/nJ+CqK/zr8Cpll+X4j2Ov3KUbzpE5h+GHn0x59r rxzXPGv5C6L3PtJi/guk/z3bC6b75zKJg+iSzmApEG3LE3NO6eYrx2urpc+D 6DQTk1BPIJ3gYhUOohv1DywD0SpWGstBtH5ZuGrBF6A/77ipgWgAm623Ug== "]] }, Open ]], Cell[CellGroupData[{ Cell["Distance transform of points", "Subsection", CellChangeTimes->{{3.593225887292843*^9, 3.5932258971868486`*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"pointDistTransform", "[", RowBox[{"imageSize_", ",", "numberImages_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"i", ",", "j"}], "}"}], ",", RowBox[{"If", "[", RowBox[{ RowBox[{"numberImages", "==", "1"}], ",", RowBox[{"ImageClip", "[", RowBox[{ RowBox[{"ImageResize", "[", RowBox[{ RowBox[{"ImageAdjust", "[", RowBox[{"DistanceTransform", "[", RowBox[{"Image", "[", RowBox[{"Graphics", "[", RowBox[{"Point", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"Random", "[", RowBox[{"Integer", ",", RowBox[{"{", RowBox[{"1", ",", RowBox[{"imageSize", "-", "1"}]}], "}"}]}], "]"}], ",", RowBox[{"Random", "[", RowBox[{"Integer", ",", RowBox[{"{", RowBox[{"1", ",", RowBox[{"imageSize", "-", "1"}]}], "}"}]}], "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "200"}], "}"}]}], "]"}], "]"}], "]"}], "]"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"imageSize", ",", "imageSize"}], "}"}]}], "]"}], ",", RowBox[{"{", RowBox[{"0", ",", "1"}], "}"}]}], "]"}], ",", RowBox[{"Table", "[", RowBox[{ RowBox[{"ImageClip", "[", RowBox[{ RowBox[{"ImageResize", "[", RowBox[{ RowBox[{"ImageAdjust", "[", RowBox[{"DistanceTransform", "[", RowBox[{"Image", "[", RowBox[{"Graphics", "[", RowBox[{"Point", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"Random", "[", RowBox[{"Integer", ",", RowBox[{"{", RowBox[{"1", ",", RowBox[{"imageSize", "-", "1"}]}], "}"}]}], "]"}], ",", RowBox[{"Random", "[", RowBox[{"Integer", ",", RowBox[{"{", RowBox[{"1", ",", RowBox[{"imageSize", "-", "1"}]}], "}"}]}], "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", RowBox[{"0.4", " ", "j", " ", "50"}]}], "}"}]}], "]"}], "]"}], "]"}], "]"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"imageSize", ",", "imageSize"}], "}"}]}], "]"}], ",", RowBox[{"{", RowBox[{"0", ",", "1"}], "}"}]}], "]"}], ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", "numberImages"}], "}"}]}], "]"}]}], " ", "]"}]}], "]"}]}]], "Input", InitializationCell->True, CellChangeTimes->{{3.5928019206438055`*^9, 3.592801924459497*^9}, { 3.5928020349814763`*^9, 3.5928020411968794`*^9}, {3.592834828731302*^9, 3.5928348292166586`*^9}, {3.5928348668052635`*^9, 3.5928348849481244`*^9}, { 3.5928349868202486`*^9, 3.5928349995832872`*^9}, {3.5928350407524385`*^9, 3.5928352116644664`*^9}, {3.5928352773189597`*^9, 3.5928352832761755`*^9}, { 3.5928354134863806`*^9, 3.592835418209725*^9}, {3.5932254977183113`*^9, 3.5932255023676004`*^9}, {3.5932256140746202`*^9, 3.593225616900605*^9}, { 3.5932257219428964`*^9, 3.593225722716446*^9}, {3.5932257903132668`*^9, 3.5932258442824354`*^9}, {3.5962436879272785`*^9, 3.596243688765876*^9}, { 3.602376937188549*^9, 3.6023769755147095`*^9}, {3.6029818336194887`*^9, 3.602981850009068*^9}, {3.603581674257104*^9, 3.6035816980319166`*^9}, { 3.6035822740883436`*^9, 3.6035822775117626`*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["Distance transform of lines", "Subsection", CellChangeTimes->{{3.5932580079153557`*^9, 3.593258016730589*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"lineDistTransform", "[", RowBox[{"imageSize_", ",", "numberImages_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "j", "}"}], ",", RowBox[{"If", "[", RowBox[{ RowBox[{"numberImages", "==", "1"}], ",", RowBox[{"ImageClip", "[", RowBox[{ RowBox[{"ImageResize", "[", RowBox[{ RowBox[{"ImageAdjust", "[", RowBox[{"DistanceTransform", "[", RowBox[{"ColorNegate", "[", RowBox[{"Image", "[", RowBox[{"Graphics", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"Point", "[", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "1"}], "}"}]}], "}"}], "]"}], ",", RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{"White", ",", RowBox[{"Thickness", "[", "0.01", "]"}], ",", RowBox[{"Line", "[", RowBox[{"RandomReal", "[", RowBox[{"1", ",", RowBox[{"{", RowBox[{"2", ",", "2"}], "}"}]}], "]"}], "]"}]}], "}"}], ",", RowBox[{"{", "20", "}"}]}], "]"}]}], "}"}], ",", RowBox[{"Background", "\[Rule]", "Black"}]}], "]"}], "]"}], "]"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"imageSize", ",", "imageSize"}], "}"}]}], "]"}], ",", RowBox[{"{", RowBox[{"0", ",", "1"}], "}"}]}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"Table", "[", RowBox[{ RowBox[{"ImageClip", "[", RowBox[{ RowBox[{"ImageResize", "[", RowBox[{ RowBox[{"ImageAdjust", "[", RowBox[{"DistanceTransform", "[", RowBox[{"ColorNegate", "[", RowBox[{"Image", "[", RowBox[{"Graphics", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"Point", "[", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"0", ",", "0"}], "}"}], ",", RowBox[{"{", RowBox[{"1", ",", "1"}], "}"}]}], "}"}], "]"}], ",", RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{"White", ",", RowBox[{"Thickness", "[", "0.01", "]"}], ",", RowBox[{"Line", "[", RowBox[{"RandomReal", "[", RowBox[{"1", ",", RowBox[{"{", RowBox[{"2", ",", "2"}], "}"}]}], "]"}], "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"10", "+", "j"}], "}"}]}], "]"}]}], "}"}], ",", RowBox[{"Background", "\[Rule]", "Black"}]}], "]"}], "]"}], "]"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"imageSize", ",", "imageSize"}], "}"}]}], "]"}], ",", RowBox[{"{", RowBox[{"0", ",", "1"}], "}"}]}], "]"}], ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", "numberImages"}], "}"}]}], "]"}]}], "]"}]}], "]"}]}]], "Input", InitializationCell->True, CellChangeTimes->{{3.5932576467633257`*^9, 3.59325778304533*^9}, { 3.5932578151840415`*^9, 3.5932578890432816`*^9}, {3.5932583311189566`*^9, 3.5932583412220917`*^9}, 3.593259123701528*^9, {3.593260196797475*^9, 3.5932602024774914`*^9}, {3.5932645425597353`*^9, 3.593264553959799*^9}, { 3.593264650739252*^9, 3.5932646542267213`*^9}, {3.5932647072962484`*^9, 3.593264708055785*^9}, 3.59624370514741*^9, {3.6023770266499715`*^9, 3.602377036437914*^9}, {3.6023770708933477`*^9, 3.6023770862402105`*^9}, { 3.6035817045095005`*^9, 3.603581716299837*^9}, {3.603582283577052*^9, 3.603582285295268*^9}, {3.603582603964658*^9, 3.6035826307545986`*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["Bandpass filter of noise", "Subsection", CellChangeTimes->{{3.593258705286593*^9, 3.5932587132402077`*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"bandpassFilter", "[", RowBox[{"imageSize_", ",", "numberImages_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "j", "}"}], ",", RowBox[{"If", "[", RowBox[{ RowBox[{"numberImages", "==", "1"}], ",", RowBox[{"ImageClip", "[", RowBox[{ RowBox[{"ImageResize", "[", RowBox[{ RowBox[{"ImageAdjust", "[", RowBox[{"BandpassFilter", "[", RowBox[{ RowBox[{"RandomImage", "[", RowBox[{ RowBox[{"UniformDistribution", "[", RowBox[{"{", RowBox[{ RowBox[{"0.5", "-", RowBox[{"1", "/", "40"}]}], ",", RowBox[{"0.5", "+", RowBox[{"1", "/", "40"}]}]}], "}"}], "]"}], ",", RowBox[{"{", RowBox[{"200", ",", "200"}], "}"}]}], "]"}], ",", RowBox[{"{", RowBox[{ RowBox[{"0.9", "/", RowBox[{"(", RowBox[{"numberImages", " ", "10"}], ")"}]}], ",", RowBox[{"1", "/", RowBox[{"(", RowBox[{"numberImages", " ", "10"}], ")"}]}]}], " ", "}"}]}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"imageSize", ",", "imageSize"}], "}"}]}], "]"}], ",", RowBox[{"{", RowBox[{"0", ",", "1"}], "}"}]}], "]"}], ",", RowBox[{"Table", "[", RowBox[{ RowBox[{"ImageClip", "[", RowBox[{ RowBox[{"ImageResize", "[", RowBox[{ RowBox[{"ImageAdjust", "[", RowBox[{"BandpassFilter", "[", RowBox[{ RowBox[{"RandomImage", "[", RowBox[{ RowBox[{"UniformDistribution", "[", RowBox[{"{", RowBox[{ RowBox[{"0.5", "-", RowBox[{"1", "/", "40"}]}], ",", RowBox[{"0.5", "+", RowBox[{"1", "/", "40"}]}]}], "}"}], "]"}], ",", RowBox[{"{", RowBox[{"200", ",", "200"}], "}"}]}], "]"}], ",", RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"0.9", "/", "numberImages"}], "*", "j"}], ",", RowBox[{ RowBox[{"1", "/", "numberImages"}], "*", "j"}]}], "}"}]}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"imageSize", ",", "imageSize"}], "}"}]}], "]"}], ",", RowBox[{"{", RowBox[{"0", ",", "1"}], "}"}]}], "]"}], ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", "numberImages"}], "}"}]}], "]"}]}], "]"}]}], "]"}]}]], "Input", InitializationCell->True, CellChangeTimes->{{3.593258304323995*^9, 3.593258321674264*^9}, { 3.59325842933641*^9, 3.593258462748042*^9}, {3.5932585304909525`*^9, 3.5932585567845497`*^9}, {3.593258616316668*^9, 3.5932586661859283`*^9}, { 3.5962437120312643`*^9, 3.596243729790799*^9}, {3.6023771367580385`*^9, 3.602377169396166*^9}, {3.602377199486509*^9, 3.602377221049799*^9}, { 3.6035817195951753`*^9, 3.6035817251771197`*^9}, {3.6035817656287165`*^9, 3.6035817710825863`*^9}, {3.603582288308401*^9, 3.603582301066429*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["Distance with different slope steepness", "Subsection", CellChangeTimes->{{3.593269184788019*^9, 3.593269194018549*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"differentSlope", "[", RowBox[{"imageSize_", ",", "numberImages_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{ "list", ",", "interp", ",", "step", ",", "tempValue", ",", "i", ",", "j", ",", "k", ",", "x", ",", "y"}], "}"}], ",", RowBox[{"If", "[", RowBox[{ RowBox[{"numberImages", "==", "1"}], ",", RowBox[{ RowBox[{"tempValue", "=", RowBox[{"Round", "[", RowBox[{"10", " ", RowBox[{"Log", "[", "20", "]"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"list", "=", RowBox[{"Flatten", "[", RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"i", ",", "j"}], "}"}], ",", RowBox[{"RandomReal", "[", RowBox[{"{", RowBox[{"0", ",", "1"}], "}"}], "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "tempValue"}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", "tempValue"}], "}"}]}], "]"}], ",", "1"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"interp", "=", RowBox[{"Interpolation", "[", RowBox[{"list", ",", RowBox[{"InterpolationOrder", "\[Rule]", RowBox[{"{", RowBox[{"2", ",", "2"}], "}"}]}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"step", "=", RowBox[{"1", "/", RowBox[{"(", RowBox[{"imageSize", "/", RowBox[{"(", RowBox[{ RowBox[{"(", "tempValue", ")"}], "-", "1"}], ")"}]}], ")"}]}]}], ";", "\[IndentingNewLine]", RowBox[{"ImageClip", "[", RowBox[{ RowBox[{"Image", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{"interp", "[", RowBox[{"x", ",", "y"}], "]"}], ",", RowBox[{"{", RowBox[{"x", ",", RowBox[{"1", "+", "step"}], ",", "tempValue", ",", "step"}], "}"}], ",", RowBox[{"{", RowBox[{"y", ",", RowBox[{"1", "+", "step"}], ",", "tempValue", ",", "step"}], "}"}]}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"0", ",", "1"}], "}"}]}], "]"}]}], ",", "\[IndentingNewLine]", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"tempValue", "=", RowBox[{"Round", "[", RowBox[{"10", " ", RowBox[{"Log", "[", RowBox[{"k", " ", "2."}], "]"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"list", "=", RowBox[{"Flatten", "[", RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"i", ",", "j"}], "}"}], ",", RowBox[{"RandomReal", "[", RowBox[{"{", RowBox[{"0", ",", "1"}], "}"}], "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "tempValue"}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", "tempValue"}], "}"}]}], "]"}], ",", "1"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"interp", "=", RowBox[{"Interpolation", "[", RowBox[{"list", ",", RowBox[{"InterpolationOrder", "\[Rule]", RowBox[{"{", RowBox[{"2", ",", "2"}], "}"}]}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"step", "=", RowBox[{"1", "/", RowBox[{"(", RowBox[{"imageSize", "/", RowBox[{"(", RowBox[{ RowBox[{"(", "tempValue", ")"}], "-", "1"}], ")"}]}], ")"}]}]}], ";", "\[IndentingNewLine]", RowBox[{"ImageClip", "[", RowBox[{ RowBox[{"Image", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{"interp", "[", RowBox[{"x", ",", "y"}], "]"}], ",", RowBox[{"{", RowBox[{"x", ",", RowBox[{"1", "+", "step"}], ",", "tempValue", ",", "step"}], "}"}], ",", RowBox[{"{", RowBox[{"y", ",", RowBox[{"1", "+", "step"}], ",", "tempValue", ",", "step"}], "}"}]}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"0", ",", "1"}], "}"}]}], "]"}]}], ",", RowBox[{"{", RowBox[{"k", ",", "1", ",", "20"}], "}"}]}], "]"}]}], "]"}]}], "]"}]}]], "Input", InitializationCell->True, CellChangeTimes->{{3.5932691639883084`*^9, 3.593269171716775*^9}, { 3.593868961983536*^9, 3.5938690262890987`*^9}, {3.59386952553884*^9, 3.593869606003853*^9}, {3.5944057945807037`*^9, 3.5944057953542366`*^9}, { 3.594406910062338*^9, 3.5944069116985035`*^9}, {3.5960628467915773`*^9, 3.5960628768488226`*^9}, {3.596243755086623*^9, 3.596243759114475*^9}, { 3.602377251478372*^9, 3.6023773041347094`*^9}, {3.6035817989212627`*^9, 3.603581828342081*^9}, {3.60358230775214*^9, 3.6035823101308365`*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["Standard deviation of the patch (Expanding the histogram)", "Subsection", CellChangeTimes->{{3.5962075067950892`*^9, 3.5962075310182085`*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"HalfSTD", "[", RowBox[{"imageSize_", ",", "numberImages_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"figures", ",", "patch", ",", "i"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"numberImages", "==", "1"}], ",", RowBox[{ RowBox[{"figures", "=", RowBox[{"standardDeviation", "[", RowBox[{"imageSize", ",", "numberImages"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"patch", "=", RowBox[{"ColorConvert", "[", RowBox[{ RowBox[{ RowBox[{"readFunOne", "[", RowBox[{ RowBox[{ RowBox[{"LoadImageNames", "[", "path", "]"}], "[", RowBox[{"[", "92", "]"}], "]"}], ",", "1", ",", RowBox[{"{", RowBox[{"imageSize", ",", "imageSize"}], "}"}]}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}], ",", "\"\\""}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Return", "[", RowBox[{"HistogramTransform", "[", RowBox[{"patch", ",", "figures"}], "]"}], "]"}]}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"figures", "=", RowBox[{"standardDeviation", "[", RowBox[{"imageSize", ",", "numberImages"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"patch", "=", RowBox[{"ColorConvert", "[", RowBox[{ RowBox[{ RowBox[{"readFunOne", "[", RowBox[{ RowBox[{ RowBox[{"LoadImageNames", "[", "path", "]"}], "[", RowBox[{"[", "92", "]"}], "]"}], ",", "1", ",", RowBox[{"{", RowBox[{"imageSize", ",", "imageSize"}], "}"}]}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}], ",", "\"\\""}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Table", "[", RowBox[{ RowBox[{"HistogramTransform", "[", RowBox[{"patch", ",", RowBox[{"figures", "[", RowBox[{"[", "i", "]"}], "]"}]}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "numberImages"}], "}"}]}], "]"}]}]}], "]"}]}], "]"}]}]], "Input", InitializationCell->True, CellChangeTimes->{{3.5962075331276436`*^9, 3.596207674547361*^9}, { 3.596230386723898*^9, 3.5962304176256905`*^9}, {3.5962304556475*^9, 3.5962304592870665`*^9}, {3.602378721167344*^9, 3.6023787457427654`*^9}, { 3.602378861300683*^9, 3.602378926641017*^9}, 3.602379044173334*^9, { 3.602379074270685*^9, 3.6023790793863*^9}, {3.602379131643361*^9, 3.602379144793682*^9}, {3.605636699856425*^9, 3.605636706593176*^9}, 3.6056367864186015`*^9, {3.6180439074462748`*^9, 3.6180439164276204`*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["Scale of the patch", "Subsection", CellChangeTimes->{{3.592048211200739*^9, 3.592048212096362*^9}, { 3.5961376349649277`*^9, 3.596137637139465*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"HalfScale", "[", RowBox[{"imageSize_", ",", "numberImages_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "i", "}"}], ",", RowBox[{"If", "[", RowBox[{ RowBox[{"numberImages", "==", "1"}], ",", RowBox[{"ImageCrop", "[", RowBox[{ RowBox[{"ImageResize", "[", RowBox[{ RowBox[{"ColorConvert", "[", RowBox[{ RowBox[{ RowBox[{"readFunOne", "[", RowBox[{ RowBox[{ RowBox[{"LoadImageNames", "[", "path", "]"}], "[", RowBox[{"[", "92", "]"}], "]"}], ",", "1", ",", RowBox[{"{", RowBox[{"imageSize", ",", "imageSize"}], "}"}]}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}], ",", "\"\\""}], "]"}], ",", RowBox[{"imageSize", " ", "3"}]}], "]"}], ",", RowBox[{"{", RowBox[{"imageSize", ",", "imageSize"}], "}"}]}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"Table", "[", RowBox[{ RowBox[{"ImageCrop", "[", RowBox[{ RowBox[{"ImageResize", "[", RowBox[{ RowBox[{"ColorConvert", "[", RowBox[{ RowBox[{ RowBox[{"readFunOne", "[", RowBox[{ RowBox[{ RowBox[{"LoadImageNames", "[", "path", "]"}], "[", RowBox[{"[", "92", "]"}], "]"}], ",", "1", ",", RowBox[{"{", RowBox[{"imageSize", ",", "imageSize"}], "}"}]}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}], ",", "\"\\""}], "]"}], ",", RowBox[{"imageSize", " ", "1.5", " ", "i"}]}], "]"}], ",", RowBox[{"{", RowBox[{"imageSize", ",", "imageSize"}], "}"}]}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "numberImages"}], "}"}]}], "]"}]}], "]"}]}], "]"}]}]], "Input", InitializationCell->True, CellChangeTimes->{{3.5920482154387302`*^9, 3.5920482711492043`*^9}, { 3.5920483697930975`*^9, 3.592048480418481*^9}, {3.5920485434011087`*^9, 3.592048555692818*^9}, 3.592051905768425*^9, {3.5920535104003825`*^9, 3.592053514834524*^9}, {3.592053593910553*^9, 3.592053631265021*^9}, { 3.5920537083536415`*^9, 3.59205372305007*^9}, {3.5927863859687104`*^9, 3.5927864362101583`*^9}, {3.592789830220018*^9, 3.5927898511517982`*^9}, 3.592797328898117*^9, {3.5944749601080966`*^9, 3.594474983295475*^9}, { 3.5944750381512265`*^9, 3.5944751033913136`*^9}, 3.59447513642665*^9, { 3.594475183158673*^9, 3.594475193459939*^9}, {3.596137684095659*^9, 3.596137719949985*^9}, {3.596137787636841*^9, 3.5961377962038975`*^9}, { 3.596138043792902*^9, 3.5961380691478243`*^9}, 3.5961381168145165`*^9, { 3.596198831635894*^9, 3.596198831720957*^9}, {3.596199264363021*^9, 3.5961992733113194`*^9}, {3.5961993925353994`*^9, 3.5961993969274845`*^9}, 3.5962077305248413`*^9, {3.6023791728916035`*^9, 3.6023792176323247`*^9}, { 3.6023792494548903`*^9, 3.602379265547283*^9}, {3.603493405846335*^9, 3.603493406495799*^9}, {3.605636710654046*^9, 3.605636714960092*^9}, { 3.618043953026536*^9, 3.6180439617427006`*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["Rotation of the patch", "Subsection", CellChangeTimes->{{3.592798772368581*^9, 3.592798782095429*^9}, { 3.5932580414340734`*^9, 3.5932580430882435`*^9}, {3.5961376573997755`*^9, 3.5961376608722277`*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"HalfRotation", "[", RowBox[{"imageSize_", ",", "numberImages_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "}"}], ",", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"numberImages", "==", "1"}], ",", RowBox[{"ImageCrop", "[", RowBox[{ RowBox[{"ImageRotate", "[", RowBox[{ RowBox[{"ColorConvert", "[", RowBox[{ RowBox[{ RowBox[{"readFunOne", "[", RowBox[{ RowBox[{ RowBox[{"LoadImageNames", "[", "path", "]"}], "[", RowBox[{"[", "92", "]"}], "]"}], ",", "1", ",", RowBox[{"{", RowBox[{ RowBox[{"imageSize", "+", "100"}], ",", RowBox[{"imageSize", "+", "100"}]}], "}"}]}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}], ",", "\"\\""}], "]"}], ",", "Pi"}], "]"}], ",", "imageSize"}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"Table", "[", RowBox[{ RowBox[{"ImageCrop", "[", RowBox[{ RowBox[{"ImageRotate", "[", RowBox[{ RowBox[{"ColorConvert", "[", RowBox[{ RowBox[{ RowBox[{"readFunOne", "[", RowBox[{ RowBox[{ RowBox[{"LoadImageNames", "[", "path", "]"}], "[", RowBox[{"[", "92", "]"}], "]"}], ",", "1", ",", RowBox[{"{", RowBox[{ RowBox[{"imageSize", "+", "100"}], ",", RowBox[{"imageSize", "+", "100"}]}], "}"}]}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}], ",", "\"\\""}], "]"}], ",", RowBox[{"i", "*", RowBox[{"Pi", "/", RowBox[{"(", RowBox[{"2", "*", RowBox[{"(", RowBox[{"numberImages", "-", "1"}], ")"}]}], ")"}]}]}]}], "]"}], ",", "imageSize"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "0", ",", RowBox[{"numberImages", "-", "1"}]}], "}"}]}], "]"}]}], "]"}]}], "]"}]}]], "Input", InitializationCell->True, CellChangeTimes->{{3.592798374086557*^9, 3.592798388029394*^9}, { 3.592798458324992*^9, 3.592798541453643*^9}, {3.592798626691784*^9, 3.592798646042446*^9}, {3.5927986913644123`*^9, 3.5927987520962634`*^9}, { 3.5927988404766326`*^9, 3.5927988405846972`*^9}, {3.592832755233019*^9, 3.5928327564728947`*^9}, {3.592832857449399*^9, 3.592832866373718*^9}, { 3.5928329200477257`*^9, 3.592832931255662*^9}, {3.5928339924170933`*^9, 3.5928339928524*^9}, {3.5928384302915936`*^9, 3.592838441590577*^9}, { 3.5956404714017477`*^9, 3.5956404837754736`*^9}, {3.595640618124335*^9, 3.595640622644526*^9}, 3.5961377023915863`*^9, {3.596137810194786*^9, 3.596137815398464*^9}, {3.596137922368074*^9, 3.5961379282292213`*^9}, { 3.596198834512922*^9, 3.596198834592966*^9}, {3.596199277659396*^9, 3.596199282209593*^9}, {3.5961993797253675`*^9, 3.5961993887467146`*^9}, { 3.602379278302326*^9, 3.602379330361246*^9}, {3.602379372665227*^9, 3.6023793766860905`*^9}, {3.6023794281665764`*^9, 3.6023794304011726`*^9}, {3.602379657956786*^9, 3.6023796778488913`*^9}, 3.60237972340819*^9, {3.6034922932421913`*^9, 3.6034923010697107`*^9}, { 3.6056367120670524`*^9, 3.605636713360962*^9}, {3.6180439659456806`*^9, 3.618043973362913*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["BandPass of the patch", "Subsection", CellChangeTimes->{{3.5961357526044035`*^9, 3.5961357622232056`*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"HalfBandPass", "[", RowBox[{"imageSize_", ",", "numberImages_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "j", "}"}], ",", RowBox[{"If", "[", RowBox[{ RowBox[{"numberImages", "==", "1"}], ",", RowBox[{"ImageAdjust", "[", RowBox[{"BandpassFilter", "[", RowBox[{ RowBox[{"ColorConvert", "[", RowBox[{ RowBox[{ RowBox[{"readFunOne", "[", RowBox[{ RowBox[{ RowBox[{"LoadImageNames", "[", "path", "]"}], "[", RowBox[{"[", "92", "]"}], "]"}], ",", "1", ",", RowBox[{"{", RowBox[{"imageSize", ",", "imageSize"}], "}"}]}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}], ",", "\"\\""}], "]"}], ",", RowBox[{"{", RowBox[{ RowBox[{"0.9", "/", RowBox[{"(", RowBox[{"numberImages", " ", "10"}], ")"}]}], " ", ",", RowBox[{"1", "/", RowBox[{"(", RowBox[{"numberImages", " ", "10"}], ")"}]}]}], " ", "}"}]}], "]"}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"Table", "[", RowBox[{ RowBox[{"ImageAdjust", "[", RowBox[{"BandpassFilter", "[", RowBox[{ RowBox[{"ColorConvert", "[", RowBox[{ RowBox[{ RowBox[{"readFunOne", "[", RowBox[{ RowBox[{ RowBox[{"LoadImageNames", "[", "path", "]"}], "[", RowBox[{"[", "92", "]"}], "]"}], ",", "1", ",", RowBox[{"{", RowBox[{"imageSize", ",", "imageSize"}], "}"}]}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}], ",", "\"\\""}], "]"}], ",", RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"0.9", "/", "numberImages"}], " ", "j"}], ",", RowBox[{ RowBox[{"1", "/", "numberImages"}], " ", "j"}]}], "}"}]}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", "numberImages"}], "}"}]}], "]"}]}], "]"}]}], "]"}]}]], "Input", InitializationCell->True, CellChangeTimes->{{3.5961357137219205`*^9, 3.596135826565672*^9}, { 3.5961358571002703`*^9, 3.5961358961048355`*^9}, {3.5961359452765913`*^9, 3.596135968722164*^9}, {3.5961360452612653`*^9, 3.596136060629115*^9}, { 3.5961363089906936`*^9, 3.5961363228224554`*^9}, 3.5961367433126717`*^9, { 3.596198837657127*^9, 3.5961988377532043`*^9}, {3.596199284824437*^9, 3.5961992875543747`*^9}, {3.5961993998715696`*^9, 3.5961994056206136`*^9}, {3.602379440781534*^9, 3.6023794955156193`*^9}, { 3.6056367185896606`*^9, 3.605636720032681*^9}, {3.618043978206341*^9, 3.618043983600158*^9}}] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["\<\ 7. Displaying the artificial data sets\ \>", "Section", CellChangeTimes->{{3.618847971146899*^9, 3.618847984556408*^9}}], Cell["\<\ First, we need to select the number of images we want the data set to consist \ of, and their size. Then we can just sellect any set we want.\ \>", "Text", CellChangeTimes->{{3.6188479986254053`*^9, 3.6188480796539907`*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{"numberImages", "=", "20"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"imageSize", "=", "200"}], ";"}], " "}]}], "Input", InitializationCell->True], Cell[BoxData[ RowBox[{"Manipulate", "[", RowBox[{ RowBox[{ RowBox[{"Which", "[", RowBox[{ RowBox[{"type", "==", "\"\\""}], ",", RowBox[{"images", "=", RowBox[{"standardDeviation", "[", RowBox[{"imageSize", ",", "numberImages"}], "]"}]}], ",", RowBox[{"type", "\[Equal]", "\"\\""}], ",", RowBox[{"images", "=", RowBox[{"verticalSin", "[", RowBox[{"imageSize", ",", "numberImages"}], "]"}]}], ",", RowBox[{"type", "\[Equal]", "\"\\""}], ",", RowBox[{"images", "=", RowBox[{"scale", "[", RowBox[{"imageSize", ",", "numberImages"}], "]"}]}], ",", "\[IndentingNewLine]", RowBox[{"type", "\[Equal]", "\"\\""}], ",", RowBox[{"images", "=", RowBox[{"spatialSin", "[", RowBox[{"imageSize", ",", "numberImages"}], "]"}]}], ",", "\[IndentingNewLine]", RowBox[{"type", "\[Equal]", "\"\\""}], ",", RowBox[{"images", "=", RowBox[{"rotatedSin", "[", RowBox[{"imageSize", ",", "numberImages"}], "]"}]}], ",", RowBox[{"type", "\[Equal]", "\"\\""}], ",", RowBox[{"images", "=", RowBox[{"pointDistTransform", "[", RowBox[{"imageSize", ",", "numberImages"}], "]"}]}], ",", RowBox[{"type", "\[Equal]", "\"\\""}], ",", RowBox[{"images", "=", RowBox[{"lineDistTransform", "[", RowBox[{"imageSize", ",", "numberImages"}], "]"}]}], ",", RowBox[{"type", "\[Equal]", "\"\\""}], ",", RowBox[{"images", "=", RowBox[{"bandpassFilter", "[", RowBox[{"imageSize", ",", "numberImages"}], "]"}]}], ",", "\[IndentingNewLine]", RowBox[{ "type", "\[Equal]", "\"\\""}], ",", " ", RowBox[{"images", "=", RowBox[{"differentSlope", "[", RowBox[{"imageSize", ",", "numberImages"}], "]"}]}], ",", "\[IndentingNewLine]", RowBox[{"type", "==", "\"\\""}], ",", RowBox[{"images", "=", RowBox[{"HalfSTD", "[", RowBox[{"imageSize", ",", "numberImages"}], "]"}]}], ",", RowBox[{"type", "\[Equal]", "\"\\""}], ",", RowBox[{"images", "=", RowBox[{"HalfRotation", "[", RowBox[{"imageSize", ",", "numberImages"}], "]"}]}], ",", "\[IndentingNewLine]", RowBox[{"type", "\[Equal]", "\"\\""}], ",", RowBox[{"images", "=", RowBox[{"HalfScale", "[", RowBox[{"imageSize", ",", "numberImages"}], "]"}]}], ",", "\[IndentingNewLine]", RowBox[{"type", "\[Equal]", "\"\\""}], ",", RowBox[{"images", "=", RowBox[{"HalfBandPass", "[", RowBox[{"imageSize", ",", "numberImages"}], "]"}]}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"GraphicsGrid", "[", RowBox[{ RowBox[{"Partition", "[", RowBox[{"images", ",", "5"}], "]"}], ",", RowBox[{"ImageSize", "\[Rule]", "700"}]}], "]"}]}], ",", RowBox[{"{", RowBox[{"type", ",", RowBox[{"{", RowBox[{ "\"\\"", ",", "\"\\"", ",", "\"\\"", ",", "\"\\"", ",", "\"\\"", ",", "\"\\"", ",", "\"\\"", ",", "\"\\"", ",", "\"\\"", ",", "\"\\"", ",", "\"\\"", ",", "\"\\"", ",", "\"\\""}], "}"}]}], "}"}], ",", RowBox[{"Initialization", "\[RuleDelayed]", RowBox[{"(", RowBox[{ RowBox[{"images", "=", RowBox[{"standardDeviation", "[", RowBox[{"imageSize", ",", "numberImages"}], "]"}]}], ";"}], ")"}]}]}], "]"}]], "Input", InitializationCell->True, CellChangeTimes->{{3.5932828928076553`*^9, 3.5932829425348244`*^9}, { 3.593282978021924*^9, 3.593283060646361*^9}, {3.593283750185048*^9, 3.593283761023713*^9}, {3.594736222075699*^9, 3.5947362564330015`*^9}, { 3.594736295598665*^9, 3.59473629926225*^9}, {3.59473715343701*^9, 3.5947371544357147`*^9}, 3.601421872834815*^9, {3.6029818643612366`*^9, 3.6029818648735933`*^9}, {3.6188481493074937`*^9, 3.6188482984154625`*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["\<\ 8. Using artificial data set to learn about sensitivity to choosen conditions\ \>", "Section", CellChangeTimes->{{3.6188473210658693`*^9, 3.61884735617382*^9}, { 3.6188483290192127`*^9, 3.618848330532281*^9}}], Cell[CellGroupData[{ Cell["Function definitions", "Subsection", CellChangeTimes->{{3.6188487207295947`*^9, 3.6188487250516663`*^9}}], Cell[TextData[{ StyleBox["distances[]", "Input"], " calculates all similarity matrices using provided pictures.\n", StyleBox["diagonalMean[]", "Input"], " calculates means across all the diagonal of a matrix.\n", StyleBox["createSet[]", "Input"], " creates a set of 13 images of specified size using the artificial data \ sets.\n\nThe rest of the functions create data sets based on one specific \ condition we try to simulate. Those conditions are rotation change, scale \ change, brightness change, overexposure sensitivity, blur sensitivity and \ sensitivity on data distribution, i.e. histogram.\nInput parameters of those \ functions are allways the same - a base image and a number of images we want \ to generate." }], "Text", CellChangeTimes->{{3.6188487342091675`*^9, 3.618848939509078*^9}, { 3.6188489775120783`*^9, 3.618848984811266*^9}, {3.6188491384154396`*^9, 3.6188493260878067`*^9}, {3.6188501224187527`*^9, 3.618850135271882*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{ RowBox[{"distances", "[", RowBox[{ "images_", ",", "sizeSVD_", ",", "numPatches_", ",", "patchSize_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{ "uAll", ",", "wAll", ",", "dist", ",", "len", ",", "allFeatures", ",", "allPatches", ",", "u"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"dist", "=", RowBox[{"ConstantArray", "[", RowBox[{"0", ",", "11"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"len", "=", RowBox[{"Length", "[", "images", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Table", "[", RowBox[{ RowBox[{"Export", "[", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{"i", "<", "10"}], ",", RowBox[{"\"\\"", " ", "~~", RowBox[{"ToString", "[", "i", "]"}], "~~", "\"\<.tif\>\""}], ",", RowBox[{"\"\\"", " ", "~~", RowBox[{"ToString", "[", "i", "]"}], "~~", "\"\<.tif\>\""}]}], "]"}], ",", RowBox[{"images", "[", RowBox[{"[", "i", "]"}], "]"}]}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "len"}], "}"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"allPatches", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"Flatten", "[", RowBox[{"readFun", "[", RowBox[{ RowBox[{"images", "[", RowBox[{"[", "i", "]"}], "]"}], ",", "numPatches", ",", RowBox[{"{", RowBox[{"patchSize", ",", "patchSize"}], "}"}]}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "len"}], "}"}]}], "]"}]}], ";", RowBox[{"allFeatures", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"buildFeatures", "[", RowBox[{"allPatches", "[", RowBox[{"[", RowBox[{"i", ",", "j"}], "]"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "len"}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", "numPatches"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"uAll", "=", RowBox[{"ConstantArray", "[", RowBox[{ RowBox[{"{", "}"}], ",", "len"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"wAll", "=", RowBox[{"ConstantArray", "[", RowBox[{ RowBox[{"{", "}"}], ",", "len"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"u", "=", RowBox[{"ConstantArray", "[", RowBox[{ RowBox[{"{", "}"}], ",", "len"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"uAll", "[", RowBox[{"[", "i", "]"}], "]"}], ",", RowBox[{"wAll", "[", RowBox[{"[", "i", "]"}], "]"}], ",", RowBox[{"u", "[", RowBox[{"[", "i", "]"}], "]"}]}], "}"}], "=", RowBox[{"SingularValueDecomposition", "[", RowBox[{ RowBox[{"Transpose", "[", RowBox[{"allFeatures", "[", RowBox[{"[", "i", "]"}], "]"}], "]"}], ",", "sizeSVD"}], "]"}]}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "len"}], "}"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"dist", "[", RowBox[{"[", "1", "]"}], "]"}], "=", RowBox[{"erosDistance", "[", RowBox[{"uAll", ",", "wAll", ",", RowBox[{"Dimensions", "[", "uAll", "]"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"dist", "[", RowBox[{"[", "2", "]"}], "]"}], "=", RowBox[{"pcaDistance", "[", RowBox[{"uAll", ",", "wAll", ",", RowBox[{"Dimensions", "[", "uAll", "]"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"dist", "[", RowBox[{"[", "3", "]"}], "]"}], "=", RowBox[{"cosDistance", "[", RowBox[{"uAll", ",", "wAll", ",", RowBox[{"Dimensions", "[", "uAll", "]"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"dist", "[", RowBox[{"[", "4", "]"}], "]"}], "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"1", "-", RowBox[{ RowBox[{"simWI", "[", RowBox[{"ConstantArray", "[", RowBox[{ RowBox[{"doClassification", "[", RowBox[{"\"\\"", ",", "uAll", ",", "wAll", ",", RowBox[{"NotebookDirectory", "[", "]"}], ",", RowBox[{"Accumulate", "[", RowBox[{"ConstantArray", "[", RowBox[{"1", ",", "len"}], "]"}], "]"}], ",", "i", ",", "2000"}], "]"}], ",", "len"}], "]"}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "len"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"dist", "[", RowBox[{"[", "5", "]"}], "]"}], "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"1", "-", RowBox[{ RowBox[{"simWI", "[", RowBox[{"ConstantArray", "[", RowBox[{ RowBox[{"doClassification", "[", RowBox[{"\"\\"", ",", "uAll", ",", "wAll", ",", RowBox[{"NotebookDirectory", "[", "]"}], ",", RowBox[{"Accumulate", "[", RowBox[{"ConstantArray", "[", RowBox[{"1", ",", "len"}], "]"}], "]"}], ",", "i", ",", "200"}], "]"}], ",", "len"}], "]"}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "len"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"dist", "[", RowBox[{"[", "6", "]"}], "]"}], "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"1", "-", RowBox[{ RowBox[{"simWI", "[", RowBox[{"ConstantArray", "[", RowBox[{ RowBox[{"doClassification", "[", RowBox[{"\"\\"", ",", "uAll", ",", "wAll", ",", RowBox[{"NotebookDirectory", "[", "]"}], ",", RowBox[{"Accumulate", "[", RowBox[{"ConstantArray", "[", RowBox[{"1", ",", "len"}], "]"}], "]"}], ",", "i", ",", "200"}], "]"}], ",", "len"}], "]"}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "len"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"dist", "[", RowBox[{"[", "7", "]"}], "]"}], "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"1", "-", RowBox[{ RowBox[{"simWI", "[", RowBox[{"ConstantArray", "[", RowBox[{ RowBox[{"doClassification", "[", RowBox[{"\"\\"", ",", "uAll", ",", "wAll", ",", RowBox[{"NotebookDirectory", "[", "]"}], ",", RowBox[{"Accumulate", "[", RowBox[{"ConstantArray", "[", RowBox[{"1", ",", "len"}], "]"}], "]"}], ",", "i", ",", "200"}], "]"}], ",", "len"}], "]"}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}]}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "len"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"dist", "[", RowBox[{"[", "8", "]"}], "]"}], "=", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"simWI2", "[", RowBox[{ RowBox[{"ConstantArray", "[", RowBox[{ RowBox[{"doClassification2", "[", RowBox[{"\"\\"", ",", "uAll", ",", "wAll", ",", RowBox[{"NotebookDirectory", "[", "]"}], ",", RowBox[{"Accumulate", "[", RowBox[{"ConstantArray", "[", RowBox[{"1", ",", "len"}], "]"}], "]"}], ",", "i", ",", "10", ",", "200", ",", "0.8"}], "]"}], ",", "len"}], "]"}], ",", "len"}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "len"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"dist", "[", RowBox[{"[", "9", "]"}], "]"}], "=", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"simWI2", "[", RowBox[{ RowBox[{"ConstantArray", "[", RowBox[{ RowBox[{"doClassification2", "[", RowBox[{"\"\\"", ",", "uAll", ",", "wAll", ",", RowBox[{"NotebookDirectory", "[", "]"}], ",", RowBox[{"Accumulate", "[", RowBox[{"ConstantArray", "[", RowBox[{"1", ",", "len"}], "]"}], "]"}], ",", "i", ",", "10", ",", "50", ",", "0.8"}], "]"}], ",", "len"}], "]"}], ",", "len"}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "len"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"dist", "[", RowBox[{"[", "10", "]"}], "]"}], "=", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"simWI2", "[", RowBox[{ RowBox[{"ConstantArray", "[", RowBox[{ RowBox[{"doClassification2", "[", RowBox[{"\"\\"", ",", "uAll", ",", "wAll", ",", RowBox[{"NotebookDirectory", "[", "]"}], ",", RowBox[{"Accumulate", "[", RowBox[{"ConstantArray", "[", RowBox[{"1", ",", "len"}], "]"}], "]"}], ",", "i", ",", "10", ",", "50", ",", "0.8"}], "]"}], ",", "len"}], "]"}], ",", "len"}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "len"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"dist", "[", RowBox[{"[", "11", "]"}], "]"}], "=", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"simWI2", "[", RowBox[{ RowBox[{"ConstantArray", "[", RowBox[{ RowBox[{"doClassification2", "[", RowBox[{"\"\\"", ",", "uAll", ",", "wAll", ",", RowBox[{"NotebookDirectory", "[", "]"}], ",", RowBox[{"Accumulate", "[", RowBox[{"ConstantArray", "[", RowBox[{"1", ",", "len"}], "]"}], "]"}], ",", "i", ",", "10", ",", "50", ",", "0.8"}], "]"}], ",", "len"}], "]"}], ",", "len"}], "]"}], "[", RowBox[{"[", "1", "]"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "len"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"DeleteFile", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{"i", "<", "10"}], ",", RowBox[{"\"\\"", " ", "~~", RowBox[{"ToString", "[", "i", "]"}], "~~", "\"\<.tif\>\""}], ",", RowBox[{"\"\\"", " ", "~~", RowBox[{"ToString", "[", "i", "]"}], "~~", "\"\<.tif\>\""}]}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "len"}], "}"}]}], "]"}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"Return", "[", "dist", "]"}]}]}], "]"}]}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"diagonalMean", "[", "dist_", "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", "len", "}"}], ",", RowBox[{ RowBox[{"len", "=", RowBox[{"Length", "[", "dist", "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Table", "[", RowBox[{ RowBox[{"N", "[", RowBox[{"Mean", "[", RowBox[{"Diagonal", "[", RowBox[{"dist", ",", "i"}], "]"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", RowBox[{ RowBox[{"-", "len"}], "+", "1"}], ",", RowBox[{"len", "-", "1"}]}], "}"}]}], "]"}]}]}], "]"}]}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"createSet", "[", "imageSize_", "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"i", ",", "names"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"names", "=", RowBox[{"{", RowBox[{ "\"\\"", ",", "\"\\"", ",", "\"\\"", ",", "\"\\"", ",", "\"\\"", ",", "\"\\"", ",", "\"\\"", ",", "\"\\"", ",", "\"\\"", ",", "\"\\"", ",", "\"\\"", ",", "\"\\"", ",", "\"\\""}], "}"}]}], ";", "\[IndentingNewLine]", RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{"ToExpression", "[", RowBox[{"names", "[", RowBox[{"[", "i", "]"}], "]"}], "]"}], "[", RowBox[{"imageSize", ",", "1"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", RowBox[{"Length", "[", "names", "]"}]}], "}"}]}], "]"}]}]}], "]"}]}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"rotateInputImage", "[", RowBox[{"inputImage_", ",", "numberImages_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"i", ",", "dimensions"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"dimensions", "=", RowBox[{"ImageDimensions", "[", "inputImage", "]"}]}], ";", RowBox[{"Table", "[", RowBox[{ RowBox[{"ImageCrop", "[", RowBox[{ RowBox[{"ImageRotate", "[", RowBox[{"inputImage", ",", RowBox[{"i", " ", RowBox[{"Pi", "/", RowBox[{"(", RowBox[{"2", "*", RowBox[{"(", RowBox[{"numberImages", "-", "1"}], ")"}]}], ")"}]}]}]}], "]"}], ",", RowBox[{ RowBox[{"dimensions", "[", RowBox[{"[", "1", "]"}], "]"}], "-", "100"}]}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "0", ",", RowBox[{"numberImages", "-", "1"}]}], "}"}]}], "]"}]}]}], "]"}]}], "\n"}], "\n", RowBox[{ RowBox[{ RowBox[{"scaleInputImage", "[", RowBox[{"inputImage_", ",", "numberImages_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"dimensions", ",", "i"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"dimensions", "=", RowBox[{"ImageDimensions", "[", "inputImage", "]"}]}], ";", RowBox[{"Table", "[", RowBox[{ RowBox[{"ImageCrop", "[", RowBox[{ RowBox[{"ImageResize", "[", RowBox[{"inputImage", ",", RowBox[{ RowBox[{"dimensions", "[", RowBox[{"[", "1", "]"}], "]"}], " ", "i"}]}], "]"}], ",", "dimensions"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "numberImages"}], "}"}]}], "]"}]}]}], "]"}]}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"brightnessInputImage", "[", RowBox[{"inputImage_", ",", "numberImages_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"dimensions", ",", "i"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"dimensions", "=", RowBox[{"ImageDimensions", "[", "inputImage", "]"}]}], ";", RowBox[{"Table", "[", RowBox[{ RowBox[{"ImageAdjust", "[", RowBox[{"inputImage", ",", RowBox[{"{", RowBox[{"0", ",", RowBox[{ RowBox[{"-", "0.95"}], "+", RowBox[{"(", RowBox[{ RowBox[{"1.9", "/", "numberImages"}], " ", RowBox[{"(", RowBox[{"i", "-", "1"}], ")"}]}], ")"}]}]}], "}"}]}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "numberImages"}], "}"}]}], "]"}]}]}], "]"}]}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"overexposureInputImage", "[", RowBox[{"inputImage_", ",", "numberImages_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"dimensions", ",", "i"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"dimensions", "=", RowBox[{"ImageDimensions", "[", "inputImage", "]"}]}], ";", RowBox[{"Table", "[", RowBox[{ RowBox[{"ImageClip", "[", RowBox[{"Image", "[", RowBox[{ RowBox[{"ImageData", "[", "inputImage", "]"}], "-", "0.5", "+", RowBox[{"(", RowBox[{ RowBox[{"1", "/", "numberImages"}], RowBox[{"(", RowBox[{"i", "-", "1"}], ")"}]}], ")"}]}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "numberImages"}], "}"}]}], "]"}]}]}], "]"}]}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"histogramInputImage", "[", RowBox[{"inputImage_", ",", "numberImages_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{ "pdf", ",", "const", ",", "i", ",", "function", ",", "lambda", ",", "cdffunc", ",", "histeq"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"pdf", "=", RowBox[{"BinCounts", "[", RowBox[{ RowBox[{"Flatten", "[", RowBox[{"ImageData", "[", "inputImage", "]"}], "]"}], ",", RowBox[{"{", RowBox[{"0", ",", "1", ",", "0.00025"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"const", "=", RowBox[{"ConstantArray", "[", RowBox[{ RowBox[{"Mean", "[", "pdf", "]"}], ",", RowBox[{"Length", "[", "pdf", "]"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Table", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"lambda", "=", " ", RowBox[{ RowBox[{"(", RowBox[{"i", "-", "1"}], ")"}], "/", RowBox[{"(", RowBox[{"numberImages", "-", "1"}], ")"}]}]}], ";", "\[IndentingNewLine]", RowBox[{"function", "=", RowBox[{ RowBox[{"lambda", " ", "pdf"}], "+", RowBox[{ RowBox[{"(", RowBox[{"1", "-", "lambda"}], ")"}], " ", "const"}]}]}], ";", "\[IndentingNewLine]", RowBox[{"cdffunc", "=", RowBox[{"ListInterpolation", "[", RowBox[{ RowBox[{"Rescale", "[", RowBox[{"Accumulate", "[", "function", "]"}], "]"}], ",", RowBox[{"{", RowBox[{"0", ",", "1"}], "}"}]}], "]"}]}], ";", "\n", " ", RowBox[{"histeq", "=", RowBox[{"Map", "[", RowBox[{"cdffunc", ",", RowBox[{"ImageData", "[", "inputImage", "]"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"Image", "[", "histeq", "]"}]}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "numberImages"}], "}"}]}], "]"}]}]}], "\[IndentingNewLine]", "]"}]}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"blurInputImage", "[", RowBox[{"inputImage_", ",", "numberImages_"}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{"dimensions", ",", "i"}], "}"}], ",", "\[IndentingNewLine]", RowBox[{ RowBox[{"dimensions", "=", RowBox[{"ImageDimensions", "[", "inputImage", "]"}]}], ";", RowBox[{"Table", "[", RowBox[{ RowBox[{"GaussianFilter", "[", RowBox[{"inputImage", ",", RowBox[{"0.5", " ", "i"}]}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "numberImages"}], "}"}]}], "]"}]}]}], "]"}]}]}], "Input", InitializationCell->True, CellChangeTimes->{{3.6188489490328393`*^9, 3.6188489635061245`*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["\<\ Plotting the sensitivity of classification methods to selected conditions\ \>", "Subsection", CellChangeTimes->{{3.6188494093419867`*^9, 3.618849441438792*^9}}], Cell["\<\ Below is a method of displaying the sensitivity of oum methods to selected \ conditions defined above. The whole procedure is described in the thesis in \ subsection 4.3 The only input parameter to this method is number of pictures \ each set will be consisting of. Based on this number, the calculation might \ take hours or even days.\ \>", "Text", CellChangeTimes->{{3.6188495554117813`*^9, 3.6188497661745963`*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{ RowBox[{"numberSteps", "=", "10"}], ";"}], "\[IndentingNewLine]", "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"functionNames", "=", RowBox[{"{", RowBox[{ "\"\\"", ",", "\"\\"", ",", "\"\\"", ",", "\"\\"", ",", "\"\\"", ",", "\"\\""}], "}"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"types", "=", RowBox[{"{", RowBox[{ "\"\\"", ",", "\"\\"", ",", "\"\\"", ",", "\"\\"", ",", "\"\\"", ",", " ", "\"\\"", ",", "\"\\"", ",", " ", "\"\\"", ",", " ", "\"\\"", ",", "\"\\"", ",", "\"\\""}], "}"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"names", "=", "13"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"means", "=", RowBox[{"ConstantArray", "[", RowBox[{"0", ",", RowBox[{"{", RowBox[{ RowBox[{"Length", "[", "functionNames", "]"}], ",", "13"}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"set", "=", RowBox[{"createSet", "[", "200", "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"set2", "=", RowBox[{"createSet", "[", "300", "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"m", "=", RowBox[{"ConstantArray", "[", RowBox[{"0", ",", RowBox[{"{", RowBox[{ RowBox[{"Length", "[", "functionNames", "]"}], ",", "numberSteps", ",", "13"}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"d", "=", RowBox[{"ConstantArray", "[", RowBox[{"0", ",", RowBox[{"{", RowBox[{ RowBox[{"Length", "[", "functionNames", "]"}], ",", "13"}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Table", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{ RowBox[{"m", "[", RowBox[{"[", RowBox[{"1", ",", "All", ",", "i"}], "]"}], "]"}], "=", RowBox[{"rotateInputImage", "[", RowBox[{ RowBox[{"set2", "[", RowBox[{"[", "i", "]"}], "]"}], ",", "numberSteps"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"m", "[", RowBox[{"[", RowBox[{"2", ",", "All", ",", "i"}], "]"}], "]"}], "=", RowBox[{"scaleInputImage", "[", RowBox[{ RowBox[{"set", "[", RowBox[{"[", "i", "]"}], "]"}], ",", "numberSteps"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"m", "[", RowBox[{"[", RowBox[{"3", ",", "All", ",", "i"}], "]"}], "]"}], "=", RowBox[{"brightnessInputImage", "[", RowBox[{ RowBox[{"set", "[", RowBox[{"[", "i", "]"}], "]"}], ",", "numberSteps"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"m", "[", RowBox[{"[", RowBox[{"4", ",", "All", ",", "i"}], "]"}], "]"}], "=", RowBox[{"overexposureInputImage", "[", RowBox[{ RowBox[{"set", "[", RowBox[{"[", "i", "]"}], "]"}], ",", "numberSteps"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"m", "[", RowBox[{"[", RowBox[{"5", ",", "All", ",", "i"}], "]"}], "]"}], "=", RowBox[{"blurInputImage", "[", RowBox[{ RowBox[{"set", "[", RowBox[{"[", "i", "]"}], "]"}], ",", "numberSteps"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{ RowBox[{"m", "[", RowBox[{"[", RowBox[{"6", ",", "All", ",", "i"}], "]"}], "]"}], "=", RowBox[{"histogramInputImage", "[", RowBox[{ RowBox[{"set", "[", RowBox[{"[", "i", "]"}], "]"}], ",", "numberSteps"}], "]"}]}], ";"}], "\[IndentingNewLine]", ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "13"}], "}"}]}], "]"}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{ RowBox[{ RowBox[{"d", "[", RowBox[{"[", RowBox[{"i", ",", "j"}], "]"}], "]"}], "=", RowBox[{"distances", "[", RowBox[{ RowBox[{"m", "[", RowBox[{"[", RowBox[{"i", ",", "All", ",", "j"}], "]"}], "]"}], ",", "sizeSVD", ",", "numPatches", ",", "patchSize"}], "]"}]}], ";"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "6"}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", "13"}], "}"}]}], "]"}], ";"}], "\[IndentingNewLine]", RowBox[{"Table", "[", RowBox[{ RowBox[{"Labeled", "[", RowBox[{ RowBox[{"ListLinePlot", "[", RowBox[{ RowBox[{"Table", "[", RowBox[{ RowBox[{"Mean", "[", RowBox[{"Table", "[", RowBox[{ RowBox[{"diagonalMean", "[", RowBox[{"d", "[", RowBox[{"[", RowBox[{"j", ",", "i", ",", "k"}], "]"}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "1", ",", "13"}], "}"}]}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"j", ",", "1", ",", "6"}], "}"}]}], "]"}], ",", RowBox[{"PlotRange", "\[Rule]", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{"0", ",", RowBox[{"2", "numberSteps"}]}], "}"}], ",", RowBox[{"{", RowBox[{"0", ",", "1"}], "}"}]}], "}"}]}], ",", RowBox[{"ImageSize", "\[Rule]", "400"}], ",", RowBox[{"PlotLegends", "\[Rule]", RowBox[{"{", RowBox[{ "\"\\"", ",", "\"\\"", ",", "\"\\"", ",", "\"\\"", ",", "\"\\"", ",", "\"\\""}], "}"}]}], ",", RowBox[{"PlotLabel", "\[Rule]", RowBox[{"types", "[", RowBox[{"[", "k", "]"}], "]"}]}]}], "]"}], ",", RowBox[{"{", RowBox[{ "\"\\"", ",", "\"\\""}], "}"}], ",", RowBox[{"{", RowBox[{"Bottom", ",", "Left"}], "}"}], ",", RowBox[{"RotateLabel", "\[Rule]", "True"}]}], "]"}], ",", RowBox[{"{", RowBox[{"k", ",", "1", ",", "11"}], "}"}]}], "]"}]}], "Input", CellChangeTimes->{{3.6180608160813847`*^9, 3.6180608555903487`*^9}, { 3.618060919294429*^9, 3.618060946730835*^9}, {3.6180611450411763`*^9, 3.618061152379384*^9}, 3.6180613966432457`*^9, {3.618061773041608*^9, 3.6180618664226937`*^9}, {3.618061951060601*^9, 3.6180619519312077`*^9}, { 3.6180622223225727`*^9, 3.61806226809897*^9}, {3.618062331181601*^9, 3.6180624300335565`*^9}, {3.618062484195899*^9, 3.6180625161815224`*^9}, { 3.6180625917450104`*^9, 3.6180627921878624`*^9}, {3.618063089046935*^9, 3.6180631634115615`*^9}, {3.6180632117237644`*^9, 3.618063338561514*^9}, { 3.6180644971324263`*^9, 3.618064520950282*^9}, {3.6180829538679*^9, 3.618082954508365*^9}, {3.6180829861127195`*^9, 3.6180829865260243`*^9}, { 3.6181349779475136`*^9, 3.6181349808825903`*^9}, 3.6181350223769608`*^9, { 3.618142329903985*^9, 3.6181423309126997`*^9}, {3.618688407798359*^9, 3.618688426848877*^9}, {3.6186884767493396`*^9, 3.618688477370782*^9}, { 3.6188494602011166`*^9, 3.6188495340646105`*^9}}] }, Open ]] }, Open ]] }, Open ]] }, WindowSize->{1902, 914}, WindowMargins->{{0, Automatic}, {Automatic, 0}}, ShowSelection->True, FrontEndVersion->"9.0 for Microsoft Windows (64-bit) (November 20, 2012)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[579, 22, 222, 6, 105, "Subtitle"], Cell[804, 30, 471, 8, 30, "Text"], Cell[CellGroupData[{ Cell[1300, 42, 199, 4, 79, "Section"], Cell[CellGroupData[{ Cell[1524, 50, 110, 1, 43, "Subsection"], Cell[1637, 53, 2274, 40, 171, "Text"], Cell[3914, 95, 14137, 357, 892, "Input", InitializationCell->True] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[18100, 458, 107, 1, 79, "Section"], Cell[CellGroupData[{ Cell[18232, 463, 211, 3, 43, "Subsection"], Cell[18446, 468, 362, 7, 30, "Text"], Cell[18811, 477, 2995, 86, 212, "Input", InitializationCell->True] }, Open ]], Cell[CellGroupData[{ Cell[21843, 568, 111, 1, 43, "Subsection"], Cell[21957, 571, 321, 5, 30, "Text"], Cell[22281, 578, 6611, 179, 272, "Input", InitializationCell->True], Cell[28895, 759, 178, 4, 30, "Text"], Cell[29076, 765, 3393, 94, 192, "Input", InitializationCell->True] }, Open ]], Cell[CellGroupData[{ Cell[32506, 864, 219, 4, 43, "Subsection"], Cell[32728, 870, 8691, 223, 492, "Input", InitializationCell->True] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[41468, 1099, 157, 2, 79, "Section"], Cell[41628, 1103, 1386, 26, 70, "Text"], Cell[43017, 1131, 14778, 353, 932, "Input", InitializationCell->True] }, Open ]], Cell[CellGroupData[{ Cell[57832, 1489, 115, 1, 79, "Section"], Cell[57950, 1492, 1600, 31, 70, "Text"], Cell[59553, 1525, 20264, 476, 1592, "Input", InitializationCell->True], Cell[CellGroupData[{ Cell[79842, 2005, 154, 3, 43, "Subsection"], Cell[79999, 2010, 404, 10, 33, "Text"], Cell[80406, 2022, 7487, 195, 572, "Input", InitializationCell->True], Cell[87896, 2219, 742, 15, 52, "Text"], Cell[88641, 2236, 403, 11, 52, "Input"], Cell[89047, 2249, 10618, 258, 672, "Input"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[99714, 2513, 128, 3, 79, "Section"], Cell[CellGroupData[{ Cell[99867, 2520, 140, 3, 43, "Subsection"], Cell[100010, 2525, 1268, 25, 110, "Text"], Cell[101281, 2552, 369, 10, 92, "Input", InitializationCell->True], Cell[101653, 2564, 348, 10, 33, "Text"], Cell[102004, 2576, 283, 8, 31, "Input"], Cell[102290, 2586, 365, 6, 30, "Text"], Cell[102658, 2594, 286, 8, 52, "Input"], Cell[102947, 2604, 112, 1, 30, "Text"], Cell[103062, 2607, 283, 8, 31, "Input"], Cell[103348, 2617, 244, 7, 52, "Input", InitializationCell->True], Cell[103595, 2626, 190, 4, 30, "Text"], Cell[103788, 2632, 515, 11, 52, "Input"], Cell[104306, 2645, 408, 7, 30, "Text"], Cell[104717, 2654, 395, 9, 52, "Input"], Cell[105115, 2665, 452, 7, 30, "Text"], Cell[105570, 2674, 2474, 64, 92, "Input"], Cell[108047, 2740, 2609, 63, 92, "Input"], Cell[110659, 2805, 3916, 103, 132, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[114612, 2913, 200, 4, 43, "Subsection"], Cell[114815, 2919, 732, 12, 49, "Text"], Cell[115550, 2933, 13675, 340, 652, "Input"], Cell[129228, 3275, 177, 4, 30, "Text"], Cell[129408, 3281, 9034, 207, 312, "Input"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[138491, 3494, 230, 5, 79, "Section"], Cell[138724, 3501, 352, 6, 30, "Text"], Cell[CellGroupData[{ Cell[139101, 3511, 255, 3, 43, "Subsection"], Cell[139359, 3516, 2579, 58, 72, "Input", InitializationCell->True] }, Open ]], Cell[CellGroupData[{ Cell[141975, 3579, 110, 1, 43, "Subsection"], Cell[142088, 3582, 4591, 109, 132, "Input", InitializationCell->True] }, Open ]], Cell[CellGroupData[{ Cell[146716, 3696, 93, 1, 43, "Subsection"], Cell[146812, 3699, 3132, 72, 112, "Input", InitializationCell->True] }, Open ]], Cell[CellGroupData[{ Cell[149981, 3776, 106, 1, 43, "Subsection"], Cell[150090, 3779, 3145, 79, 72, "Input", InitializationCell->True] }, Open ]], Cell[CellGroupData[{ Cell[153272, 3863, 158, 2, 43, "Subsection"], Cell[153433, 3867, 3586, 92, 92, "Input", InitializationCell->True] }, Open ]], Cell[CellGroupData[{ Cell[157056, 3964, 118, 1, 43, "Subsection"], Cell[157177, 3967, 4016, 91, 112, "Input", InitializationCell->True] }, Open ]], Cell[CellGroupData[{ Cell[161230, 4063, 117, 1, 43, "Subsection"], Cell[161350, 4066, 4328, 99, 132, "Input", InitializationCell->True] }, Open ]], Cell[CellGroupData[{ Cell[165715, 4170, 114, 1, 43, "Subsection"], Cell[165832, 4173, 3395, 82, 112, "Input", InitializationCell->True] }, Open ]], Cell[CellGroupData[{ Cell[169264, 4260, 127, 1, 43, "Subsection"], Cell[169394, 4263, 5384, 137, 212, "Input", InitializationCell->True] }, Open ]], Cell[CellGroupData[{ Cell[174815, 4405, 149, 1, 43, "Subsection"], Cell[174967, 4408, 2866, 68, 152, "Input", InitializationCell->True] }, Open ]], Cell[CellGroupData[{ Cell[177870, 4481, 157, 2, 43, "Subsection"], Cell[178030, 4485, 3350, 72, 72, "Input", InitializationCell->True] }, Open ]], Cell[CellGroupData[{ Cell[181417, 4562, 215, 3, 43, "Subsection"], Cell[181635, 4567, 3583, 78, 72, "Input", InitializationCell->True] }, Open ]], Cell[CellGroupData[{ Cell[185255, 4650, 113, 1, 43, "Subsection"], Cell[185371, 4653, 2907, 70, 72, "Input", InitializationCell->True] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[188327, 4729, 131, 3, 79, "Section"], Cell[188461, 4734, 235, 4, 30, "Text"], Cell[188699, 4740, 206, 6, 52, "Input", InitializationCell->True], Cell[188908, 4748, 4614, 97, 272, "Input", InitializationCell->True] }, Open ]], Cell[CellGroupData[{ Cell[193559, 4850, 222, 4, 79, "Section"], Cell[CellGroupData[{ Cell[193806, 4858, 112, 1, 43, "Subsection"], Cell[193921, 4861, 959, 16, 128, "Text"], Cell[194883, 4879, 20986, 542, 1112, "Input", InitializationCell->True] }, Open ]], Cell[CellGroupData[{ Cell[215906, 5426, 171, 3, 43, "Subsection"], Cell[216080, 5431, 430, 7, 49, "Text"], Cell[216513, 5440, 7698, 198, 492, "Input"] }, Open ]] }, Open ]] }, Open ]] } ] *) (* End of internal cache information *)