# psychopy.tools.colorspacetools.cielab2rgb¶

psychopy.tools.colorspacetools.cielab2rgb(lab, whiteXYZ=None, conversionMatrix=None, transferFunc=None, clip=False, **kwargs)[source]

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

CIE L*a*b* are first transformed into CIE XYZ (1931) color space, then the RGB conversion is applied. By default, the sRGB conversion matrix is used with a reference D65 white point. You may specify your own RGB conversion matrix and white point (in CIE XYZ) appropriate for your display.

Parameters
• lab (tuple, list or ndarray) – 1-, 2-, 3-D vector of CIE L*a*b* coordinates to convert. The last dimension should be length-3 in all cases specifying a single coordinate.

• whiteXYZ (tuple, list or ndarray) – 1-D vector coordinate of the white point in CIE-XYZ color space. Must be the same white point needed by the conversion matrix. The default white point is D65 if None is specified, defined as X, Y, Z = 0.9505, 1.0000, 1.0890.

• conversionMatrix (tuple, list or ndarray) – 3x3 conversion matrix to transform CIE-XYZ to RGB values. The default matrix is sRGB with a D65 white point if None is specified. Note that values must be gamma corrected to appear correctly according to the sRGB standard.

• transferFunc (pyfunc or None) – Signature of the transfer function to use. If None, values are kept as linear RGB (it’s assumed your display is gamma corrected via the hardware CLUT). The TF must be appropriate for the conversion matrix supplied (default is sRGB). Additional arguments to ‘transferFunc’ can be passed by specifying them as keyword arguments. Gamma functions that come with PsychoPy are ‘srgbTF’ and ‘rec709TF’, see their docs for more information.

• clip (bool) – Make all output values representable by the display. However, colors outside of the display’s gamut may not be valid!

Returns

Array of RGB tristimulus values.

Return type

ndarray

Example

Converting a CIE L*a*b* color to linear RGB:

import psychopy.tools.colorspacetools as cst
cielabColor = (53.0, -20.0, 0.0)  # greenish color (L*, a*, b*)
rgbColor = cst.cielab2rgb(cielabColor)


Using a transfer function to convert to sRGB:

rgbColor = cst.cielab2rgb(cielabColor, transferFunc=cst.srgbTF)