colour.adaptation Package

Module Contents

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

Computes the chromatic adaptation matrix from test viewing conditions to reference viewing conditions.

Parameters:
  • XYZ_w (array_like) – Test viewing condition CIE XYZ tristimulus values of whitepoint.
  • XYZ_wr (array_like) – Reference viewing condition CIE XYZ tristimulus values of whitepoint.
  • 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

Raises:

KeyError – If chromatic adaptation method is not defined.

Examples

>>> XYZ_w = np.array([1.09846607, 1.00000000, 0.35582280])
>>> XYZ_wr = np.array([0.95042855, 1.00000000, 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.00000000, 0.35582280])
>>> XYZ_wr = np.array([0.95042855, 1.00000000, 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 stimulus from test viewing conditions to reference viewing conditions.

Parameters:
  • XYZ (array_like) – CIE XYZ tristimulus values of stimulus to adapt.
  • XYZ_w (array_like) – Test viewing condition CIE XYZ tristimulus values of whitepoint.
  • XYZ_wr (array_like) – Reference viewing condition CIE XYZ tristimulus values of whitepoint.
  • 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 tristimulus values of the stimulus corresponding colour.

Return type:

ndarray

Examples

>>> XYZ = np.array([0.07049534, 0.10080000, 0.09558313])
>>> XYZ_w = np.array([1.09846607, 1.00000000, 0.35582280])
>>> XYZ_wr = np.array([0.95042855, 1.00000000, 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.10080000, 0.09558313])
>>> XYZ_w = np.array([1.09846607, 1.00000000, 0.35582280])
>>> XYZ_wr = np.array([0.95042855, 1.00000000, 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 stimulus CIE XYZ_1 tristimulus values from test viewing conditions to reference viewing conditions using Fairchild (1990) chromatic adaptation model.

Parameters:
  • XYZ_1 (array_like) – CIE XYZ_1 tristimulus values of test sample / stimulus in domain [0, 100].
  • XYZ_n (array_like) – Test viewing condition CIE XYZ_n tristimulus values of whitepoint.
  • XYZ_r (array_like) – Reference viewing condition CIE XYZ_r tristimulus values of whitepoint.
  • Y_n (numeric or array_like) – 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 tristimulus values of stimulus.

Return type:

ndarray

Warning

The input domain of that definition is non standard!

Notes

  • Input CIE XYZ_1, CIE XYZ_n and CIE XYZ_r tristimulus values are in domain [0, 100].
  • Output CIE XYZ_2 tristimulus values are 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 or array_like) – \(F\) surround condition.
colour.adaptation.CMCCAT2000_forward(XYZ, XYZ_w, XYZ_wr, L_A1, L_A2, surround=CMCCAT2000_InductionFactors(F=1.0))

Adapts given stimulus CIE XYZ tristimulus values from test viewing conditions to reference viewing conditions using CMCCAT2000 forward chromatic adaptation model.

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

CIE XYZ_c tristimulus values of the stimulus corresponding colour.

Return type:

ndarray

Warning

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

Notes

  • Input CIE XYZ, CIE XYZ_w and CIE XYZ_wr tristimulus values are in domain [0, 100].
  • Output CIE XYZ_c tristimulus values are 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 stimulus corresponding colour CIE XYZ tristimulus values from reference viewing conditions to test viewing conditions using CMCCAT2000 reverse chromatic adaptation model.

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

CIE XYZ_c tristimulus values of the adapted stimulus.

Return type:

ndarray

Warning

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

Notes

  • Input CIE XYZ_c, CIE XYZ_w and CIE XYZ_wr tristimulus values are in domain [0, 100].
  • Output CIE XYZ tristimulus values are 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 stimulus CIE XYZ tristimulus values using given viewing conditions.

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

Parameters:
  • XYZ (array_like) – CIE XYZ tristimulus values of the stimulus to adapt.
  • XYZ_w (array_like) – Source viewing condition CIE XYZ tristimulus values of the whitepoint.
  • XYZ_wr (array_like) – Target viewing condition CIE XYZ tristimulus values of the whitepoint.
  • L_A1 (numeric or array_like) – Luminance of test adapting field \(L_{A1}\) in \(cd/m^2\).
  • L_A2 (numeric or array_like) – 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 stimulus CIE XYZ tristimulus values.

Return type:

ndarray

Warning

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

Notes

  • Input CIE XYZ, CIE XYZ_w and CIE XYZ_wr tristimulus values are in domain [0, 100].
  • Output CIE XYZ tristimulus values are 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.06833960, 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 stimulus CIE XYZ_1 tristimulus values from test viewing conditions to reference viewing conditions using CIE 1994 chromatic adaptation model.

Parameters:
  • XYZ (array_like) – CIE XYZ tristimulus values of test sample / stimulus in domain [0, 100].
  • xy_o1 (array_like) – Chromaticity coordinates \(x_{o1}\) and \(y_{o1}\) of test illuminant and background.
  • xy_o2 (array_like) – 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 tristimulus values of test stimulus.

Return type:

ndarray

Warning

The input domain of that definition is non standard!

Notes

  • Input CIE XYZ_1 tristimulus values are in domain [0, 100].
  • Output CIE XYZ_2 tristimulus values are in domain [0, 100].

Examples

>>> XYZ_1 = np.array([28.00, 21.26, 5.27])
>>> xy_o1 = np.array([0.4476, 0.4074])
>>> xy_o2 = np.array([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...])