(rgb)
return saturation, value
Convert an RGB image or array of RGB colors to saturation and
value, returning each one as a separate 32-bit floating point array or
value.
Convert an RGB image or array of RGB colors to saturation and
value, returning each one as a separate 32-bit floating point array or
value.
Convert an RGB image or array of RGB colors to saturation and value returning each one as a separate 32 - bit floating point array or value .
def rgb_to_sv(rgb):
    '''Convert an RGB image or array of RGB colors to saturation and
value, returning each one as a separate 32-bit floating point array or
value.

    '''

    if not isinstance(rgb, np.ndarray):
        rgb = np.array(rgb)

    axis = len(rgb.shape) - 1
    cmax = rgb.max(axis=axis).astype(np.float32)
    cmin = rgb.min(axis=axis).astype(np.float32)
    delta = cmax - cmin

    saturation = delta.astype(np.float32) / cmax.astype(np.float32)
    saturation = np.where(cmax == 0, 0, saturation)

    value = cmax / 255.0

    return saturation, value
def rgb_to_sv ( rgb ) : if not isinstance ( rgb , np . ndarray ) : rgb = np . array ( rgb ) axis = len ( rgb . shape ) - 1 cmax = rgb . max ( axis = axis ) . astype ( np . float32 ) cmin = rgb . min ( axis = axis ) . astype ( np . float32 ) delta = cmax - cmin saturation = delta . astype ( np . float32 ) / cmax . astype ( np . float32 ) saturation = np . where ( cmax == 0 , 0 , saturation ) value = cmax / 255.0 return saturation , value