def rgb2gray(rgb):
 if (rgb.ndim == 2):
  return np.ascontiguousarray(rgb)
 rgb = _prepare_colorarray(rgb[..., :3])
 gray = (0.2125 * rgb[..., 0])
 gray[:] += (0.7154 * rgb[..., 1])
 gray[:] += (0.0721 * rgb[..., 2])
 return gray

def rgb2gray ( rgb ) : if ( rgb . ndim == 2 ) : return np . ascontiguousarray ( rgb ) rgb = _prepare_colorarray ( rgb [ ... , : 3 ] ) gray = ( 0.2125 * rgb [ ... , 0 ] ) gray [ : ] += ( 0.7154 * rgb [ ... , 1 ] ) gray [ : ] += ( 0.0721 * rgb [ ... , 2 ] ) return gray
compute luminance of an rgb image .