colour.adaptation Package

Module Contents

colour.adaptation.chromatic_adaptation_matrix_VonKries(XYZ_w, XYZ_wr, transform=u'CAT02')

Returns the chromatic adaptation matrix from test viewing conditions CIE XYZ_w colourspace matrix to reference viewing conditions CIE XYZ_wr colourspace matrix.

Parameters:
  • XYZ_w (array_like, (3,)) – Test viewing condition CIE XYZ colourspace matrix.
  • XYZ_wr (array_like, (3,)) – Reference viewing condition CIE XYZ colourspace matrix.
  • transform (unicode, optional) – {‘CAT02’, ‘XYZ Scaling’, ‘Von Kries’, ‘Bradford’, ‘Sharp’, ‘Fairchild, ‘CMCCAT97’, ‘CMCCAT2000’, ‘CAT02_BRILL_CAT’, ‘Bianco’, ‘Bianco PC’}, Chromatic adaptation transform.
Returns:

Chromatic adaptation matrix.

Return type:

ndarray, (3, 3)

Raises:

KeyError – If chromatic adaptation method is not defined.

Examples

>>> XYZ_w = np.array([1.09846607, 1., 0.3558228])
>>> XYZ_wr = np.array([0.95042855, 1., 1.08890037])
>>> chromatic_adaptation_matrix_VonKries(XYZ_w, XYZ_wr)    
array([[ 0.8687653..., -0.1416539...,  0.3871961...],
       [-0.1030072...,  1.0584014...,  0.1538646...],
       [ 0.0078167...,  0.0267875...,  2.9608177...]])

Using Bradford method:

>>> XYZ_w = np.array([1.09846607, 1., 0.3558228])
>>> XYZ_wr = np.array([0.95042855, 1., 1.08890037])
>>> method = 'Bradford'
>>> chromatic_adaptation_matrix_VonKries(XYZ_w, XYZ_wr, method)    
array([[ 0.8446794..., -0.1179355...,  0.3948940...],
       [-0.1366408...,  1.1041236...,  0.1291981...],
       [ 0.0798671..., -0.1349315...,  3.1928829...]])
colour.adaptation.chromatic_adaptation_VonKries(XYZ, XYZ_w, XYZ_wr, transform=u'CAT02')

Adapts given CIE XYZ colourspace stimulus from test viewing conditions CIE XYZ_w colourspace matrix to reference viewing conditions CIE XYZ_wr colourspace matrix. [6]_

Parameters:
  • XYZ (array_like, (3,)) – CIE XYZ colourspace stimulus to adapt.
  • XYZ_w (array_like, (3,)) – Test viewing condition CIE XYZ colourspace whitepoint matrix.
  • XYZ_wr (array_like, (3,)) – Reference viewing condition CIE XYZ colourspace whitepoint matrix.
  • transform (unicode, optional) – {‘CAT02’, ‘XYZ Scaling’, ‘Von Kries’, ‘Bradford’, ‘Sharp’, ‘Fairchild, ‘CMCCAT97’, ‘CMCCAT2000’, ‘CAT02_BRILL_CAT’, ‘Bianco’, ‘Bianco PC’}, Chromatic adaptation transform.
Returns:

CIE XYZ_c colourspace matrix of the stimulus corresponding colour.

Return type:

ndarray, (3,)

Examples

>>> XYZ = np.array([0.07049534, 0.1008, 0.09558313])
>>> XYZ_w = np.array([1.09846607, 1., 0.3558228])
>>> XYZ_wr = np.array([0.95042855, 1., 1.08890037])
>>> chromatic_adaptation_VonKries(XYZ, XYZ_w, XYZ_wr)  
array([ 0.0839746...,  0.1141321...,  0.2862554...])

Using Bradford method:

>>> XYZ = np.array([0.07049534, 0.1008, 0.09558313])
>>> XYZ_w = np.array([1.09846607, 1., 0.3558228])
>>> XYZ_wr = np.array([0.95042855, 1., 1.08890037])
>>> method = 'Bradford'
>>> chromatic_adaptation_VonKries(XYZ, XYZ_w, XYZ_wr, method)    
array([ 0.0854032...,  0.1140122...,  0.2972149...])
colour.adaptation.chromatic_adaptation_Fairchild1990(XYZ_1, XYZ_n, XYZ_r, Y_n, discount_illuminant=False)

Adapts given CIE XYZ_1 colourspace stimulus from test viewing conditions to reference viewing conditions using Fairchild (1990) chromatic adaptation model.

Parameters:
  • XYZ_1 (array_like, (3,)) – CIE XYZ_1 colourspace matrix of test sample / stimulus in domain [0, 100].
  • XYZ_n (array_like, (3,)) – Test viewing condition CIE XYZ_n colourspace whitepoint matrix.
  • XYZ_r (array_like, (3,)) – Reference viewing condition CIE XYZ_r colourspace whitepoint matrix.
  • Y_n (numeric) – Luminance \(Y_n\) of test adapting stimulus in \(cd/m^2\).
  • discount_illuminant (bool, optional) – Truth value indicating if the illuminant should be discounted.
