An indexed image is useful to represent the image which has limited number of colors in it so as to reduce the space consumption (of the image). As the name suggests, an indexed image is a matrix of indexes with each number pointing to the color in the colormap matrix.

Say you have an image with only three colors red, green and blue and no other color, its indexed image X (assuming it to be a 4x4 matrix image) could look something like this:

`X=[3,2,2,1;1,3,1,2;1,2,1,2];`

And the corresponding colormap matrix will be:

`map=[1,0,0;0,1,0;0,0,1];`

Here map will be 3x3 matrix with rows indicating number of colors (which is three in this example) and columns indicating R,G,B (the numbers will be varying between [0,1]).

For example, 3 in X simply points to 3rd row in map matrix and takes its corresponding color (which is blue).

Once you obtain index and colormap from an image, you can use them to get an RGB image by using

**ind2rgb** (

http://in.mathworks.com/help/matlab/ref/ind2rgb.html) command. This command simply maps indexes to the colormap matrix and creates a 3D matrix where the third dimension contains the RGB colors. You can run following lines in matlab for better understanding:

`[X,map] = imread('corn.tif');`

RGB = ind2rgb(X,map);

imagesc(RGB);