This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Indexed Images

An indexed image consists of an array and a colormap matrix. An indexed image uses direct mapping of pixel values in the array to colormap values. By convention, this documentation uses the variable name X to refer to the array and map to refer to the colormap.

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.

The pixel values in the array are direct indices into a colormap. The color of each image pixel is determined by using the corresponding value of X as an index into map. 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 single or double, the colormap normally contains integer values in the range [1, p], where p is the length of the colormap. 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 logical, uint8 or uint16, the colormap normally contains integer values in the range [0, p1]. The value 0 points to the first row in the colormap, the value 1 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. After you read the image and the colormap into the workspace as separate variables, you must keep track of the association between the image and colormap. However, you are not limited to using the default colormap—you can use any colormap that you choose.

The following figure illustrates the structure of an indexed image. In the figure, the image matrix is of class double, so the value 5 points to the fifth row of the colormap.

Pixel Values Index to Colormap Entries in an Indexed Image

Related Topics