colour.adaptation.cat Module

Chromatic Adaptation Transforms

Defines various chromatic adaptation transforms (CAT) and objects to calculate the chromatic adaptation matrix between two given CIE XYZ colourspace matrices:

References

[1](1, 2, 3, 4, 5, 6) http://brucelindbloom.com/Eqn_ChromAdapt.html
[2](1, 2) http://rit-mcsl.org/fairchild//files/FairchildYSh.zip
[3](1, 2, 3) http://en.wikipedia.org/wiki/CIECAM02#CAT02
colour.adaptation.cat.XYZ_SCALING_CAT = array([[ 1., 0., 0.], [ 0., 1., 0.], [ 0., 0., 1.]])

XYZ Scaling chromatic adaptation transform. [1]

XYZ_SCALING_CAT : array_like, (3, 3)

colour.adaptation.cat.BRADFORD_CAT = array([[ 0.8951, 0.2664, -0.1614], [-0.7502, 1.7135, 0.0367], [ 0.0389, -0.0685, 1.0296]])

Bradford chromatic adaptation transform. [1]

BRADFORD_CAT : array_like, (3, 3)

colour.adaptation.cat.VON_KRIES_CAT = array([[ 0.40024, 0.7076 , -0.08081], [-0.2263 , 1.16532, 0.0457 ], [ 0. , 0. , 0.91822]])

Von Kries chromatic adaptation transform. [1]

VON_KRIES_CAT : array_like, (3, 3)

colour.adaptation.cat.FAIRCHILD_CAT = array([[ 0.8562, 0.3372, -0.1934], [-0.836 , 1.8327, 0.0033], [ 0.0357, -0.0469, 1.0112]])

Fairchild chromatic adaptation transform. [2]

FAIRCHILD_CAT : array_like, (3, 3)

colour.adaptation.cat.CAT02_CAT = array([[ 0.7328, 0.4296, -0.1624], [-0.7036, 1.6975, 0.0061], [ 0.003 , 0.0136, 0.9834]])

CAT02 chromatic adaptation transform. [3]

CAT02_CAT : array_like, (3, 3)

colour.adaptation.cat.CAT02_INVERSE_CAT = array([[ 1.09612382, -0.278869 , 0.18274518], [ 0.45436904, 0.47353315, 0.0720978 ], [-0.00962761, -0.00569803, 1.01532564]])

Inverse CAT02 chromatic adaptation transform. [3]

CAT02_INVERSE_CAT : array_like, (3, 3)

colour.adaptation.cat.CHROMATIC_ADAPTATION_METHODS = CaseInsensitiveMapping({u'Bradford': array([[ 0.8951, 0.2664, -0.1614], [-0.7502, 1.7135, 0.0367], [ 0.0389, -0.0685, 1.0296]]), u'XYZ Scaling': array([[ 1., 0., 0.], [ 0., 1., 0.], [ 0., 0., 1.]]), u'CAT02': array([[ 0.7328, 0.4296, -0.1624], [-0.7036, 1.6975, 0.0061], [ 0.003 , 0.0136, 0.9834]]), u'Von Kries': array([[ 0.40024, 0.7076 , -0.08081], [-0.2263 , 1.16532, 0.0457 ], [ 0. , 0. , 0.91822]]), u'Fairchild': array([[ 0.8562, 0.3372, -0.1934], [-0.836 , 1.8327, 0.0033], [ 0.0357, -0.0469, 1.0112]])})

Supported chromatic adaptation transform methods.

CHROMATIC_ADAPTATION_METHODS : dict
(‘XYZ Scaling’, ‘Bradford’, ‘Von Kries’, ‘Fairchild, ‘CAT02’)
colour.adaptation.cat.chromatic_adaptation_matrix(XYZ1, XYZ2, method=u'CAT02')[source]

Returns the chromatic adaptation matrix from given source and target CIE XYZ colourspace array_like variables.

Parameters:
  • XYZ1 (array_like, (3,)) – CIE XYZ source array_like variable.
  • XYZ2 (array_like, (3,)) – CIE XYZ target array_like variable.
  • method (unicode, optional) – (‘XYZ Scaling’, ‘Bradford’, ‘Von Kries’, ‘Fairchild, ‘CAT02’), Chromatic adaptation method.
Returns:

Chromatic adaptation matrix.

Return type:

ndarray, (3, 3)

Raises:

KeyError – If chromatic adaptation method is not defined.

References

[4]http://brucelindbloom.com/Eqn_ChromAdapt.html (Last accessed 24 February 2014)

Examples

>>> XYZ1 = np.array([1.09923822, 1.000, 0.35445412])
>>> XYZ2 = np.array([0.96907232, 1.000, 1.121792157])
>>> chromatic_adaptation_matrix(XYZ1, XYZ2)  
array([[ 0.8714561..., -0.1320467...,  0.4039483...],
       [-0.0963880...,  1.0490978...,  0.160403... ],
       [ 0.0080207...,  0.0282636...,  3.0602319...]])

Using Bradford method:

>>> XYZ1 = np.array([1.09923822, 1.000, 0.35445412])
>>> XYZ2 = np.array([0.96907232, 1.000, 1.121792157])
>>> method = 'Bradford'
>>> chromatic_adaptation_matrix(XYZ1, XYZ2, method)  
array([[ 0.8518131..., -0.1134786...,  0.4124804...],
       [-0.1277659...,  1.0928930...,  0.1341559...],
       [ 0.0845323..., -0.1434969...,  3.3075309...]])