colour.models.common Module

Common Colour Models Utilities

Defines various colour models common utilities.

colour.models.common.XYZ_to_sRGB(XYZ, illuminant=(0.31271, 0.32902), chromatic_adaptation_transform=u'CAT02', transfer_function=True)[source]

Converts from CIE XYZ tristimulus values to sRGB colourspace.

Parameters:
  • XYZ (array_like) – CIE XYZ tristimulus values.
  • illuminant (array_like, optional) – Source illuminant chromaticity coordinates.
  • chromatic_adaptation_transform (unicode, optional) – {‘CAT02’, ‘XYZ Scaling’, ‘Von Kries’, ‘Bradford’, ‘Sharp’, ‘Fairchild, ‘CMCCAT97’, ‘CMCCAT2000’, ‘CAT02_BRILL_CAT’, ‘Bianco’, ‘Bianco PC’}, Chromatic adaptation transform.
  • transfer_function (bool, optional) – Apply sRGB transfer function.
Returns:

sRGB colour array.

Return type:

ndarray

Notes

  • Input CIE XYZ tristimulus values are in domain [0, 1].

Examples

>>> import numpy as np
>>> XYZ = np.array([0.07049534, 0.10080000, 0.09558313])
>>> XYZ_to_sRGB(XYZ)  
array([ 0.1750135...,  0.3881879...,  0.3216195...])
colour.models.common.sRGB_to_XYZ(RGB, illuminant=(0.31271, 0.32902), chromatic_adaptation_method=u'CAT02', inverse_transfer_function=True)[source]

Converts from sRGB colourspace to CIE XYZ tristimulus values.

Parameters:
  • RGB (array_like) – sRGB colourspace array.
  • illuminant (array_like, optional) – Source illuminant chromaticity coordinates.
  • chromatic_adaptation_method (unicode, optional) – {‘CAT02’, ‘XYZ Scaling’, ‘Von Kries’, ‘Bradford’, ‘Sharp’, ‘Fairchild, ‘CMCCAT97’, ‘CMCCAT2000’, ‘CAT02_BRILL_CAT’, ‘Bianco’, ‘Bianco PC’}, Chromatic adaptation method.
  • inverse_transfer_function (bool, optional) – Apply sRGB inverse transfer function.
Returns:

CIE XYZ tristimulus values.

Return type:

ndarray

Notes

  • Input RGB colourspace array is in domain [0, 1].

Examples

>>> import numpy as np
>>> RGB = np.array([0.17501358, 0.38818795, 0.32161955])
>>> sRGB_to_XYZ(RGB)  
array([ 0.0704953...,  0.1008    ,  0.0955831...])