bundles / skimage 0.26.1rc0.dev0+git20260530.b607368ff / skimage / color / colorconv / convert_colorspace
function
skimage.color.colorconv:convert_colorspace
source: /dev/scikit-image/src/skimage/color/colorconv.py:76
Signature
def convert_colorspace(arr, fromspace, tospace, *, channel_axis = -1)Summary
Convert an image array to a new color space.
Extended Summary
Valid color spaces are:
'RGB', 'HSV', 'RGB CIE', 'XYZ', 'YUV', 'YIQ', 'YPbPr', 'YCbCr', 'YDbDr'
Parameters
arr: array_like of shape (..., C=3, ...)The image to convert. By default, the final dimension denotes channels.
fromspace: strThe color space to convert from. Can be specified in lower case.
tospace: strThe color space to convert to. Can be specified in lower case.
channel_axis: int, optionalThis parameter indicates which axis of the array corresponds to channels.
Returns
out: ndarray of shape (..., C=3, ...)The converted image. Same dimensions as input.
Raises
: ValueErrorIf fromspace is not a valid color space
: ValueErrorIf tospace is not a valid color space
Notes
Conversion is performed through the "central" RGB color space, i.e. conversion from XYZ to HSV is implemented as XYZ -> RGB -> HSV instead of directly.
Examples
from skimage import data img = data.astronaut() img_hsv = convert_colorspace(img, 'RGB', 'HSV')✓
Aliases
skimage.color.convert_colorspace