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.

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