: I = rgb2gray (rgb_img)
: gray_map = rgb2gray (rgb_map)

Transform an image or colormap from red-green-blue (RGB) color space to a grayscale intensity image.

The input may be of class uint8, int8, uint16, int16, single, or double. The output is of the same class as the input.

Implementation Note: The grayscale intensity is calculated as

I = 0.298936*R + 0.587043*G + 0.114021*B

which corresponds to the luminance channel when RGB is translated to YIQ as documented in https://en.wikipedia.org/wiki/YIQ.

See also: rgb2hsv, rgb2ind.

Package: image