Returns:

Adapted CIE XYZ_2 colourspace test stimulus.

Return type:

ndarray, (3,)

Warning

The input domain of that definition is non standard!

Notes

  • Input CIE XYZ_1, CIE XYZ_n and CIE XYZ_r colourspace matrices are in domain [0, 100].
  • Output CIE XYZ_2 colourspace matrix is in domain [0, 100].

Examples

>>> XYZ_1 = np.array([19.53, 23.07, 24.97])
>>> XYZ_n = np.array([111.15, 100.00, 35.20])
>>> XYZ_r = np.array([94.81, 100.00, 107.30])
>>> Y_n = 200
>>> chromatic_adaptation_Fairchild1990(XYZ_1, XYZ_n, XYZ_r, Y_n)    
array([ 23.3252634...,  23.3245581...,  76.1159375...])
class colour.adaptation.CMCCAT2000_InductionFactors

Bases: colour.adaptation.cmccat2000.CMCCAT2000_InductionFactors

CMCCAT2000 chromatic adaptation model induction factors.

Parameters:F (numeric) – \(F\) surround condition.
colour.adaptation.CMCCAT2000_forward(XYZ, XYZ_w, XYZ_wr, L_A1, L_A2, surround=CMCCAT2000_InductionFactors(F=1.0))

Adapts given CIE XYZ colourspace stimulus from test viewing conditions CIE XYZ_w colourspace matrix to reference viewing conditions CIE XYZ_wr colourspace matrix using CMCCAT2000 forward chromatic adaptation model.

Parameters:
  • XYZ (array_like, (3,)) – CIE XYZ colourspace stimulus to adapt.
  • XYZ_w (array_like, (3,)) – Test viewing condition CIE XYZ colourspace matrix.
  • XYZ_wr (array_like, (3,)) – Reference viewing condition CIE XYZ colourspace matrix.
  • L_A1 (numeric) – Luminance of test adapting field \(L_{A1}\) in \(cd/m^2\).
  • L_A2 (numeric) – Luminance of reference adapting field \(L_{A2}\) in \(cd/m^2\).
  • surround (CMCCAT2000_InductionFactors, optional) – Surround viewing conditions induction factors.
Returns:

CIE XYZ_c colourspace matrix of the stimulus corresponding colour.

Return type:

ndarray, (3,)

Warning

The input and output domains of that definition are non standard!

Notes

  • Input CIE XYZ, CIE XYZ_w and CIE XYZ_wr colourspace matrices are in domain [0, 100].
  • Output CIE XYZ_c colourspace matrix is in domain [0, 100].

Examples

>>> XYZ = np.array([22.48, 22.74, 8.54])
>>> XYZ_w = np.array([111.15, 100.00, 35.20])
>>> XYZ_wr = np.array([94.81, 100.00, 107.30])
>>> L_A1 = 200
>>> L_A2 = 200
>>> CMCCAT2000_forward(XYZ, XYZ_w, XYZ_wr, L_A1, L_A2)    
array([ 19.5269832...,  23.0683396...,  24.9717522...])
colour.adaptation.CMCCAT2000_reverse(XYZ_c, XYZ_w, XYZ_wr, L_A1, L_A2, surround=CMCCAT2000_InductionFactors(F=1.0))

Adapts given CIE XYZ colourspace matrix of the stimulus corresponding colour from reference viewing conditions CIE XYZ_wr colourspace matrix to test viewing conditions CIE XYZ_w colourspace matrix using CMCCAT2000 reverse chromatic adaptation model.

Parameters:
  • XYZ (array_like, (3,)) – CIE XYZ colourspace stimulus to adapt.
  • XYZ_w (array_like, (3,)) – Test viewing condition CIE XYZ colourspace whitepoint matrix.
  • XYZ_wr (array_like, (3,)) – Reference viewing condition CIE XYZ colourspace whitepoint matrix.
  • L_A1 (numeric) – Luminance of test adapting field \(L_{A1}\) in \(cd/m^2\).
  • L_A2 (numeric) – Luminance of reference adapting field \(L_{A2}\) in \(cd/m^2\).
  • surround (CMCCAT2000_InductionFactors, optional) – Surround viewing conditions induction factors.
Returns:

CIE XYZ_c stimulus colourspace matrix.

Return type:

ndarray, (3,)

Warning

The input and output domains of that definition are non standard!

Notes

  • Input CIE XYZ_c, CIE XYZ_w and CIE XYZ_wr colourspace matrices are in domain [0, 100].
  • Output CIE XYZ colourspace matrix is in domain [0, 100].

Examples

