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 rgb is 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)