(* Content-type: application/mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 6.0' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 145, 7] NotebookDataLength[ 17670, 426] NotebookOptionsPosition[ 17188, 406] NotebookOutlinePosition[ 17534, 421] CellTagsIndexPosition[ 17491, 418] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell["\<\ The first entry serves to set the directory to the folder that contains the \ images on which you wish to \"play\". This is also the folder to which \ movies will be exported. The command specifications will change from machine \ to machine, user to user, so find the correct path for your situation. Also, \ the code reflects the way that the Unix-based operating system on my Mac \ deals with the pathway, using \"/\" to differentiate between folder names. \ On PC's, you may need to use \":\" instead. You will only need to enter this \ set of commands once per session.\ \>", "Text", CellChangeTimes->{{3.432287507154348*^9, 3.432287677392601*^9}, { 3.432289466082067*^9, 3.432289525351747*^9}, {3.432290063021639*^9, 3.432290082205223*^9}}], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"SetDirectory", "[", "\"\\"", "]"}]], "Input", CellChangeTimes->{ 3.392721922227129*^9, {3.392735373415298*^9, 3.392735374896103*^9}, { 3.394413082654017*^9, 3.394413088952065*^9}, {3.431905924706287*^9, 3.431905944609438*^9}, {3.441457000985279*^9, 3.44145700606907*^9}, { 3.441460335643136*^9, 3.441460337393918*^9}, 3.457730953515625*^9}], Cell[BoxData["\<\"C:\\\\Documents and Settings\\\\KAMS \ Student\\\\Desktop\\\\Banff Talk\"\>"], "Output", CellChangeTimes->{ 3.3944131061778593`*^9, 3.394433306806179*^9, 3.394443040950466*^9, 3.431905953833497*^9, 3.4319351830356503`*^9, 3.431937760692987*^9, 3.431938142810536*^9, 3.431962804350463*^9, 3.432291728489805*^9, 3.4323909673506327`*^9, 3.441457012254327*^9, {3.441460338552891*^9, 3.4414603578010197`*^9}, 3.441486269595726*^9, 3.45773127859375*^9, 3.457731383921875*^9, 3.457732141578125*^9, 3.457732778296875*^9, 3.45773345575*^9, 3.4577342781875*^9, 3.45773441221875*^9, 3.457735682109375*^9, 3.457736661125*^9, 3.457746027234375*^9, 3.45774925621875*^9, 3.4577499048125*^9, 3.457750581015625*^9, 3.457750964875*^9, 3.457751497234375*^9, 3.45775208784375*^9, 3.4577523408125*^9, 3.457752596375*^9, 3.4577530198125*^9, 3.4577532640625*^9, 3.4577703786875*^9, 3.457770716875*^9, 3.457771080265625*^9, 3.457771554984375*^9, 3.457772590453125*^9, 3.4578690784375*^9}] }, Open ]], Cell[TextData[{ "The following set of commands generates a table of images of the same basic \ size as the original, with the inverse of a matrix transformation applied to \ the center of each pixel ", StyleBox["n", FontSlant->"Italic"], " times, generating a list of graphics that can be exported as an .avi \ movie. The user can determine the original image that is input, the matrix \ that is used, and the number of times ", StyleBox["n", FontSlant->"Italic"], " that the matrix is applied." }], "Text", CellChangeTimes->{{3.432289544245453*^9, 3.432289556862978*^9}, { 3.432289677196247*^9, 3.432289876211731*^9}, {3.432294944859445*^9, 3.432294957933152*^9}}], Cell[BoxData[ RowBox[{ RowBox[{"(*", " ", RowBox[{ "The", " ", "following", " ", "command", " ", "inputs", " ", "the", " ", "image", " ", RowBox[{"file", ".", " ", "You"}], " ", "supply", " ", "the", " ", "file", " ", RowBox[{"name", "."}]}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"temp", "=", RowBox[{"Import", "[", "\"\\"", "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"colors", "=", FractionBox[ RowBox[{"temp", "[", RowBox[{"[", "1", "]"}], "]"}], "255."]}], ";"}], " ", RowBox[{"(*", " ", RowBox[{ "Scales", " ", "the", " ", "RGB", " ", "values", " ", "for", " ", RowBox[{"Mathematica", "."}]}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"{", RowBox[{"rows", ",", "cols", ",", "check"}], "}"}], "=", RowBox[{"Dimensions", "[", "colors", "]"}]}], ";"}], " ", RowBox[{"(*", RowBox[{"Sets", " ", "the", " ", RowBox[{"dimensions", "."}]}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"countermax", "=", RowBox[{"Max", "[", RowBox[{"rows", ",", "cols"}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"rmax", "=", FractionBox["rows", "2."]}], ";", RowBox[{"cmax", "=", FractionBox["cols", "2."]}], ";", RowBox[{"max", "=", RowBox[{"Max", "[", RowBox[{"rmax", ",", "cmax"}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"centers", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"-", "max"}], "+", "j", "-", ".5"}], ",", RowBox[{ RowBox[{"-", "max"}], "+", "i", "-", ".5"}]}], "}"}], ",", RowBox[{"{", RowBox[{"i", ",", "countermax"}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", "countermax"}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ "The", " ", "following", " ", "command", " ", "inputs", " ", "the", " ", "matrix", " ", "that", " ", "will", " ", "be", " ", "used", " ", "to", " ", "generate", " ", "the", " ", RowBox[{"graphics", ".", " ", "The"}], " ", "inverse", " ", "of", " ", "the", " ", "matrix", " ", "is", " ", "drawn", " ", "into", " ", "the", " ", "function", " ", RowBox[{"\"\\"", "."}]}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"matrix", "[", RowBox[{"x_", ",", "y_"}], "]"}], ":=", RowBox[{"{", RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"Cos", "[", RowBox[{ RowBox[{"(", FractionBox[ SqrtBox[ RowBox[{ SuperscriptBox["x", "2"], "+", SuperscriptBox["y", "2"]}]], "25"], ")"}], "\[Degree]"}], "]"}], ",", RowBox[{"Sin", "[", RowBox[{ RowBox[{"(", RowBox[{"(", FractionBox[ SqrtBox[ RowBox[{ SuperscriptBox["x", "2"], "+", SuperscriptBox["y", "2"]}]], "25"], ")"}], ")"}], "\[Degree]"}], "]"}]}], "}"}], ",", RowBox[{"{", RowBox[{ RowBox[{"-", RowBox[{"Sin", "[", RowBox[{ RowBox[{"(", RowBox[{"(", FractionBox[ SqrtBox[ RowBox[{ SuperscriptBox["x", "2"], "+", SuperscriptBox["y", "2"]}]], "25"], ")"}], ")"}], "\[Degree]"}], "]"}]}], " ", ",", RowBox[{"Cos", "[", RowBox[{ RowBox[{"(", RowBox[{"(", FractionBox[ SqrtBox[ RowBox[{ SuperscriptBox["x", "2"], "+", SuperscriptBox["y", "2"]}]], "25"], ")"}], ")"}], "\[Degree]"}], "]"}]}], "}"}]}], "}"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"imat", "[", RowBox[{"x_", ",", "y_"}], "]"}], "=", RowBox[{"Inverse", "[", RowBox[{"matrix", "[", RowBox[{"x", ",", "y"}], "]"}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"f", "[", RowBox[{"{", RowBox[{"x_", ",", "y_"}], "}"}], "]"}], ":=", RowBox[{ RowBox[{"imat", "[", RowBox[{"x", ",", "y"}], "]"}], ".", RowBox[{"{", RowBox[{"x", ",", "y"}], "}"}]}]}], ";"}], "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ RowBox[{ "The", " ", "following", " ", "two", " ", "commands", " ", "put", " ", "the", " ", "original", " ", "picture", " ", "into", " ", "the", " ", "list", " ", "of", " ", "frames"}], ",", " ", RowBox[{"as", " ", "the", " ", "initial", " ", RowBox[{"frame", "."}]}]}], " ", "*)"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"newcolors", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"1", "\[LessEqual]", RowBox[{"Floor", "[", RowBox[{ RowBox[{"centers", "[", RowBox[{"[", RowBox[{"i", ",", "j", ",", "1"}], "]"}], "]"}], "+", "cmax", "+", ".50000001"}], "]"}], "\[LessEqual]", "cols"}], " ", "&&", " ", RowBox[{"1", "\[LessEqual]", RowBox[{"Floor", "[", RowBox[{ RowBox[{"centers", "[", RowBox[{"[", RowBox[{"i", ",", "j", ",", "2"}], "]"}], "]"}], "+", "rmax", "+", ".50000001"}], "]"}], "\[LessEqual]", "rows"}]}], ",", RowBox[{"colors", "[", RowBox[{"[", RowBox[{ RowBox[{"Floor", "[", RowBox[{ RowBox[{"centers", "[", RowBox[{"[", RowBox[{"i", ",", "j", ",", "2"}], "]"}], "]"}], "+", "rmax", "+", ".50000001"}], "]"}], ",", RowBox[{"Floor", "[", RowBox[{ RowBox[{"centers", "[", RowBox[{"[", RowBox[{"i", ",", "j", ",", "1"}], "]"}], "]"}], "+", "cmax", "+", ".50000001"}], "]"}]}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"1.", ",", "1.", ",", "1."}], "}"}]}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "countermax"}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", "countermax"}], "}"}]}], "]"}]}], ";"}], "\n", RowBox[{ RowBox[{"frames", "=", RowBox[{"{", RowBox[{"Image", "[", "newcolors", "]"}], "}"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Print", "[", "\"\<0\>\"", "]"}], ";"}], "\[IndentingNewLine]", RowBox[{"(*", " ", RowBox[{ RowBox[{"The", " ", "following", " ", "do"}], "-", RowBox[{ "loop", " ", "generates", " ", "the", " ", "frames", " ", "for", " ", "the", " ", RowBox[{"animation", ".", " ", "You"}], " ", "specify", " ", "how", " ", "many", " ", "frames", " ", "past", " ", "the", " ", "original", " ", "that", " ", "are", " ", "generated", " ", "by", " ", "changing", " ", "the", " ", "value", " ", "after", " ", "\"\\"", " ", "in", " ", "the", " ", "last", " ", RowBox[{"line", ".", " ", "The"}], " ", "command", " ", "\"\\"", " ", "maps", " ", "\"\\"", " ", "onto", " ", "all", " ", "of", " ", "the", " ", "pixel", " ", RowBox[{"centers", "."}]}]}], " ", "*)"}], "\n", RowBox[{"Do", "[", RowBox[{ RowBox[{"(", "\[IndentingNewLine]", RowBox[{ RowBox[{"centers", "=", RowBox[{"Map", "[", RowBox[{"f", ",", "centers", ",", RowBox[{"{", "2", "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"newcolors", "=", RowBox[{"Table", "[", RowBox[{ RowBox[{"If", "[", RowBox[{ RowBox[{ RowBox[{"1", "\[LessEqual]", RowBox[{"Floor", "[", RowBox[{ RowBox[{"centers", "[", RowBox[{"[", RowBox[{"i", ",", "j", ",", "1"}], "]"}], "]"}], "+", "cmax", "+", ".50000001"}], "]"}], "\[LessEqual]", "cols"}], " ", "&&", " ", RowBox[{"1", "\[LessEqual]", RowBox[{"Floor", "[", RowBox[{ RowBox[{"centers", "[", RowBox[{"[", RowBox[{"i", ",", "j", ",", "2"}], "]"}], "]"}], "+", "rmax", "+", ".50000001"}], "]"}], "\[LessEqual]", "rows"}]}], ",", RowBox[{"colors", "[", RowBox[{"[", RowBox[{ RowBox[{"Floor", "[", RowBox[{ RowBox[{"centers", "[", RowBox[{"[", RowBox[{"i", ",", "j", ",", "2"}], "]"}], "]"}], "+", "rmax", "+", ".50000001"}], "]"}], ",", RowBox[{"Floor", "[", RowBox[{ RowBox[{"centers", "[", RowBox[{"[", RowBox[{"i", ",", "j", ",", "1"}], "]"}], "]"}], "+", "cmax", "+", ".50000001"}], "]"}]}], "]"}], "]"}], ",", RowBox[{"{", RowBox[{"1.", ",", "1.", ",", "1."}], "}"}]}], "]"}], ",", RowBox[{"{", RowBox[{"i", ",", "countermax"}], "}"}], ",", RowBox[{"{", RowBox[{"j", ",", "countermax"}], "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"AppendTo", "[", RowBox[{"frames", ",", RowBox[{"Image", "[", "newcolors", "]"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"Print", "[", "n", "]"}], ";"}], "\[IndentingNewLine]", ")"}], ",", RowBox[{"{", RowBox[{"n", ",", "100"}], "}"}]}], "]"}]}]}]], "Input", CellChangeTimes->{{3.431936317415556*^9, 3.43193636865625*^9}, { 3.431936404893033*^9, 3.431936473506255*^9}, {3.431936542340912*^9, 3.431936558629945*^9}, {3.431936591032587*^9, 3.431936617019826*^9}, { 3.431936670044957*^9, 3.431936747615903*^9}, {3.431937824748437*^9, 3.431937825797295*^9}, {3.4322896216066513`*^9, 3.432289657605424*^9}, { 3.432289896157895*^9, 3.432290029959999*^9}, {3.432290158495302*^9, 3.432290192348386*^9}, {3.432291509195903*^9, 3.432291515500259*^9}, { 3.432291547557032*^9, 3.4322916858844633`*^9}, 3.432291723511078*^9, { 3.432291771831841*^9, 3.4322918111905737`*^9}, 3.432291847178153*^9, { 3.432292431755724*^9, 3.4322924853621483`*^9}, {3.432292750281657*^9, 3.432292780838387*^9}, {3.432292845809155*^9, 3.432292883070293*^9}, { 3.4322948358383503`*^9, 3.43229485043886*^9}, {3.432297183093547*^9, 3.432297202464058*^9}, {3.43229786711292*^9, 3.432297909309589*^9}, 3.432391146739993*^9, 3.4414602747067127`*^9, 3.441486419222228*^9, { 3.441486484304759*^9, 3.44148648444156*^9}, {3.4417996073394527`*^9, 3.441799610218257*^9}, {3.457696718176466*^9, 3.45769674167272*^9}, { 3.4576967990529547`*^9, 3.457696820547875*^9}, {3.457730970375*^9, 3.45773100671875*^9}, {3.457731099234375*^9, 3.457731240515625*^9}, { 3.457731301140625*^9, 3.4577313018125*^9}, {3.4577313520625*^9, 3.45773136490625*^9}, {3.45773141040625*^9, 3.45773142153125*^9}, { 3.45773212690625*^9, 3.45773213196875*^9}, {3.457732692734375*^9, 3.457732705828125*^9}, {3.457732783921875*^9, 3.457732784015625*^9}, { 3.4577340385*^9, 3.4577340433125*^9}, {3.457734287546875*^9, 3.457734304609375*^9}, {3.45773438309375*^9, 3.45773439696875*^9}, { 3.45773619421875*^9, 3.4577361994375*^9}, {3.457736591984375*^9, 3.457736602625*^9}, 3.457739332828125*^9, 3.457745901875*^9, { 3.457746013390625*^9, 3.457746013796875*^9}, {3.457746054765625*^9, 3.4577460625625*^9}, {3.457746305828125*^9, 3.45774632296875*^9}, { 3.4577491493125*^9, 3.457749248234375*^9}, {3.45774985878125*^9, 3.4577498946875*^9}, {3.457750329484375*^9, 3.457750342203125*^9}, { 3.45775050178125*^9, 3.457750523875*^9}, {3.4577505545625*^9, 3.4577505746875*^9}, {3.45775090428125*^9, 3.4577509505625*^9}, { 3.4577514635*^9, 3.45775153353125*^9}, {3.4577516005*^9, 3.457751607375*^9}, {3.45775167590625*^9, 3.45775167853125*^9}, { 3.4577517845625*^9, 3.4577518145*^9}, {3.457751865765625*^9, 3.45775187071875*^9}, {3.45775195596875*^9, 3.457751959359375*^9}, { 3.45775203121875*^9, 3.457752076640625*^9}, {3.457752308640625*^9, 3.457752327546875*^9}, {3.457752434609375*^9, 3.45775259028125*^9}, { 3.4577527653125*^9, 3.457752778125*^9}, {3.457752988703125*^9, 3.457752996171875*^9}, {3.4577532035625*^9, 3.457753250359375*^9}, { 3.4577703006875*^9, 3.457770367953125*^9}, {3.457770631125*^9, 3.457770706765625*^9}, {3.457771050140625*^9, 3.457771069546875*^9}, { 3.45777144434375*^9, 3.457771458625*^9}, {3.457771500859375*^9, 3.457771542046875*^9}, {3.457771855171875*^9, 3.457771891359375*^9}, { 3.457772209796875*^9, 3.4577722125625*^9}, {3.45777257125*^9, 3.457772578640625*^9}, {3.45786902878125*^9, 3.457869067625*^9}, { 3.457869340015625*^9, 3.457869340421875*^9}, {3.457869776234375*^9, 3.45786977646875*^9}}], Cell[BoxData[ RowBox[{"Export", "[", RowBox[{"\"\\"", ",", "frames"}], "]"}]], "Input", CellChangeTimes->{{3.457869189296875*^9, 3.45786920184375*^9}, { 3.457869336296875*^9, 3.4578693374375*^9}}] }, WindowSize->{951, 617}, WindowMargins->{{101, Automatic}, {Automatic, 23}}, FrontEndVersion->"7.0 for Microsoft Windows (32-bit) (November 10, 2008)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[545, 20, 766, 12, 83, "Text"], Cell[CellGroupData[{ Cell[1336, 36, 454, 8, 31, "Input"], Cell[1793, 46, 1037, 16, 30, "Output"] }, Open ]], Cell[2845, 65, 681, 15, 65, "Text"], Cell[3529, 82, 13433, 316, 703, "Input"], Cell[16965, 400, 219, 4, 31, "Input"] } ] *) (* End of internal cache information *)