machinevisiontoolbox.Image.colorspace

Image.colorspace(dst, src=None)

Transform a color image between color representations

Parameters:
  • dst (str) – destination color space (see below)

  • src (str, optional) – source color space (see below), defaults to colororder of image

Returns:

color image in new colorspace

Return type:

Image

Color space names (synonyms listed on the same line) are:

Color space name

Option string(s)

grey scale

‘grey’, ‘gray’

RGB (red/green/blue)

‘rgb’

BGR (blue/green/red)

‘bgr’

CIE XYZ

‘xyz’, ‘xyz_709’

YCrCb

‘ycrcb’

HSV (hue/sat/value)

‘hsv’

HLS (hue/lightness/sat)

‘hls’

CIE L*a*b*

‘lab’, ‘l*a*b*’

CIE L*u*v*

‘luv’, ‘l*u*v*’

Example:

>>> from machinevisiontoolbox import Image
>>> im = Image.Read('flowers1.png')
>>> im.colorspace('hsv')
Image: 640 x 426 (uint8), h:s:v
Note:

RGB images are assumed to be linear, or gamma decoded.

References:
  • Robotics, Vision & Control for Python, Section 10.2.7, 10.4.1, P. Corke, Springer 2023.

Seealso:

mono colorspace_convert