Legacy Documentation

Digital Image Processing (2000)

This is documentation for an obsolete product.
Current products and services
Previous section-----Next section

2.4 A Data Structure for Color Images

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 built-in 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.

ImageProcessing file system symbols.

In[1]:=
In[2]:=
Out[2]=Out[2]=
In[3]:=
Out[3]=Out[3]=

ImageData expressions.

In[4]:=
Out[4]//InputForm=Out[4]//InputForm=

Structure conversion functions.

In[5]:=
Out[5]//InputForm=Out[5]//InputForm=
Here we split the rgb image into three single-color GrayLevel channels. Each channel is defined by an ImageData expression.
In[6]:=
Out[6]//InputForm=Out[6]//InputForm=
This returns an RGBColor meshed image from the three individual channels.
In[7]:=
Out[7]//InputForm=Out[7]//InputForm=

ImageData structure interrogation functions.

In[8]:=
Out[8]//MatrixForm=Out[8]//MatrixForm=
In[9]:=
Out[9]=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.
In[10]:=
Out[10]=Out[10]=
In[11]:=
Out[11]=Out[11]=
In[12]:=
Out[12]//InputForm=Out[12]//InputForm=
In[13]:=
Out[13]//InputForm=Out[13]//InputForm=
In[14]:=
Out[14]//InputForm=Out[14]//InputForm=

ImageProcessing arithmetic and logic operators.

In[15]:=
Out[15]//InputForm=Out[15]//InputForm=
In[16]:=
Out[16]//InputForm=Out[16]//InputForm=
The array operators Reverse, Transpose, RotateRight, and RotateLeft have been extended to accept ImageData expressions.
In[17]:=
Out[17]=Out[17]=
In addition to the previously described extensions to arithmetic and logic commands, the package includes other functions that greatly enhance the ease-of-use 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.

Extensions to Take and Thread.

In[18]:=
Out[18]//InputForm=Out[18]//InputForm=
In[19]:=
Out[19]//InputForm=Out[19]//InputForm=
In[20]:=
Out[20]//InputForm=Out[20]//InputForm=