Image Processing Toolbox    
rgb2gray

Convert an RGB image or colormap to grayscale

Syntax

Description

rgb2gray converts RGB images to grayscale by eliminating the hue and saturation information while retaining the luminance.

I = rgb2gray(RGB) converts the truecolor image RGB to the grayscale intensity image I.

newmap = rgb2gray(map) returns a grayscale colormap equivalent to map.

Class Support

If the input is an RGB image, it can be of class uint8, uint16, or double. The output image, I, is of the same class as the input image. If the input is a colormap, the input and output colormaps are both of class double.

Algorithm

rgb2gray converts the RGB values to NTSC coordinates, sets the hue and saturation components to zero, and then converts back to RGB color space.

See Also

ind2gray, ntsc2rgb, rgb2ind, rgb2ntsc


  regionprops rgb2hsv