Name

RGB2Ind — converts an RGB image to an indexed image

Calling Sequence

[IndexImage ColorMap] = RGB2Ind(RGB);

Parameters

RGB

3D image of a numeric type

IndexImage

2D matrix with the same number of rows and columns as RGB

ColorMap

matrix with three columns and as many rows as RGB contains pixels. Note that this parameter is compulsory.

Description

This function converts an RGB image to an indexed image. This function should be called if a color image is to be displayed with ShowImage. This function as the same effect as rgb2ind in previous versions.

Examples

RGB = rand(3, 3, 3) // generate random image

[IndexedImage, ColorMap] = RGB2Ind(RGB) // RGB is converted to an indexed image

FigureHandle = ShowImage(IndexedImage, 'Example', ColorMap); // IndexedImage is displayed

See also

Ind2RGB, ShowImage, ShowColorImage, DrawBoundingBoxes