colour.RGB_to_XYZ#

colour.RGB_to_XYZ(RGB: ArrayLike, illuminant_RGB: ArrayLike, illuminant_XYZ: ArrayLike, matrix_RGB_to_XYZ: ArrayLike, chromatic_adaptation_transform: Literal['Bianco 2010', 'Bianco PC 2010', 'Bradford', 'CAT02 Brill 2008', 'CAT02', 'CAT16', 'CMCCAT2000', 'CMCCAT97', 'Fairchild', 'Sharp', 'Von Kries', 'XYZ Scaling'] | str | None = 'CAT02', cctf_decoding: Callable | None = None) ndarray[source]#

Convert given RGB colourspace array to CIE XYZ tristimulus values.

Parameters:
  • RGB (ArrayLike) – RGB colourspace array.

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

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

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

  • chromatic_adaptation_transform (Literal['Bianco 2010', 'Bianco PC 2010', 'Bradford', 'CAT02 Brill 2008', 'CAT02', 'CAT16', 'CMCCAT2000', 'CMCCAT97', 'Fairchild', 'Sharp', 'Von Kries', 'XYZ Scaling'] | str | None) – Chromatic adaptation transform, if None no chromatic adaptation is performed.

  • cctf_decoding (Callable | None) – Decoding colour component transfer function (Decoding CCTF) or electro-optical transfer function (EOTF).

Returns:

CIE XYZ tristimulus values.

Return type:

numpy.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...])