This is a development version (0.26.1rc0.dev0) and may be unstable.Go to latest (0.26.1rc0.dev0+git20260530.b607368ff)
{ } Raw JSON

bundles / skimage 0.26.1rc0.dev0 / skimage / color / colorconv / convert_colorspace

function

skimage.color.colorconv:convert_colorspace

source: /_skimage2/color/colorconv.py:77

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 : str

The color space to convert from. Can be specified in lower case.

tospace : str

The color space to convert to. Can be specified in lower case.

channel_axis : int, optional

This 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

: ValueError

If fromspace is not a valid color space

: ValueError

If 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