Tools related to working with various color spaces.

The routines provided in the module are used to transform color coordinates between spaces. Most of the functions here are vectorized, allowing for array inputs to convert multiple color values at once.

As of version 2021.0 of PsychoPy, users ought to use the Color class for working with color coordinate values.


Conversion functions for the CIELAB and CIELCH color space.

cielab2rgb(lab[, whiteXYZ, …])

Transform CIE L*a*b* (1976) color space coordinates to RGB tristimulus values.

cielch2rgb(lch[, whiteXYZ, …])

Transform CIE L*C*h* coordinates to RGB tristimulus values.


Conversion functions for the Derrington Krauskopf and Lennie (DKL) color space.

dkl2rgb(dkl[, conversionMatrix])

Convert from DKL color space (Derrington, Krauskopf & Lennie) to RGB.

dklCart2rgb(LUM, LM, S[, conversionMatrix])

Like dkl2rgb except that it uses cartesian coords (LM,S,LUM) rather than spherical coords for DKL (elev, azim, contr).

rgb2dklCart(picture[, conversionMatrix])

Convert an RGB image into Cartesian DKL space.


Conversion functions for the Hue-Saturation-Value (HSV) color space.


Convert from HSV color space to RGB gun values.


Convert values from linear RGB to HSV colorspace.


lms2rgb(lms_Nx3[, conversionMatrix])

Convert from cone space (Long, Medium, Short) to RGB.

rgb2lms(rgb_Nx3[, conversionMatrix])

Convert from RGB to cone space (LMS).

Gamma/Transfer Functions

Standard gamma functions for converting between linear RGB space and sRGB.

srgbTF(rgb[, reverse])

Apply sRGB transfer function (or gamma) to linear RGB values.

rec709TF(rgb, **kwargs)

Apply the Rec 709 transfer function (or gamma) to linear RGB values.


Helper functions for working with color coordinates.

rescaleColor(rgb[, convertTo, clip])

Rescale RGB colors.

Back to top