Image Processing Toolbox Previous page   Next Page

Displaying Intensity Images

To display an intensity (grayscale) image, using either imshow or imview, specify the image matrix as an argument.

or

Both functions display the image by scaling the intensity values to serve as indices into a grayscale colormap.

If I is double, a pixel value of 0.0 is displayed as black, a pixel value of 1.0 is displayed as white, and pixel values in between are displayed as shades of gray. If I is uint8, then a pixel value of 255 is displayed as white. If I is uint16, then a pixel value of 65535 is displayed as white.

Intensity images are similar to indexed images in that each uses an m-by-3 RGB colormap, but normally, you do not specify a colormap for an intensity image. MATLAB displays intensity images by using a grayscale system colormap (where R=G=B). By default, the number of levels of gray in the colormap is 256 on systems with 24-bit color, and 64 or 32 on other systems. (See Working with Different Screen Bit Depths for a detailed explanation.)

Specifying the Number of Gray Levels

Using imshow, you can optionally specify the number of gray levels to use for intensity images. For example, to display an image with 32 gray levels, use this syntax.

Because MATLAB scales intensity images to fill the colormap range, a colormap of any size can be used. Larger colormaps enable you to see more detail, but they also use up more color slots. The availability of color slots is discussed further in Working with Different Screen Bit Depths.

Displaying Intensity Images That Have Unconventional Ranges

In some cases, you might have data you want to display as an intensity image, even though the data is outside the conventional toolbox range (i.e., [0,1] for double arrays, [0,255] for uint8 arrays, or [0,65535] for uint16 arrays). For example, if you filter an intensity image, some of the output data might fall outside the range of the original data.

To display unconventional range data as an image, you can specify the display range directly, using this syntax for both the imshow and imview functions.

or

If you use an empty matrix ([]) for the display range, these functions scale the data automatically, setting low and high to the minimum and maximum values in the array. The next example filters an intensity image, creating unconventional range data. The example calls imview to display the image, using the automatic scaling option. If you execute this example, note the display range specified in the lower right corner of the Image Viewer window.


Previous page  Displaying Indexed Images Displaying Binary Images Next page

Learn more about the latest releases of MathWorks products:

 © 1994-2009 The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS