colour.appearance.llab Module

LLAB(l:c) Colour Appearance Model

Defines LLAB(l:c) colour appearance model objects:

References

[1]Mark D. Fairchild, Color Appearance Models, 3nd Edition, The Wiley-IS&T Series in Imaging Science and Technology, published June 2013, ASIN: B00DAYO8E2, locations 6019-6178.
[2]Luo, M. R., & Morovic, J., Two Unsolved Issues in Colour Management – Colour Appearance and Gamut Mapping, 5th International Conference on High Technology: Imaging Science and Technology – Evolution & Promise published 1996, pp. 136–147.
[3]Luo, M. R., Lo, M. C., & Kuo, W. G., The LLAB (l:c) colour model, Color Research & Application, Volume 21, Issue 6, pages 412–429, December 1996
class colour.appearance.llab.LLAB_InductionFactors[source]

Bases: colour.appearance.llab.LLAB_InductionFactors

LLAB(l:c) colour appearance model induction factors.

Parameters:
  • D (numeric) – Discounting-the-Illuminant factor \(D\) in domain [0, 1].
  • F_S (numeric) – Surround induction factor \(F_S\).
  • F_L (numeric) – Lightness induction factor \(F_L\).
  • F_C (numeric) – Chroma induction factor \(F_C\).
colour.appearance.llab.LLAB_VIEWING_CONDITIONS = CaseInsensitiveMapping({u'35mm Projection Transparency, Dark Surround': LLAB_InductionFactors(D=0.7, F_S=4, F_L=1, F_C=1), u'Cut Sheet Transparency, Dim Surround': LLAB_InductionFactors(D=1, F_S=5, F_L=1, F_C=1.1), u'ref_average_4_plus': LLAB_InductionFactors(D=1, F_S=3, F_L=0, F_C=1), u'Reference Samples & Images, Average Surround, Subtending < 4': LLAB_InductionFactors(D=1, F_S=3, F_L=1, F_C=1), u'Television & VDU Displays, Dim Surround': LLAB_InductionFactors(D=0.7, F_S=3.5, F_L=1, F_C=1), u'sheet_dim': LLAB_InductionFactors(D=1, F_S=5, F_L=1, F_C=1.1), u'projected_dark': LLAB_InductionFactors(D=0.7, F_S=4, F_L=1, F_C=1), u'ref_average_4_minus': LLAB_InductionFactors(D=1, F_S=3, F_L=1, F_C=1), u'Reference Samples & Images, Average Surround, Subtending > 4': LLAB_InductionFactors(D=1, F_S=3, F_L=0, F_C=1), u'tv_dim': LLAB_InductionFactors(D=0.7, F_S=3.5, F_L=1, F_C=1)})

Reference LLAB(l:c) colour appearance model viewing conditions.

LLAB_VIEWING_CONDITIONS : dict
(‘Reference Samples & Images, Average Surround, Subtending > 4’, ‘Reference Samples & Images, Average Surround, Subtending < 4’, ‘Television & VDU Displays, Dim Surround’, ‘Cut Sheet Transparency, Dim Surround’:, ‘35mm Projection Transparency, Dark Surround’)

Aliases:

  • ‘ref_average_4_plus’: ‘Reference Samples & Images, Average Surround, Subtending > 4’
  • ‘ref_average_4_minus’: ‘Reference Samples & Images, Average Surround, Subtending < 4’
  • ‘tv_dim’: ‘Television & VDU Displays, Dim Surround’
  • ‘sheet_dim’: ‘Cut Sheet Transparency, Dim Surround’
  • ‘projected_dark’: ‘35mm Projection Transparency, Dark Surround’
colour.appearance.llab.LLAB_XYZ_TO_RGB_MATRIX = array([[ 0.8951, 0.2664, -0.1614], [-0.7502, 1.7135, 0.0367], [ 0.0389, -0.0685, 1.0296]])

LLAB(l:c) colour appearance model CIE XYZ colourspace matrix to normalised cone responses matrix.

LLAB_XYZ_TO_RGB_MATRIX : array_like, (3, 3)

colour.appearance.llab.LLAB_RGB_TO_XYZ_MATRIX = array([[ 0.987 , -0.1471, 0.16 ], [ 0.4323, 0.5184, 0.0493], [-0.0085, 0.04 , 0.9685]])

LLAB(l:c) colour appearance model normalised cone responses to CIE XYZ colourspace matrix.

Notes

  • This matrix has been rounded on purpose to 4 decimals so that we keep consistency with Mark D. Fairchild implementation results.

LLAB_RGB_TO_XYZ_MATRIX : array_like, (3, 3)

class colour.appearance.llab.LLAB_ReferenceSpecification[source]

Bases: colour.appearance.llab.LLAB_ReferenceSpecification

