bundles / skimage 0.26.1rc0.dev0 / skimage / color / colorconv / rgb2gray
function
skimage.color.colorconv:rgb2gray
source: /_skimage2/color/colorconv.py:936
Signature
def rgb2gray(rgb, *, channel_axis = -1)Summary
Compute luminance of an RGB image.
Parameters
rgb: (..., C=3, ...) array_likeThe image in RGB format. By default, the final dimension denotes channels.
Returns
out: ndarrayThe luminance image - an array which is the same size as the input array, but with the channel dimension removed.
Raises
: ValueErrorIf
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 BIf there is an alpha channel present, it is ignored.
Examples
from skimage.color import rgb2gray from skimage import data img = data.astronaut() img_gray = rgb2gray(img)✓
Aliases
skimage.color.rgb2gray