Image Processing Toolbox User's Guide Previous page   Next Page

Displaying Indexed Images

To display an indexed image, using either imshow or imtool, specify both the image matrix and the colormap. This documentation uses the variable name X to represent an indexed image in the workspace, and map to represent the colormap.

or

For each pixel in X, these functions display the color stored in the corresponding row of map. If the image matrix data 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. However, if the image matrix data is of class uint8 or uint16, the value 0 (zero) points to the first row in the colormap, the value 1 points to the second row, and so on. This offset is handled automatically by the imtool and imshow functions.

If the colormap contains a greater number of colors than the image, the functions ignore the extra colors in the colormap. If the colormap contains fewer colors than the image requires, the functions set all image pixels over the limits of the colormap's capacity to the last color in the colormap. For example, if an image of class uint8 contains 256 colors, and you display it with a colormap that contains only 16 colors, all pixels with a value of 15 or higher are displayed with the last color in the colormap.


Previous page  Displaying Different Image Types Displaying Grayscale Images Next page

© 1994-2005 The MathWorks, Inc.