Defines the LLAB(l:c) colour appearance model reference specification.

This specification has field names consistent with Mark D. Fairchild reference.

Parameters:
  • L_L (numeric) – Correlate of Lightness \(L_L\).
  • Ch_L (numeric) – Correlate of chroma \(Ch_L\).
  • h_L (numeric) – Hue angle \(h_L\) in degrees.
  • s_L (numeric) – Correlate of saturation \(s_L\).
  • C_L (numeric) – Correlate of colourfulness \(C_L\).
  • HC (numeric) – Hue \(h\) composition \(H^C\).
  • A_L (numeric) – Opponent signal \(A_L\).
  • B_L (numeric) – Opponent signal \(B_L\).
class colour.appearance.llab.LLAB_Specification[source]

Bases: colour.appearance.llab.LLAB_Specification

Defines the LLAB(l:c) colour appearance model specification.

This specification has field names consistent with the remaining colour appearance models in colour.appearance but diverge from Mark D. Fairchild reference.

Parameters:
  • J (numeric) – Correlate of Lightness \(L_L\).
  • C (numeric) – Correlate of chroma \(Ch_L\).
  • h (numeric) – Hue angle \(h_L\) in degrees.
  • s (numeric) – Correlate of saturation \(s_L\).
  • M (numeric) – Correlate of colourfulness \(C_L\).
  • HC (numeric) – Hue \(h\) composition \(H^C\).
  • a (numeric) – Opponent signal \(A_L\).
  • b (numeric) – Opponent signal \(B_L\).
colour.appearance.llab.XYZ_to_LLAB(XYZ, XYZ_0, Y_b, L, surround=LLAB_InductionFactors(D=1, F_S=3, F_L=1, F_C=1))[source]

Computes the LLAB(L:c) colour appearance model correlates.

Parameters:
  • XYZ (array_like, (3,)) – CIE XYZ colourspace matrix of test sample / stimulus in domain [0, 100].
  • XYZ_0 (array_like, (3,)) – CIE XYZ colourspace matrix of reference white in domain [0, 100].
  • Y_b (numeric) – Luminance factor of the background in \(cd/m^2\).
  • L (numeric) – Absolute luminance \(L\) of reference white in \(cd/m^2\).
  • surround (LLAB_InductionFactors, optional) – Surround viewing conditions induction factors.
Returns:

LLAB(L:c) colour appearance model specification.

Return type:

LLAB_Specification

Warning

The output domain of that definition is non standard!

Notes

  • Input CIE XYZ colourspace matrix is in domain [0, 100].
  • Input CIE XYZ_0 colourspace matrix is in domain [0, 100].

Examples

>>> XYZ = np.array([19.01, 20, 21.78])
>>> XYZ_0 = np.array([95.05, 100, 108.88])
>>> Y_b = 20.0
>>> L = 318.31
>>> surround = LLAB_VIEWING_CONDITIONS['ref_average_4_minus']
>>> XYZ_to_LLAB(XYZ, XYZ_0, Y_b, L, surround)  
LLAB_Specification(J=37.3680474..., C=0.0086506..., h=229.4635727..., s=0.0002314..., M=0.0183832..., HC=None, a=-0.0119478..., b=-0.0139711...)
colour.appearance.llab.XYZ_to_RGB_LLAB(XYZ)[source]

Converts from CIE XYZ colourspace to normalised cone responses.

Parameters:XYZ (array_like, (3,)) – CIE XYZ colourspace matrix.
Returns:Normalised cone responses.
Return type:ndarray, (3,)

Examples

>>> XYZ = np.array([19.01, 20, 21.78])
>>> XYZ_to_RGB_LLAB(XYZ)  
array([ 0.9414279...,  1.0404012...,  1.0897088...])
colour.appearance.llab.chromatic_adaptation(RGB, RGB_0, RGB_0r, Y, D=1)[source]

Applies chromatic adaptation to given RGB normalised cone responses matrix.

Parameters:
  • RGB (array_like, (3,)) – RGB normalised cone responses matrix of test sample / stimulus.
  • RGB_0 (array_like, (3,)) – RGB normalised cone responses matrix of reference white.
  • RGB_0r (array_like, (3,)) – RGB normalised cone responses matrix of reference illuminant CIE Standard Illuminant D Series D65.
  • Y (numeric) – Tristimulus values \(Y\) of the stimulus.
  • D (numeric, optional) – Discounting-the-Illuminant factor in domain [0, 1].
Returns:

Adapted CIE XYZ colourspace matrix.

Return type:

ndarray, (3,)

Examples

