colour.RGB_to_XYZ

colour.RGB_to_XYZ(RGB, illuminant_RGB, illuminant_XYZ, matrix_RGB_to_XYZ, chromatic_adaptation_transform='CAT02', cctf_decoding=None)[source]

Converts given RGB colourspace array to CIE XYZ tristimulus values.

Parameters
  • RGB (array_like) – RGB colourspace array.

  • illuminant_RGB (array_like) – CIE xy chromaticity coordinates or CIE xyY colourspace array of the illuminant for the input RGB colourspace array.

  • illuminant_XYZ (array_like) – CIE xy chromaticity coordinates or CIE xyY colourspace array of the illuminant for the output CIE XYZ tristimulus values.

  • matrix_RGB_to_XYZ (array_like) – Matrix converting the RGB colourspace array to CIE XYZ tristimulus values, i.e. the Normalised Primary Matrix (NPM).

  • chromatic_adaptation_transform (unicode, optional) – {‘CAT02’, ‘XYZ Scaling’, ‘Von Kries’, ‘Bradford’, ‘Sharp’, ‘Fairchild’, ‘CMCCAT97’, ‘CMCCAT2000’, ‘CAT02 Brill 2008’, ‘Bianco 2010’, ‘Bianco PC 2010’, None}, Chromatic adaptation transform, if None no chromatic adaptation is performed.

  • cctf_decoding (object, optional) – Decoding colour component transfer function (Decoding CCTF) or electro-optical transfer function (EOTF / EOCF).

Returns

CIE XYZ tristimulus values.

Return type

ndarray

Notes

Domain

Scale - Reference

Scale - 1

RGB

[0, 1]

[0, 1]

illuminant_XYZ

[0, 1]

[0, 1]

illuminant_RGB

[0, 1]

[0, 1]

Range

Scale - Reference

Scale - 1

XYZ

[0, 1]

[0, 1]

Examples

>>> RGB = np.array([0.45595571, 0.03039702, 0.04087245])
>>> illuminant_RGB = np.array([0.31270, 0.32900])
>>> illuminant_XYZ = np.array([0.34570, 0.35850])
>>> chromatic_adaptation_transform = 'Bradford'
>>> matrix_RGB_to_XYZ = np.array(
...     [[0.41240000, 0.35760000, 0.18050000],
...      [0.21260000, 0.71520000, 0.07220000],
...      [0.01930000, 0.11920000, 0.95050000]]
... )
>>> RGB_to_XYZ(RGB, illuminant_RGB, illuminant_XYZ, matrix_RGB_to_XYZ,
...            chromatic_adaptation_transform)  
array([ 0.2163881...,  0.1257    ,  0.0384749...])