skimage2.color.rgb2gray#
- skimage2.color.rgb2gray(rgb, *, channel_axis=-1)[source]#
Compute luminance of an RGB image.
- Parameters:
- rgb(âĶ, C=3, âĶ) array_like
The image in RGB format. By default, the final dimension denotes channels.
- Returns:
- outndarray
The luminance image - an array which is the same size as the input array, but with the channel dimension removed.
- Raises:
- ValueError
If
rgbis not at least 2-D with shape (âĶ, C=3, âĶ).
Notes
The weights used in this conversion are calibrated for contemporary CRT phosphors:
Y = 0.2125 R + 0.7154 G + 0.0721 B
If there is an alpha channel present, it is ignored.
References
Examples
>>> from _skimage2.color import rgb2gray >>> from _skimage2 import data >>> img = data.astronaut() >>> img_gray = rgb2gray(img)