>>> XYZ_c = np.array([19.53, 23.07, 24.97])
>>> XYZ_w = np.array([111.15, 100.00, 35.20])
>>> XYZ_wr = np.array([94.81, 100.00, 107.30])
>>> L_A1 = 200
>>> L_A2 = 200
>>> CMCCAT2000_reverse(XYZ_c, XYZ_w, XYZ_wr, L_A1, L_A2)    
array([ 22.4839876...,  22.7419485...,   8.5393392...])
colour.adaptation.chromatic_adaptation_CMCCAT2000(XYZ, XYZ_w, XYZ_wr, L_A1, L_A2, surround=CMCCAT2000_InductionFactors(F=1.0), method=u'Forward')

Adapts given CIE XYZ colourspace matrix using given viewing conditions.

This definition is a convenient wrapper around CMCCAT2000_forward() and CMCCAT2000_reverse().

Parameters:
  • XYZ (array_like, (3,)) – CIE XYZ colourspace matrix to adapt.
  • XYZ_w (array_like, (3,)) – Source viewing condition CIE XYZ colourspace whitepoint matrix.
  • XYZ_wr (array_like, (3,)) – Target viewing condition CIE XYZ colourspace whitepoint matrix.
  • L_A1 (numeric) – Luminance of test adapting field \(L_{A1}\) in \(cd/m^2\).
  • L_A2 (numeric) – Luminance of reference adapting field \(L_{A2}\) in \(cd/m^2\).
  • surround (CMCCAT2000_InductionFactors, optional) – Surround viewing conditions induction factors.
  • method (unicode, optional) – {‘Forward’, ‘Reverse’} Chromatic adaptation method.
Returns:

Adapted CIE XYZ colourspace matrix.

Return type:

ndarray, (3,)

Warning

The input and output domains of that definition are non standard!

Notes

  • Input CIE XYZ, CIE XYZ_w and CIE XYZ_wr colourspace matrices are in domain [0, 100].
  • Output CIE XYZ colourspace matrix is in domain [0, 100].

Examples

>>> XYZ = np.array([22.48, 22.74, 8.54])
>>> XYZ_w = np.array([111.15, 100.00, 35.20])
>>> XYZ_wr = np.array([94.81, 100.00, 107.30])
>>> L_A1 = 200
>>> L_A2 = 200
>>> chromatic_adaptation_CMCCAT2000(XYZ, XYZ_w, XYZ_wr, L_A1, L_A2, method='Forward')    
array([ 19.5269832...,  23.0683396...,  24.9717522...])

Using the CMCCAT2000 reverse model:

>>> XYZ = np.array([19.52698326, 23.0683396, 24.97175229])
>>> XYZ_w = np.array([111.15, 100.00, 35.20])
>>> XYZ_wr = np.array([94.81, 100.00, 107.30])
>>> L_A1 = 200
>>> L_A2 = 200
>>> chromatic_adaptation_CMCCAT2000(XYZ, XYZ_w, XYZ_wr, L_A1, L_A2, method='Reverse')    
array([ 22.48,  22.74,   8.54])
colour.adaptation.chromatic_adaptation_CIE1994(XYZ_1, xy_o1, xy_o2, Y_o, E_o1, E_o2, n=1)

Adapts given CIE XYZ_1 colourspace stimulus from test viewing conditions to reference viewing conditions using CIE 1994 chromatic adaptation model.

Parameters:
  • XYZ (array_like, (3,)) – CIE XYZ colourspace matrix of test sample / stimulus in domain [0, 100].
  • xy_o1 (array_like, (2,)) – Chromaticity coordinates \(x_{o1}\) and \(y_{o1}\) of test illuminant and background.
  • xy_o2 (array_like, (2,)) – Chromaticity coordinates \(x_{o2}\) and \(y_{o2}\) of reference illuminant and background.
  • Y_o (numeric) – Luminance factor \(Y_o\) of achromatic background as percentage in domain [18, 100].
  • E_o1 (numeric) – Test illuminance \(E_{o1}\) in \(cd/m^2\).
  • E_o2 (numeric) – Reference illuminance \(E_{o2}\) in \(cd/m^2\).
  • n (numeric, optional) – Noise component in fundamental primary system.
Returns:

Adapted CIE XYZ_2 colourspace test stimulus.

Return type:

ndarray, (3,)

Warning

The input domain of that definition is non standard!

Notes

  • Input CIE XYZ_1 colourspace matrix is in domain [0, 100].
  • Output CIE XYZ_2 colourspace matrix is in domain [0, 100].

Examples

>>> XYZ_1 = np.array([28.0, 21.26, 5.27])
>>> xy_o1 = (0.4476, 0.4074)
>>> xy_o2 = (0.3127, 0.3290)
>>> Y_o = 20
>>> E_o1 = 1000
>>> E_o2 = 1000
>>> chromatic_adaptation_CIE1994(XYZ_1, xy_o1, xy_o2, Y_o, E_o1, E_o2)    
array([ 24.0337952...,  21.1562121...,  17.6430119...])