Convert a color indexed image to a grayscale intensity image.
The image x must be an indexed image which will be converted using the colormap cmap. If cmap does not contain enough colors for the image, pixels in x outside the range are mapped to the last color in the map before conversion to grayscale.
The output I is of the same class as the input x and may be
one of uint8
, uint16
, single
, or double
.
Implementation Note: There are several ways of converting colors to
grayscale intensities. This functions uses the luminance value obtained
from rgb2ntsc
which is I = 0.299*R + 0.587*G + 0.114*B
.
Other possibilities include the value component from rgb2hsv
or
using a single color channel from ind2rgb
.
See also: gray2ind, ind2rgb.
Package: octave