<< rgb2hsv Image Types and Color Space Conversions rgb2lab >>

IPCV >> Image Types and Color Space Conversions > rgb2ind

rgb2ind

Convert RGB image to index image

Syntax

[imout,map] = rgb2ind(imin,n)

Parameters

inm :

Source Image

n :

n levels for each color channel intensity

imout :

Output indexed image

map :

Colormap

Description

On input Im is a n1 x n2 x 3 hypermat describing a true color image Im(i,j,:) giving the R-G-B of the pixel (i,j). On output A is a n1 x n2 matrix, A(i,j) given the index on the "true" color map of the (i,j) pixel. There are n levels for each color channel intensity (each intensity being given by an integer I between 0 and n-1) To the "color" R,G,B (R,G,B in [0,n-1]) must correspond the index k= R n^2 + G n + B + 1 of the table cmap of size n^3 x 3 and cmap(k,:) = [R/(n-1) G/(n-1) B/(n-1)] As the max size of a cmap in scilab is 2^16-2, n = 40 is the max possible (40^3 <= 2^16 - 2 < 41^3).

Examples

S = imread(fullpath(getIPCVpath() + "/images/puffin.png"));
[X,map] = rgb2ind(S,8);
imshow(X,map);

See also

Authors


Report an issue
<< rgb2hsv Image Types and Color Space Conversions rgb2lab >>