Image.colorspace#
- Image.colorspace(dst: str, src: str | None = None) Self[source]#
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:
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(size=(640, 426), dtype=uint8, nplanes=3, colororder=h:s:v)
Note
RGB images are assumed to be linear, or gamma decoded.
- References:
P. Corke, Robotics, Vision & Control for Python, Springer, 2023, Section 10.2.7, 10.4.1.
- Seealso: