ind2rgb
Converts an indexed image and its colormap to an RGB image.
Category: Graphics > Images
Syntax
RGB = ind2rgb(X, map)
Replaces each index in X by the color of the corresponding row of map.
Description
The result has one plane per color channel, so RGB(:,:,1) holds the red values of all pixels. It is the inverse of rgb2ind when no color was lost, and a convenient step before filtering color data.
Input arguments
X- Indexed image. Integer-class indices start at 0,
doubleones at 1. map- Colormap, m-by-3.
Output arguments
RGB- m-by-n-by-3
doubleimage.
Example
Look up colors
X = [1 2];
map = [1 0 0; 0 1 0];
RGB = ind2rgb(X, map);
disp(size(RGB))
disp(squeeze(RGB(1, 2, :))')
Output
1 2 3
0 1 0