magpack.image_utils.rgb2gray#

rgb2gray(rgb)#

Converts RGB/RGBA data of shape (x, y, …, 3) to grayscale.

The output is in the same range as the input (e.g. [0,1] or [0,255]). Only the first 3 indices from the last dimension are used.

Parameters:
rgbnp.ndarray

Numpy array of shape (x, y, …, 3) to be converted

Returns:
graynp.ndarray

Numpy array of shape (x, y, …) grayscale data