Legacy Documentation

Digital Image Processing (2000)

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

2.5 Reading, Writing, Displaying, and Annotating Images

ImageRead and ImageWrite functions.

The ImageProcessing function ImageRead should be used to load image data stored in one of the supported image formats. ImageRead makes use of the built-in Import function for the low-level format conversion operations and converts the output Graphics to an ImageData expression (using utility function GraphicsToImageData). The type argument string may be omitted if a standard filename suffix is used.
In[1]:=
In[2]:=
As demonstrated in Section 2.4, ImageData expressions may be conveniently displayed using the standard Mathematica Graphics function. ImageData objects behaves like any other Mathematica Graphics primitive (e.g., see Raster). A meshed ImageData expression will, by default, display as a single composite color image.
In[3]:=
Out[3]=Out[3]=
In[4]:=
Out[4]=Out[4]=
In[5]:=
Out[5]=Out[5]=
In[6]:=
Out[6]=Out[6]=
On occasion, the default contrast may not provide optimum viewing conditions. The option PlotRange may be used to adjust image contrast. As in 2D and 3D plots, PlotRange allows the user to adjust the dynamic range of the display. Here we show two examples, one a narrowing of the display range, thus causing saturation, and the other an expansion of the range, thus making the image appear darker.
In[7]:=
Out[7]=Out[7]=
In Section 2.2, we showed how to obtain and plot a row or column profile of a raw image data array. Here we return to this problem to show how to obtain row or column profiles of ImageData expressions. Later, in Section 5.5, we will show how data profiles along any arbitrary path may be extracted. As in the earlier example, functions Part or Take may be used to get a row or column of the image data.
In[8]:=
In[9]:=
Out[9]=Out[9]=
In[10]:=
In[11]:=
Out[11]=Out[11]=
The user may sometimes need to combine image graphics with Mathematica Graphics primitives, either for annotation purposes or for region-of-interest processing purposes. This is complicated just a little by the fact that graphics coordinates and matrix indices are reversed with respect to each other. It should be noted that while 2D arrays use a row-major notation, (i.e., row coordinate followed by column coordinate) graphics use the familiar x-y position notation, with x as the horizontal axis and y as the vertical axis.

GraphicsRotate function.

Here we demonstrate the use of GraphicsRotate. Suppose we wished to annotate the beans image with a blue-colored disk at position r=26 and c=105, where r and c stand for the row and column, respectively.
In[12]:=
Out[12]=Out[12]=
In[13]:=
Out[13]=Out[13]=