>>> RGB = np.array([0.94142795, 1.0404012, 1.08970885])
>>> RGB_0 = np.array([0.94146023, 1.04039386, 1.08950293])
>>> RGB_0r = np.array([0.94146023, 1.04039386, 1.08950293])
>>> Y = 20.0
>>> chromatic_adaptation(RGB, RGB_0, RGB_0r, Y)  
array([ 19.0099957...,  20.0009186...,  21.7799386...])
colour.appearance.llab.f(x, F_S)[source]

Defines the nonlinear response function of the LLAB(L:c) colour appearance model used to model the nonlinear behavior of various visual responses.

Parameters:
  • x (numeric or array_like) – Visual response variable \(x\).
  • F_S (numeric) – Surround induction factor \(F_S\).
Returns:

Modeled visual response variable \(x\).

Return type:

numeric or array_like

Examples

>>> x = np.array([0.23350512, 0.23351103, 0.23355179])
>>> f(0.20000918623399996, 3)  
array(0.5848125...)
colour.appearance.llab.opponent_colour_dimensions(XYZ, Y_b, F_S, F_L)[source]

Returns opponent colour dimensions from given adapted CIE XYZ colourspace matrix.

The opponent colour dimensions are based on a modified CIE Lab colourspace formulae.

Parameters:
  • XYZ (array_like, (3,)) – Adapted CIE XYZ colourspace matrix.
  • Y_b (numeric) – Luminance factor of the background in \(cd/m^2\).
  • F_S (numeric) – Surround induction factor \(F_S\).
  • F_L (numeric) – Lightness induction factor \(F_L\).
Returns:

Opponent colour dimensions.

Return type:

ndarray, (3,)

Examples

>>> XYZ = np.array([19.00999572, 20.00091862, 21.77993863])
>>> Y_b = 20.0
>>> F_S = 3.0
>>> F_L = 1.0
>>> opponent_colour_dimensions(XYZ, Y_b, F_S, F_L)  
array([  3.7368047...e+01,  -4.4986443...e-03,  -5.2604647...e-03])
colour.appearance.llab.hue_angle(a, b)[source]

Returns the hue angle \(h_L\) in degrees.

Parameters:
  • a (numeric) – Opponent colour dimension \(a\).
  • b (numeric) – Opponent colour dimension \(b\).
Returns:

Hue angle \(h_L\) in degrees.

Return type:

numeric

Examples

>>> hue_angle(-4.49864756e-03, -5.26046353e-03)  
229.4635727...
colour.appearance.llab.chroma_correlate(a, b)[source]

Returns the correlate of chroma \(Ch_L\).

Parameters:
  • a (numeric) – Opponent colour dimension \(a\).
  • b (numeric) – Opponent colour dimension \(b\).
Returns:

Correlate of chroma \(Ch_L\).

Return type:

numeric

Examples

>>> a = -4.49864756e-03
>>> b = -5.26046353e-03
>>> chroma_correlate(a, b)  
0.0086506...
colour.appearance.llab.colourfulness_correlate(L, L_L, Ch_L, F_C)[source]

Returns the correlate of colourfulness \(C_L\).

Parameters:
  • L (numeric) – Absolute luminance \(L\) of reference white in \(cd/m^2\).
  • L_L (numeric) – Correlate of Lightness \(L_L\).
  • Ch_L (numeric) – Correlate of chroma \(Ch_L\).
  • F_C (numeric) – Chroma induction factor \(F_C\).
Returns:

Correlate of colourfulness \(C_L\).

Return type:

numeric

Examples

>>> L = 318.31
>>> L_L = 37.368047493928195
>>> Ch_L = 0.0086506620517144972
>>> F_C = 1.0
>>> colourfulness_correlate(L, L_L, Ch_L, F_C)  
0.0183832...
colour.appearance.llab.saturation_correlate(Ch_L, L_L)[source]

Returns the correlate of saturation \(S_L\).

Parameters:
  • Ch_L (numeric) – Correlate of chroma \(Ch_L\).
  • L_L (numeric) – Correlate of Lightness \(L_L\).
Returns:

Correlate of saturation \(S_L\).

Return type:

numeric

Examples

>>> Ch_L = 0.0086506620517144972
>>> L_L = 37.368047493928195
>>> saturation_correlate(Ch_L, L_L)  
0.0002314...
colour.appearance.llab.final_opponent_signals(C_L, h_L)[source]

Returns the final opponent signals \(A_L\) and \(B_L\).

Parameters:
  • C_L (numeric) – Correlate of colourfulness \(C_L\).
  • h_L (numeric) – Correlate of hue \(h_L\) in radians.
Returns:

Final opponent signals \(A_L\) and \(B_L\).

Return type:

tuple

Examples

>>> C_L = 0.0183832899143
>>> h_L = 4.004894857014253
>>> final_opponent_signals(C_L, h_L)  
(-0.0119478..., -0.0139711...)