While it is very convenient to manipulate images as matrices in the case of monochrome data, this is not the case with color images. The Digital Image Processing package resolves this problem by defining a common data structure for monochrome and color images. The image data structure is encapsulated in an ImageData Mathematica expression. ImageData is like a generalization of the graphics primitive Raster, because it also facilitates the easy manipulation and handling of single and multichannel images. As a consequence, users usually do not need to concern themselves with the complexities of the structural organization of the color information since all ImageProcessing functions and selected builtin Mathematica functions will handle color image data in a transparent manner. To learn about the structure of an ImageData expression consider rgb.tif, a small RGB color image found in $ImageProcessingDataDirectory. This directory is added to the search path when the package is loaded. All the example images are located in this directory. $ImageProcessingInstallationDirectory  gives the toplevel installation directory  $ImageProcessingDataDirectory  gives 
ImageProcessing file system symbols. Out[2]=  
Out[3]=  
 format of singlechannel (i.e., monochrome) image 
ImageData[{{{r_{0,0},g_{0,0},b_{0,0}}, {r_{0,1},g_{0,1},b_{0,1}}...}}, PixelInterleave→True, ColorFunction→cf] 
 format of multichannel ( image in planar configuration 
ImageData expressions. Out[4]//InputForm=  
RawImageData[img]  returns raw data from an ImageData expression  MeshedImageData[img]  returns an ImageData expression with a meshed data structure  PlanarImageData[img]  returns an ImageData expression with a planar data structure  FromChannels[img]  returns a meshed ImageData expression from multiple singlecolor ImageData expressions  ToChannels[img]  returns a list of singlecolor ImageData expressions 
Structure conversion functions. Out[5]//InputForm=  
Here we split the rgb image into three singlecolor GrayLevel channels. Each channel is defined by an ImageData expression. Out[6]//InputForm=  
This returns an RGBColor meshed image from the three individual channels. Out[7]//InputForm=  
ImageDepth[img]  returns the number of color channels in img  ImageOptions[img]  returns the list of options in img  ImageDimensions[img]  returns the planar dimensions of img  RawImageData[img]  returns the raw image data in img  ImageDataQ[img]  returns True if img is an ImageData expression and False otherwise 
ImageData structure interrogation functions. Out[8]//MatrixForm=  
Out[9]=  
Note that a second method of extracting the raw data is to use the Part command. Since the first element of the ImageData expression contains the raw image data, it is easier, if somewhat more cryptic to use the Part specification on an ImageData object. Out[10]=  
Out[11]=  
Having described the structure of ImageData, we now turn our attention to the problem of using the expression as an argument to other ImageProcessing and Mathematica functions. The goal of making ImageData objects easy to use requires that builtin Mathematica functions, to the degree that this makes sense, accept these expressions as valid arguments. Consider first the group of arithmetic operators. Here are a couple of examples. The basic arithmetic and logic operations (Plus, Times, Subract, Divide, Power, BitAnd, BitOr, BitXor) between a scalar and an ImageData expression or two ImageData expressions work as expected. Out[12]//InputForm=  
Out[13]//InputForm=  
Out[14]//InputForm=  
ImagePlus[img, a]  Plus operator  ImageTimes[img, a]  Times  ImagePower[img, a]  Power operator  ImageSubtract[img, a]  Subtract operator  ImageDivide[img, a]  Divide operator  ImageBitAnd[img, a]  BitAnd operator  ImageBitOr[img, a]  BitOr operator  ImageBitXor[img, a]  BitXor operator 
ImageProcessing arithmetic and logic operators. Out[15]//InputForm=  
Out[16]//InputForm=  
The array operators Reverse, Transpose, RotateRight, and RotateLeft have been extended to accept ImageData expressions. Out[17]=  
In addition to the previously described extensions to arithmetic and logic commands, the package includes other functions that greatly enhance the easeofuse of ImageData objects. The ImageTake function adapts the functionality of Take, while ImageThread allows the user to easily apply functions to individual channels of an image. The function ImageTakeGUI uses a graphical user interface to simplify the selection of one or more subregions of a given example image. ImageTake[img, {x_{1}, x_{2}}, {y_{1}, y_{2}}]  returns a subregion of img defined by the row coordinates {x_{1}, x_{2}} and column coordinates {y_{1}, y_{2}}  ImageTakeGUI[img]  returns one or more subregions of img using a user interface tool  ImageThread[f, img, args]  applies 
Extensions to Take and Thread. Out[18]//InputForm=  
Out[19]//InputForm=  
Out[20]//InputForm=  
