Image Processing Toolbox    

Indexed Images

An indexed image consists of a data matrix, X, and a colormap matrix, map. The data matrix can be of class uint8, uint16, or double. The colormap matrix is an m-by-3 array of class double containing floating-point values in the range [0,1]. Each row of map specifies the red, green, and blue components of a single color. An indexed image uses direct mapping of pixel values to colormap values. The color of each image pixel is determined by using the corresponding value of X as an index into map. The value 1 points to the first row in map, the value 2 points to the second row, and so on.

A colormap is often stored with an indexed image and is automatically loaded with the image when you use the imread function. However, you are not limited to using the default colormap--you can use any colormap that you choose. The figure below illustrates the structure of an indexed image. The pixels in the image are represented by integers, which are pointers (indices) to color values stored in the colormap.

Figure 2-1: Pixel Values Are Indices to a Colormap in Indexed Images

Class and Colormap Offsets

The relationship between the values in the image matrix and the colormap depends on the class of the image matrix. If the image matrix is of class double, the value 1 points to the first row in the colormap, the value 2 points to the second row, and so on. If the image matrix is of class uint8 or uint16, there is an offset--the value 0 points to the first row in the colormap, the value 1 points to the second row, and so on.

The offset is also used in graphics file formats to maximize the number of colors that can be supported. In the image above, the image matrix is of class double. Because there is no offset, the value 5 points to the fifth row of the colormap.

Limitations to uint16 Support

Note that the toolbox provides limited support for indexed images of class uint16. You can read these images into MATLAB and display them, but before you can process a uint16 indexed image you must first convert it to either a double or a uint8. To convert to a double, call im2double; to reduce the image to 256 colors or fewer (uint8) call imapprox. For more information, see the reference pages for im2double and imapprox.


  Image Types in the Toolbox Intensity Images