(* 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[ 28250, 920] NotebookOptionsPosition[ 23645, 773] NotebookOutlinePosition[ 24064, 789] CellTagsIndexPosition[ 24021, 786] WindowFrame->Normal ContainsDynamic->False*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell["Digital Images ", "Title"], Cell["\<\ Wavelet Workshop June 2 - 5, 2009 University of South Florida\ \>", "Subtitle"], Cell["\<\ Catherine Beneteau Caroline Haddad David Ruch Patrick Van Fleet\ \>", "Subsubtitle", CellChangeTimes->{{3.42144927371875*^9, 3.42144928703125*^9}}], Cell[CellGroupData[{ Cell["Overview", "Section", CellChangeTimes->{{3.421428159890625*^9, 3.421428161*^9}}], Cell[CellGroupData[{ Cell["Objectives", "Subsection"], Cell["\<\ The purpose of this notebook is to give you a brief introduction to the \ software package DiscreteWavelets and show you how to use it to load images. \ Some basic image manipulation is illustrated as well. \ \>", "Text", CellChangeTimes->{{3.421456620265625*^9, 3.421456650625*^9}, 3.4523426821096163`*^9}] }, Open ]], Cell[CellGroupData[{ Cell["DiscreteWavelets", "Subsection"], Cell[TextData[{ "You should run this cell each time you open this notebook!! It loads the \ ", StyleBox["Mathematica", FontSlant->"Italic"], " package DiscreteWavelets for use in subsequent computations." }], "Text", CellChangeTimes->{{3.421429438203125*^9, 3.421429441265625*^9}}], Cell[BoxData[ RowBox[{"<<", "DiscreteWavelets`DiscreteWavelets`"}]], "Input", CellChangeTimes->{{3.421448451359375*^9, 3.42144845165625*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["Help on DiscreteWavelets", "Subsection"], Cell["\<\ If you ever need help with DiscreteWavelets, go to Help, then Documentation \ Center. On the bottom right, you will find a link for Installed Add-Ons. \ Click this link and then the link to DiscreteWavelets to access \ documentation, examples, and applications of the software package.\ \>", "Text", CellChangeTimes->{{3.42142653203125*^9, 3.421426604453125*^9}}] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Image Basics", "Section", CellChangeTimes->{{3.421428254109375*^9, 3.421428255890625*^9}}], Cell[CellGroupData[{ Cell["Digital Images in the Package", "Subsection"], Cell["\<\ The DiscreteWavelets package comes with 18 grayscale images and 9 color \ images for you to use. There are three functions available to tell you more \ about these images. \ \>", "Text", CellChangeTimes->{{3.421426678765625*^9, 3.421426688421875*^9}}], Cell[CellGroupData[{ Cell["ImageList", "Subsubsection", CellChangeTimes->{{3.4214266908125*^9, 3.421426693453125*^9}}], Cell[TextData[{ "The first function is called ", StyleBox["ImageList", FontWeight->"Bold"], ". This function can tell you the names and sizes of the digital images in \ the package. Click the cells below to see how to use ", StyleBox["ImageList", FontWeight->"Bold"], "." }], "Text", CellChangeTimes->{{3.421426678765625*^9, 3.421426688421875*^9}}], Cell[BoxData[ RowBox[{"ImageList", "[", RowBox[{"ImageType", "\[Rule]", "GrayScale"}], "]"}]], "Input", CellChangeTimes->{{3.421430850546875*^9, 3.421430850765625*^9}}], Cell[BoxData[ RowBox[{"ImageList", "[", RowBox[{"ImageType", "\[Rule]", "Color"}], "]"}]], "Input", CellChangeTimes->{{3.4214308521875*^9, 3.42143085234375*^9}}], Cell[BoxData[ RowBox[{"ImageList", "[", "]"}]], "Input", CellChangeTimes->{{3.421430853921875*^9, 3.4214308540625*^9}}], Cell[TextData[{ "Clicking on ", StyleBox["Kernel", FontWeight->"Bold"], " then ", StyleBox["Delete All Output", FontWeight->"Bold"], " will remove output from this notebook." }], "Text", CellChangeTimes->{3.4214267046875*^9, 3.42142674603125*^9}] }, Open ]], Cell[CellGroupData[{ Cell["ImageNames", "Subsubsection", CellChangeTimes->{{3.42142670821875*^9, 3.421426709671875*^9}}], Cell[TextData[{ "Another useful function is ", StyleBox["ImageNames", FontWeight->"Bold"], ". This function returns a list of absolute path names to each image. \ Since the package can be installed in multiple locations, this functions \ takes the work out of locating the images." }], "Text", CellChangeTimes->{{3.4214267046875*^9, 3.421426718421875*^9}}], Cell[BoxData[ RowBox[{"color", " ", "=", " ", RowBox[{"ImageNames", "[", RowBox[{"ImageType", "\[Rule]", "Color"}], "]"}]}]], "Input"], Cell[TextData[{ "\nYou'll notice a list of 9 path/file names. If you want to use ", StyleBox["building.png", FontWeight->"Bold"], " in an application (the second name in the list), you simply use \ color[[2]].", "\n\n", "From ", StyleBox["ImageList", FontWeight->"Bold"], ", you probably noticed that the images were quite large. Sometimes it's \ handy to work with smaller images. If you set the directive ", StyleBox["ListThumbnails", FontWeight->"Bold"], " to ", StyleBox["True", FontWeight->"Bold"], ", then the file names returned are those of the thumbnails.\n" }], "Text", CellChangeTimes->{{3.4214269214375*^9, 3.421426938828125*^9}}], Cell[BoxData[ RowBox[{"ImageNames", "[", RowBox[{ RowBox[{"ImageType", "\[Rule]", "Color"}], ",", RowBox[{"ListThumbnails", "\[Rule]", "True"}]}], "]"}]], "Input", CellChangeTimes->{{3.421430857171875*^9, 3.421430857890625*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["ShowThumbnails", "Subsubsection", CellChangeTimes->{{3.421426779203125*^9, 3.4214267818125*^9}}], Cell[TextData[{ "If you wish to view thumbnails of all images included in the package, use \ the ", StyleBox["ShowThumbnails", FontWeight->"Bold"], " command. You can specify the ", StyleBox["ImageType", FontWeight->"Bold"], " as either ", StyleBox["GrayScale", FontWeight->"Bold"], " or ", StyleBox["Color", FontWeight->"Bold"], ". If no image type is given the function shows thumbnails of all included \ images." }], "Text", CellChangeTimes->{{3.421426787890625*^9, 3.4214268661875*^9}}], Cell[BoxData[ RowBox[{"ShowThumbnails", "[", RowBox[{"ImageType", "\[Rule]", "GrayScale"}], "]"}]], "Input", CellChangeTimes->{{3.421426884046875*^9, 3.42142689428125*^9}, { 3.421430859578125*^9, 3.421430860078125*^9}}], Cell[BoxData[ RowBox[{"ShowThumbnails", "[", RowBox[{"ImageType", "\[Rule]", "Color"}], "]"}]], "Input", CellChangeTimes->{{3.42142696096875*^9, 3.42142696165625*^9}, { 3.4214308620625*^9, 3.421430862390625*^9}}], Cell[BoxData[ RowBox[{"ShowThumbnails", "[", "]"}]], "Input", CellChangeTimes->{3.421426952359375*^9}] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Loading a Digital Image", "Subsection"], Cell[TextData[{ StyleBox["DiscreteWavelets", FontWeight->"Bold"], " comes with a command called ", StyleBox["ImageRead", FontWeight->"Bold"], ". This command essentially needs one argument - the location, either on a \ computer or on the internet, of a digital image. In the case of a grayscale \ image, ", StyleBox["ImageRead", FontWeight->"Bold"], " returns a matrix (named A in the commands below) containing the gray scale \ intensity values for each pixel. \n\nHere are some examples." }], "Text", CellChangeTimes->{{3.4214269689375*^9, 3.421426970390625*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{"gray", "=", RowBox[{"ImageNames", "[", RowBox[{"ImageType", "\[Rule]", "GrayScale"}], "]"}]}], ";"}], "\n", RowBox[{ RowBox[{"A", "=", RowBox[{"ImageRead", "[", RowBox[{"gray", "[", RowBox[{"[", "1", "]"}], "]"}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"Print", "[", RowBox[{"\"\\"", ",", RowBox[{"Dimensions", "[", "A", "]"}]}], "]"}], ";"}]}], "Input", CellChangeTimes->{{3.421430865671875*^9, 3.421430865953125*^9}}], Cell["Here is the first row of A:", "Text"], Cell[BoxData[ RowBox[{"A", "[", RowBox[{"[", "1", "]"}], "]"}]], "Input", CellChangeTimes->{{3.421430870328125*^9, 3.42143087059375*^9}}], Cell["Here is the 100th row of A:", "Text"], Cell[BoxData[ RowBox[{"A", "[", RowBox[{"[", "100", "]"}], "]"}]], "Input", CellChangeTimes->{{3.421430872390625*^9, 3.4214308725625*^9}}], Cell["Here is the 100th column of A:", "Text"], Cell[BoxData[ RowBox[{ RowBox[{"Transpose", "[", "A", "]"}], "[", RowBox[{"[", "100", "]"}], "]"}]], "Input", CellChangeTimes->{{3.421430874703125*^9, 3.421430874875*^9}}], Cell[TextData[{ "There are two additional directives for ", StyleBox["ImageRead", FontWeight->"Bold"], ". The first is called ", StyleBox["PrintInfo", FontWeight->"Bold"], " and if set to ", StyleBox["True", FontWeight->"Bold"], ", will give you the dimensions and type (grayscale, color) of image you \ have read. The ", StyleBox["PowersOfTwo", FontWeight->"Bold"], " option, if set (say to K) will chop off enough rows on the bottom and \ columns on the left to make the dimensions of the image divisible by ", Cell[BoxData[ SuperscriptBox["2", "K"]]], ". This is really handy when students pull their own images off the web and \ we need the dimensions to be divisible by ", Cell[BoxData[ SuperscriptBox["2", "K"]]], "." }], "Text"], Cell[BoxData[{ RowBox[{ RowBox[{ RowBox[{"{", RowBox[{"gray", ",", "color"}], "}"}], "=", RowBox[{"ImageNames", "[", RowBox[{ RowBox[{"ImageType", "\[Rule]", "All"}], ",", RowBox[{"ListThumbnails", "\[Rule]", "True"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"A", "=", RowBox[{"ImageRead", "[", RowBox[{ RowBox[{"gray", "[", RowBox[{"[", "2", "]"}], "]"}], ",", RowBox[{"PrintInfo", "\[Rule]", "True"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"B", "=", RowBox[{"ImageRead", "[", RowBox[{ RowBox[{"color", "[", RowBox[{"[", "3", "]"}], "]"}], ",", RowBox[{"PrintInfo", "\[Rule]", "True"}]}], "]"}]}], ";"}]}], "Input", CellChangeTimes->{{3.42143087721875*^9, 3.42143087740625*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{"A", "=", RowBox[{"ImageRead", "[", RowBox[{ RowBox[{"gray", "[", RowBox[{"[", "3", "]"}], "]"}], ",", RowBox[{"PrintInfo", "\[Rule]", "True"}], ",", RowBox[{"PowersOfTwo", "\[Rule]", "6"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{"Print", "[", RowBox[{"\"\\"", ",", RowBox[{"Dimensions", "[", "A", "]"}], ",", "\"\<.\>\""}], "]"}]}], "Input",\ CellChangeTimes->{{3.421430880046875*^9, 3.421430881640625*^9}}], Cell["\<\ Note that B was processed as a color image. This means that B returned three \ matrices - the first matrix is the red portion of the image (with values 0 to \ 255), the second matrix is the green portion of the image, and the third \ matrix is the blue portion of the image. Notation-wise, we have the matrices B[[ 1 ]] (red), B[[ 2 ]] (green), and B[[ \ 3 ]] (blue), but it might be easier to make the call as follows:\ \>", "Text", CellChangeTimes->{{3.42145836678125*^9, 3.42145837171875*^9}}], Cell[BoxData[ RowBox[{ RowBox[{ RowBox[{"{", RowBox[{"red", ",", "green", ",", "blue"}], "}"}], " ", "=", RowBox[{"ImageRead", "[", RowBox[{ RowBox[{"color", "[", RowBox[{"[", "3", "]"}], "]"}], ",", RowBox[{"PrintInfo", "\[Rule]", "True"}]}], "]"}]}], ";"}]], "Input", CellChangeTimes->{{3.421430884578125*^9, 3.42143088515625*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["Plotting a Digital Image", "Subsection"], Cell[TextData[{ "It is easy to plot digital images read with ", StyleBox["ImageRead", FontWeight->"Bold"], " in Mathematica. The command is called ", StyleBox["ImagePlot", FontWeight->"Bold"], ". \n\nOnce you have an image loaded via ", StyleBox["ImageRead", FontWeight->"Bold"], ", here's what you can do:" }], "Text"], Cell[BoxData[ RowBox[{"ImagePlot", "[", "A", "]"}]], "Input", CellChangeTimes->{ 3.42142707075*^9, {3.421430886703125*^9, 3.421430886875*^9}}], Cell[BoxData[ RowBox[{"ImagePlot", "[", "B", "]"}]], "Input", CellChangeTimes->{ 3.421427071578125*^9, {3.42143088875*^9, 3.42143088890625*^9}}], Cell[BoxData[ RowBox[{"ImagePlot", "[", RowBox[{"{", RowBox[{"red", ",", "green", ",", "blue"}], "}"}], "]"}]], "Input", CellChangeTimes->{ 3.4214270728125*^9, {3.421430889984375*^9, 3.421430890328125*^9}}], Cell[TextData[{ "You can plot individual channels of a color image if you like. It will be \ grayscale by default, but if you want to see it in its original color, simply \ add the directive ", StyleBox["ChannelColor", FontWeight->"Bold"], ":" }], "Text"], Cell[BoxData[{ RowBox[{"ImagePlot", "[", "red", "]"}], "\[IndentingNewLine]", RowBox[{"ImagePlot", "[", RowBox[{"red", ",", RowBox[{"ChannelColor", "\[Rule]", "Red"}]}], "]"}], "\[IndentingNewLine]", RowBox[{"ImagePlot", "[", RowBox[{"green", ",", RowBox[{"ChannelColor", "\[Rule]", "Green"}]}], "]"}], "\[IndentingNewLine]", RowBox[{"ImagePlot", "[", RowBox[{"blue", ",", RowBox[{"ChannelColor", "\[Rule]", "Blue"}]}], "]"}], "\[IndentingNewLine]", RowBox[{"ImagePlot", "[", RowBox[{"{", RowBox[{"red", ",", "green", ",", "blue"}], "}"}], "]"}]}], "Input", CellChangeTimes->{{3.42142709346875*^9, 3.42142709615625*^9}, { 3.421430892265625*^9, 3.421430892421875*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["Reading and Plotting Images from the Internet", "Subsection", CellChangeTimes->{{3.421427651046875*^9, 3.421427658390625*^9}}], Cell["\<\ It is quite easy to read and plot images from the internet. All you need is \ a connection to the internet and a url for the image. You can find the url \ for an image in Internet Explorer by simply right-clicking on it and then \ clicking on Properties:\ \>", "Text", CellChangeTimes->{{3.421427667296875*^9, 3.42142770025*^9}, { 3.421427843515625*^9, 3.4214279033125*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{ RowBox[{"{", RowBox[{"r", ",", "g", ",", "b"}], "}"}], "=", RowBox[{ "ImageRead", "[", "\"\\"", "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{"ImagePlot", "[", RowBox[{"{", RowBox[{"r", ",", "g", ",", "b"}], "}"}], "]"}]}], "Input", CellChangeTimes->{{3.421427704578125*^9, 3.42142770553125*^9}, { 3.421427797640625*^9, 3.421427808203125*^9}, {3.42143098959375*^9, 3.421431005109375*^9}}], Cell[TextData[{ StyleBox["Warning :", FontColor->RGBColor[1, 0, 0]], " Most of our applications will require the dimensions of the image to be \ divisible by some power of 2. Use the PowersOfTwo directive to appropriately \ resize internet images. Images that appear as grayscale are often stored as \ color images on the internet. Use the PrintInfo directive to check this \ before using internet images in applications." }], "Text", CellChangeTimes->{{3.421427906296875*^9, 3.42142799559375*^9}}] }, Open ]], Cell[CellGroupData[{ Cell["Manipulating Images", "Subsection"], Cell["\<\ Once you have an image loaded and know how to plot it, you can do all kinds \ of things with it. Convert color to grayscale:\ \>", "Text"], Cell[BoxData[ RowBox[{"ImagePlot", "[", RowBox[{ RowBox[{"(", RowBox[{"red", "+", "green", "+", "blue"}], ")"}], "/", "3"}], "]"}]], "Input", CellChangeTimes->{ 3.42142710846875*^9, {3.421431008125*^9, 3.421431008765625*^9}}], Cell["Darken the image", "Text"], Cell[BoxData[ RowBox[{"ImagePlot", "[", RowBox[{"A", "/", "2"}], "]"}]], "Input", CellChangeTimes->{ 3.421427113140625*^9, {3.42143100984375*^9, 3.4214310101875*^9}}], Cell["Image negative", "Text"], Cell[BoxData[ RowBox[{"ImagePlot", "[", RowBox[{"255", "-", "A"}], "]"}]], "Input", CellChangeTimes->{ 3.42142711625*^9, {3.42143101159375*^9, 3.421431011953125*^9}}], Cell["Color negative", "Text"], Cell[BoxData[ RowBox[{"ImagePlot", "[", RowBox[{"255", "-", RowBox[{"{", RowBox[{"red", ",", "green", ",", "blue"}], "}"}]}], "]"}]], "Input", CellChangeTimes->{ 3.421427125765625*^9, {3.4214310131875*^9, 3.421431013453125*^9}}], Cell["Flip it upside down", "Text"], Cell[BoxData[ RowBox[{"ImagePlot", "[", RowBox[{"Reverse", "[", "A", "]"}], "]"}]], "Input", CellChangeTimes->{{3.42143101553125*^9, 3.421431015765625*^9}}], Cell["What does the transpose do?", "Text"], Cell[BoxData[ RowBox[{"ImagePlot", "[", RowBox[{"Transpose", "[", "A", "]"}], "]"}]], "Input", CellChangeTimes->{{3.42142717653125*^9, 3.42142719546875*^9}, { 3.421431016953125*^9, 3.421431017109375*^9}}], Cell["\<\ The previous cell is basically a rotation of the image counterclockwise 90 \ degrees. In the cell below, can you write code to rotate the image \ clockwise 90 degrees?\ \>", "Text"], Cell[BoxData[ RowBox[{"(*", " ", RowBox[{ "Remove", " ", "this", " ", "comment", " ", "and", " ", "put", " ", "code", " ", "here"}], " ", "*)"}]], "Input"] }, Open ]], Cell[CellGroupData[{ Cell["Converting Color Images to YCbCr Space", "Subsection"], Cell[TextData[{ "DiscreteWavelets contains a command for converting from RGB color space to \ YCbCr space. The command is called ", StyleBox["RGBToYCbCr", FontWeight->"Bold"], ". Here is an example call:" }], "Text", CellChangeTimes->{{3.42142723834375*^9, 3.421427238734375*^9}, { 3.421459798796875*^9, 3.42145980209375*^9}}], Cell[BoxData[{ RowBox[{ RowBox[{ RowBox[{"{", RowBox[{"Y", ",", "Cb", ",", "Cr"}], "}"}], " ", "=", " ", RowBox[{"RGBToYCbCr", "[", RowBox[{"{", RowBox[{"red", ",", "green", ",", "blue"}], "}"}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{"ImagePlot", "[", RowBox[{"Y", ",", RowBox[{"LinearScaling", "\[Rule]", "True"}]}], "]"}], "\[IndentingNewLine]", RowBox[{"ImagePlot", "[", RowBox[{"Cb", ",", RowBox[{"LinearScaling", "\[Rule]", "True"}]}], "]"}], "\[IndentingNewLine]", RowBox[{"ImagePlot", "[", RowBox[{"Cr", ",", RowBox[{"LinearScaling", "\[Rule]", "True"}]}], "]"}]}], "Input", CellChangeTimes->{{3.42142720225*^9, 3.42142720365625*^9}, { 3.42143101953125*^9, 3.421431019734375*^9}}], Cell[TextData[{ "Note that we have used the directive ", StyleBox["LinearScaling", FontWeight->"Bold"], " set to ", StyleBox["True", FontWeight->"Bold"], ". This maps the minimum value of the matrix to 0 and the maximum value of \ the matrix to 255." }], "Text", CellChangeTimes->{{3.421427217734375*^9, 3.421427217828125*^9}}], Cell[TextData[{ "You can convert back to RGB space using the command ", StyleBox["YCbCrToRGB", FontWeight->"Bold"], ":" }], "Text", CellChangeTimes->{3.42142724303125*^9}], Cell[BoxData[{ RowBox[{ RowBox[{ RowBox[{"{", RowBox[{"red", ",", "green", ",", "blue"}], "}"}], "=", RowBox[{"YCbCrToRGB", "[", RowBox[{"{", RowBox[{"Y", ",", "Cb", ",", "Cr"}], "}"}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{"ImagePlot", "[", RowBox[{"{", RowBox[{"red", ",", "green", ",", "blue"}], "}"}], "]"}]}], "Input", CellChangeTimes->{ 3.42142724790625*^9, {3.42143102153125*^9, 3.421431021703125*^9}}] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell["Exercises", "Section"], Cell[CellGroupData[{ Cell["Exercise 1", "Subsubsection"], Cell["\<\ In the cell below, find and plot the grayscale image of the clown that comes \ with the DiscreteWavelets package.\ \>", "Text"], Cell[BoxData[ RowBox[{"(*", " ", RowBox[{ "Remove", " ", "this", " ", "comment", " ", "and", " ", "put", " ", "code", " ", RowBox[{"here", "."}]}], " ", "*)"}]], "Input"] }, Open ]], Cell[CellGroupData[{ Cell["Exercise 2", "Subsubsection"], Cell["\<\ In the cell below, find and plot the red, green, and blue color channels \ (when reading the image, name the three matrices red, green, and blue) of the \ image of the goats that comes with the DiscreteWavelets package.\ \>", "Text"], Cell[BoxData[ RowBox[{"(*", " ", RowBox[{ "Remove", " ", "this", " ", "comment", " ", "and", " ", "put", " ", "code", " ", RowBox[{"here", "."}]}], " ", "*)"}]], "Input"] }, Open ]], Cell[CellGroupData[{ Cell["Exercise 3", "Subsubsection"], Cell["\<\ In an example above, we converted a color image to grayscale by simply \ averaging the channels. The National Television System Committee suggests \ using a weight average of these three channels for this conversion. The NTSC \ map is gray = .299*red + .587*green + .114*blue In the cell below, load and plot the legos image that comes with the package. \ Next create two grayscale images from this color image. Build the first by \ averaging the three channels and construct the second using the NTSC map. \ Call the first image gray1 and the second gray2. Plot both images - do you \ notice a difference? Repeat the exercise with some other color images included with the package or \ one from the internet.\ \>", "Text", CellChangeTimes->{{3.421427335640625*^9, 3.4214275079375*^9}, { 3.421427539640625*^9, 3.4214276243125*^9}}], Cell[BoxData[ RowBox[{"(*", " ", RowBox[{ "Remove", " ", "this", " ", "comment", " ", "and", " ", "put", " ", "code", " ", RowBox[{"here", "."}]}], " ", "*)"}]], "Input"] }, Open ]], Cell[CellGroupData[{ Cell["Exercise 4", "Subsubsection"], Cell["\<\ Gamma correction is a simple image processing tool that can be used to \ lighten or darken an image. The process is quite simple. Suppose A is a \ grayscale image matrix. We first divide all elements of A by 255 to obtain \ values in the interval [0, 1] and then raise each value to some positive \ exponent \[Gamma]. We then multiply each element by 255 and round the result \ to the nearest integer. In Mathematica we can do \"incorrect\" mathematical operations. If A is our \ image matrix, then A/255 makes some sense, but (A/255)^gamma actually raises \ each element of A to the gamma power. In the cell below, using the Round[ ] \ function, write code that will perform gamma correction on the image from \ Exercise 1. Call the output B. Try several values of gamma (I would suggest \ naming a variable gamma and then changing its values) and plotting the \ result. Can you characterize what different values of gamma do to the image? Feel free to load other grayscale images in the package and perform gamma \ correction on them.\ \>", "Text", CellChangeTimes->{{3.421428095203125*^9, 3.421428137953125*^9}}], Cell[BoxData[ RowBox[{"(*", " ", RowBox[{ "Remove", " ", "this", " ", "comment", " ", "and", " ", "put", " ", "code", " ", RowBox[{"here", "."}]}], " ", "*)"}]], "Input"] }, Open ]], Cell[CellGroupData[{ Cell["Exercise 5", "Subsubsection", CellChangeTimes->{{3.421493495745909*^9, 3.421493497432891*^9}}], Cell["\<\ In an example above we computed the negative of a color image. In the \ original image, each pixel was represented by a linear combination of vectors \ representing red, green, and blue. For the image negative, what vectors are \ used to form the linear combination for each pixel? What are the associated \ colors?\ \>", "Text", CellChangeTimes->{{3.421493503759072*^9, 3.4214936484021235`*^9}}], Cell[BoxData[ RowBox[{"(*", " ", RowBox[{ "Remove", " ", "this", " ", "comment", " ", "and", " ", "put", " ", "code", " ", RowBox[{"here", "."}]}], " ", "*)"}]], "Input"] }, Open ]] }, Open ]] }, Open ]] }, WindowSize->{1392, 933}, WindowMargins->{{-1, Automatic}, {Automatic, 3}}, FrontEndVersion->"6.0 for Microsoft Windows (32-bit) (April 20, 2007)", StyleDefinitions->FrontEnd`FileName[{"Creative"}, "NaturalColor.nb", CharacterEncoding -> "WindowsANSI"] ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[590, 23, 32, 0, 73, "Title"], Cell[625, 25, 89, 4, 96, "Subtitle"], Cell[717, 31, 158, 6, 89, "Subsubtitle"], Cell[CellGroupData[{ Cell[900, 41, 87, 1, 75, "Section"], Cell[CellGroupData[{ Cell[1012, 46, 32, 0, 37, "Subsection"], Cell[1047, 48, 324, 6, 65, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[1408, 59, 38, 0, 37, "Subsection"], Cell[1449, 61, 288, 7, 47, "Text"], Cell[1740, 70, 143, 2, 41, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[1920, 77, 46, 0, 37, "Subsection"], Cell[1969, 79, 377, 6, 83, "Text"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[2395, 91, 97, 1, 75, "Section"], Cell[CellGroupData[{ Cell[2517, 96, 51, 0, 37, "Subsection"], Cell[2571, 98, 264, 5, 47, "Text"], Cell[CellGroupData[{ Cell[2860, 107, 98, 1, 27, "Subsubsection"], Cell[2961, 110, 360, 10, 47, "Text"], Cell[3324, 122, 173, 3, 41, "Input"], Cell[3500, 127, 166, 3, 41, "Input"], Cell[3669, 132, 121, 2, 41, "Input"], Cell[3793, 136, 256, 9, 29, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[4086, 150, 100, 1, 27, "Subsubsection"], Cell[4189, 153, 364, 8, 65, "Text"], Cell[4556, 163, 142, 3, 41, "Input"], Cell[4701, 168, 665, 19, 155, "Text"], Cell[5369, 189, 240, 5, 41, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[5646, 199, 103, 1, 27, "Subsubsection"], Cell[5752, 202, 510, 17, 65, "Text"], Cell[6265, 221, 226, 4, 41, "Input"], Cell[6494, 227, 219, 4, 41, "Input"], Cell[6716, 233, 104, 2, 41, "Input"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[6869, 241, 45, 0, 37, "Subsection"], Cell[6917, 243, 581, 14, 119, "Text"], Cell[7501, 259, 549, 14, 82, "Input"], Cell[8053, 275, 43, 0, 29, "Text"], Cell[8099, 277, 142, 3, 41, "Input"], Cell[8244, 282, 43, 0, 29, "Text"], Cell[8290, 284, 143, 3, 41, "Input"], Cell[8436, 289, 46, 0, 29, "Text"], Cell[8485, 291, 178, 4, 41, "Input"], Cell[8666, 297, 765, 23, 119, "Text"], Cell[9434, 322, 817, 25, 82, "Input"], Cell[10254, 349, 531, 14, 62, "Input"], Cell[10788, 365, 509, 9, 119, "Text"], Cell[11300, 376, 372, 10, 41, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[11709, 391, 46, 0, 37, "Subsection"], Cell[11758, 393, 334, 11, 83, "Text"], Cell[12095, 406, 146, 3, 41, "Input"], Cell[12244, 411, 148, 3, 41, "Input"], Cell[12395, 416, 217, 5, 41, "Input"], Cell[12615, 423, 261, 7, 47, "Text"], Cell[12879, 432, 716, 18, 122, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[13632, 455, 133, 1, 37, "Subsection"], Cell[13768, 458, 389, 7, 65, "Text"], Cell[14160, 467, 520, 14, 102, "Input"], Cell[14683, 483, 507, 9, 101, "Text"] }, Open ]], Cell[CellGroupData[{ Cell[15227, 497, 41, 0, 37, "Subsection"], Cell[15271, 499, 151, 5, 83, "Text"], Cell[15425, 506, 243, 7, 41, "Input"], Cell[15671, 515, 32, 0, 29, "Text"], Cell[15706, 517, 173, 4, 41, "Input"], Cell[15882, 523, 30, 0, 29, "Text"], Cell[15915, 525, 173, 4, 41, "Input"], Cell[16091, 531, 30, 0, 29, "Text"], Cell[16124, 533, 244, 6, 41, "Input"], Cell[16371, 541, 35, 0, 29, "Text"], Cell[16409, 543, 161, 3, 41, "Input"], Cell[16573, 548, 43, 0, 29, "Text"], Cell[16619, 550, 211, 4, 41, "Input"], Cell[16833, 556, 193, 4, 47, "Text"], Cell[17029, 562, 165, 4, 41, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[17231, 571, 60, 0, 37, "Subsection"], Cell[17294, 573, 336, 8, 47, "Text"], Cell[17633, 583, 761, 21, 102, "Input"], Cell[18397, 606, 338, 10, 47, "Text"], Cell[18738, 618, 177, 6, 29, "Text"], Cell[18918, 626, 459, 13, 62, "Input"] }, Open ]] }, Open ]], Cell[CellGroupData[{ Cell[19426, 645, 28, 0, 75, "Section"], Cell[CellGroupData[{ Cell[19479, 649, 35, 0, 27, "Subsubsection"], Cell[19517, 651, 137, 3, 47, "Text"], Cell[19657, 656, 184, 5, 41, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[19878, 666, 35, 0, 27, "Subsubsection"], Cell[19916, 668, 243, 4, 65, "Text"], Cell[20162, 674, 184, 5, 41, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[20383, 684, 35, 0, 27, "Subsubsection"], Cell[20421, 686, 857, 18, 245, "Text"], Cell[21281, 706, 184, 5, 41, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[21502, 716, 35, 0, 27, "Subsubsection"], Cell[21540, 718, 1140, 21, 317, "Text"], Cell[22683, 741, 184, 5, 41, "Input"] }, Open ]], Cell[CellGroupData[{ Cell[22904, 751, 101, 1, 27, "Subsubsection"], Cell[23008, 754, 410, 7, 83, "Text"], Cell[23421, 763, 184, 5, 41, "Input"] }, Open ]] }, Open ]] }, Open ]] } ] *) (* End of internal cache information *)