Processing math: 100%

colour.appearance.hunt Module

Hunt Colour Appearance Model

Defines Hunt 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 5094-5556.
[2]Dr. R.W.G. Hunt, The reproduction of colour, 6th Edition, John Wiley & Sons, published 10 August 2005, ISBN-13: 978-0470024256
class colour.appearance.hunt.Hunt_InductionFactors[source]

Bases: colour.appearance.hunt.Hunt_InductionFactors

Hunt colour appearance model induction factors.

Parameters:
  • N_c (numeric) – Chromatic surround induction factor Nc.
  • N_b (numeric) – Brightness surround induction factor Nb.
  • N_cb (numeric, optional) – Chromatic background induction factor Ncb, approximated using tristimulus values Yw and Yb of respectively the reference white and the background if not specified.
  • N_bb (numeric, optional) – Brightness background induction factor Nbb, approximated using tristimulus values Yw and Yb of respectively the reference white and the background if not specified.
colour.appearance.hunt.HUNT_VIEWING_CONDITIONS = CaseInsensitiveMapping({u'Large Transparencies On Light Boxes': Hunt_InductionFactors(N_c=0.7, N_b=25, N_cb=None, N_bb=None), u'Television & CRT, Dim Surrounds': Hunt_InductionFactors(N_c=1, N_b=25, N_cb=None, N_bb=None), u'normal': Hunt_InductionFactors(N_c=1, N_b=75, N_cb=None, N_bb=None), u'Normal Scenes': Hunt_InductionFactors(N_c=1, N_b=75, N_cb=None, N_bb=None), u'Small Areas, Uniform Background & Surrounds': Hunt_InductionFactors(N_c=1, N_b=300, N_cb=None, N_bb=None), u'small_uniform': Hunt_InductionFactors(N_c=1, N_b=300, N_cb=None, N_bb=None), u'Projected Transparencies, Dark Surrounds': Hunt_InductionFactors(N_c=0.7, N_b=10, N_cb=None, N_bb=None), u'projected_dark': Hunt_InductionFactors(N_c=0.7, N_b=10, N_cb=None, N_bb=None), u'light_boxes': Hunt_InductionFactors(N_c=0.7, N_b=25, N_cb=None, N_bb=None), u'tv_dim': Hunt_InductionFactors(N_c=1, N_b=25, N_cb=None, N_bb=None)})

Reference Hunt colour appearance model viewing conditions.

HUNT_VIEWING_CONDITIONS : dict
(‘Small Areas, Uniform Background & Surrounds’, ‘Normal Scenes’, ‘Television & CRT, Dim Surrounds’, ‘Large Transparencies On Light Boxes’, ‘Projected Transparencies, Dark Surrounds’)

Aliases:

  • ‘small_uniform’: ‘Small Areas, Uniform Background & Surrounds’
  • ‘normal’: ‘Normal Scenes’
  • ‘tv_dim’: ‘Television & CRT, Dim Surrounds’
  • ‘light_boxes’: ‘Large Transparencies On Light Boxes’
  • ‘projected_dark’: ‘Projected Transparencies, Dark Surrounds’
colour.appearance.hunt.XYZ_TO_HPE_MATRIX = array([[ 0.38971, 0.68898, -0.07868], [-0.22981, 1.1834 , 0.04641], [ 0. , 0. , 1. ]])

Hunt colour appearance model CIE XYZ colourspace matrix to Hunt-Pointer-Estevez ργβ colourspace matrix.

XYZ_TO_HPE_MATRIX : array_like, (3, 3)

colour.appearance.hunt.HPE_TO_XYZ_MATRIX = array([[ 1.91019683e+00, -1.11212389e+00, 2.01907957e-01], [ 3.70950088e-01, 6.29054257e-01, -8.05514218e-06], [ 0.00000000e+00, 0.00000000e+00, 1.00000000e+00]])

Hunt colour appearance model Hunt-Pointer-Estevez ργβ colourspace to CIE XYZ colourspace matrix matrix.

HPE_TO_XYZ_MATRIX : array_like, (3, 3)

class colour.appearance.hunt.Hunt_ReferenceSpecification[source]

Bases: colour.appearance.hunt.Hunt_ReferenceSpecification

Defines the Hunt colour appearance model reference specification.

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

Parameters:
  • J (numeric) – Correlate of Lightness J.
  • C_94 (numeric) – Correlate of chroma C94.
  • h_S (numeric) – Hue angle hS in degrees.
  • s (numeric) – Correlate of saturation s.
  • Q (numeric) – Correlate of brightness Q.
  • M_94 (numeric) – Correlate of colourfulness M94.
  • H (numeric) – Hue h quadrature H.
  • H_C (numeric) – Hue h composition HC.
class colour.appearance.hunt.Hunt_Specification[source]

Bases: colour.appearance.hunt.Hunt_Specification

Defines the Hunt 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 J.
  • C (numeric) – Correlate of chroma C94.
  • h (numeric) – Hue angle hS in degrees.
  • s (numeric) – Correlate of saturation s.
  • Q (numeric) – Correlate of brightness Q.
  • M (numeric) – Correlate of colourfulness M94.
  • H (numeric) – Hue h quadrature H.
  • HC (numeric) – Hue h composition HC.
colour.appearance.hunt.XYZ_to_Hunt(XYZ, XYZ_w, XYZ_b, L_A, surround=Hunt_InductionFactors(N_c=1, N_b=75, N_cb=None, N_bb=None), L_AS=None, CCT_w=None, XYZ_p=None, p=None, S=None, S_W=None, helson_judd_effect=False, discount_illuminant=True)[source]

Computes the Hunt colour appearance model correlates.

Parameters:
  • XYZ (array_like, (3,)) – CIE XYZ colourspace matrix of test sample / stimulus in domain [0, 100].
  • XYZ_w (array_like, (3,)) – CIE XYZ colourspace matrix of reference white in domain [0, 100].
  • XYZ_b (array_like, (3,)) – CIE XYZ colourspace matrix of background in domain [0, 100].
  • L_A (numeric) – Adapting field luminance LA in cd/m2.
  • surround (Hunt_InductionFactors, optional) – Surround viewing conditions induction factors.
  • L_AS (numeric, optional) – Scotopic luminance LAS of the illuminant, approximated if not specified.
  • CCT_w (numeric, optional) – Correlated color temperature Tcp: of the illuminant, needed to approximate LAS.
  • XYZ_p (array_like, (3,), optional) – CIE XYZ colourspace matrix of proximal field in domain [0, 100], assumed to be equal to background if not specified.
  • p (numeric, optional) – Simultaneous contrast / assimilation factor p with value in domain [-1, 0] when simultaneous contrast occurs and domain [0, 1] when assimilation occurs.
  • S (numeric, optional) – Scotopic response S to the stimulus, approximated using tristimulus values Y of the stimulus if not specified.
  • S_w (numeric, optional) – Scotopic response Sw for the reference white, approximated using the tristimulus values Yw of the reference white if not specified.
  • helson_judd_effect (bool, optional) – Truth value indicating whether the Helson-Judd effect should be accounted for.
  • discount_illuminant (bool, optional) – Truth value indicating if the illuminant should be discounted.

Warning

The input domain of that definition is non standard!

Notes

  • Input CIE XYZ colourspace matrix is in domain [0, 100].
  • Input CIE XYZ_b colourspace matrix is in domain [0, 100].
  • Input CIE XYZ_w colourspace matrix is in domain [0, 100].
  • Input CIE XYZ_p colourspace matrix is in domain [0, 100].
Returns:Hunt colour appearance model specification.
Return type:Hunt_Specification
Raises:ValueError – If an illegal arguments combination is specified.

Examples

>>> XYZ = np.array([19.01, 20.00, 21.78])
>>> XYZ_w = np.array([95.05, 100.00, 108.88])
>>> XYZ_b = np.array([95.05, 100.00, 108.88])
>>> L_A = 318.31
>>> surround = HUNT_VIEWING_CONDITIONS['Normal Scenes']
>>> CCT_w = 6504.0
>>> XYZ_to_Hunt(XYZ, XYZ_w, XYZ_b, L_A, surround, CCT_w=CCT_w)    
Hunt_Specification(J=30.0462678..., C=0.1210508..., h=269.2737594..., s=0.0199093..., Q=22.2097654..., M=0.1238964..., H=None, HC=None)
colour.appearance.hunt.luminance_level_adaptation_factor(L_A)[source]

Returns the luminance level adaptation factor FL.

Parameters:L_A (numeric) – Adapting field luminance LA in cd/m2.
Returns:Luminance level adaptation factor FL
Return type:numeric

Examples

>>> luminance_level_adaptation_factor(318.31)  
1.1675444...
colour.appearance.hunt.illuminant_scotopic_luminance(L_A, CCT)[source]

Returns the approximate scotopic luminance LAS of the illuminant.

Parameters:
  • L_A (numeric) – Adapting field luminance LA in cd/m2.
  • CCT (numeric) – Correlated color temperature Tcp of the illuminant.
Returns:

Approximate scotopic luminance LAS.

Return type:

numeric

Examples

>>> illuminant_scotopic_luminance(318.31, 6504.0)  
769.9376286...
colour.appearance.hunt.XYZ_to_rgb(XYZ)[source]

Converts from CIE XYZ colourspace to Hunt-Pointer-Estevez ργβ colourspace.

Parameters:XYZ (array_like, (3,)) – CIE XYZ colourspace matrix.
Returns:Hunt-Pointer-Estevez ργβ colourspace matrix.
Return type:ndarray, (3,)

Examples

>>> XYZ = np.array([19.01, 20, 21.78])
>>> XYZ_to_rgb(XYZ)  
array([ 19.4743367...,  20.3101217...,  21.78     ])
colour.appearance.hunt.f_n(x)[source]

Defines the nonlinear response function of the Hunt colour appearance model used to model the nonlinear behavior of various visual responses.

Parameters:x (numeric or array_like) – Visual response variable x.
Returns:Modeled visual response variable x.
Return type:numeric or array_like

Examples

>>> x = np.array([0.23350512, 0.23351103, 0.23355179])
>>> f_n(x)  
array([ 5.8968592...,  5.8969521...,  5.8975927...])
colour.appearance.hunt.chromatic_adaptation(XYZ, XYZ_w, XYZ_b, L_A, F_L, XYZ_p=None, p=None, helson_judd_effect=False, discount_illuminant=True)[source]

Applies chromatic adaptation to given CIE XYZ colourspace matrix.

Parameters:
  • XYZ (array_like, (3,)) – CIE XYZ colourspace matrix of test sample in domain [0, 100].
  • XYZ_b (array_like, (3,)) – CIE XYZ colourspace matrix of background in domain [0, 100].
  • XYZ_w (array_like, (3,)) – CIE XYZ colourspace matrix of reference white in domain [0, 100].
  • L_A (numeric) – Adapting field luminance LA in cd/m2.
  • F_L (numeric) – Luminance adaptation factor FL.
  • XYZ_p (array_like, (3,), optional) – CIE XYZ colourspace matrix of proximal field in domain [0, 100], assumed to be equal to background if not specified.
  • p (numeric, optional) – Simultaneous contrast / assimilation factor p with value in domain [-1, 0] when simultaneous contrast occurs and domain [0, 1] when assimilation occurs.
  • helson_judd_effect (bool, optional) – Truth value indicating whether the Helson-Judd effect should be accounted for.
  • discount_illuminant (bool, optional) – Truth value indicating if the illuminant should be discounted.
Returns:

Adapted CIE XYZ colourspace matrix.

Return type:

ndarray, (3,)

Examples

>>> XYZ = np.array([19.01, 20.00, 21.78])
>>> XYZ_b = np.array([95.05, 100.00, 108.88])
>>> XYZ_w = np.array([95.05, 100.00, 108.88])
>>> L_A = 318.31
>>> F_L = 1.16754446415
>>> chromatic_adaptation(XYZ, XYZ_w, XYZ_b, L_A, F_L)  
array([ 6.8959454...,  6.8959991...,  6.8965708...])
colour.appearance.hunt.adjusted_reference_white_signals(rgb_p, rgb_b, rgb_w, p)[source]

Adjusts the white point for simultaneous chromatic contrast.

Parameters:
  • rgb_p (array_like, (3,)) – Cone signals Hunt-Pointer-Estevez ργβ matrix of the proximal field.
  • rgb_b (array_like, (3,)) – Cone signals Hunt-Pointer-Estevez ργβ matrix of the background.
  • rgb_w (array_like, (3,)) – Cone signals matrix Hunt-Pointer-Estevez ργβ of the reference white.
  • p (numeric) – Simultaneous contrast / assimilation factor p with value in domain [-1, 0] when simultaneous contrast occurs and domain [0, 1] when assimilation occurs.
Returns:

Adjusted cone signals Hunt-Pointer-Estevez ργβ matrix of the reference white.

Return type:

ndarray

Examples

>>> rgb_p = np.array([98.0719355, 101.1375595, 100])
>>> rgb_b = np.array([0.99984505, 0.9998384, 0.99982674])
>>> rgb_w = np.array([97.3732571, 101.5496803, 108.88])
>>> p = 0.1
>>> adjusted_reference_white_signals(rgb_p, rgb_b, rgb_w, p)    
array([ 88.0792742...,  91.8569553...,  98.4876543...])
colour.appearance.hunt.achromatic_post_adaptation_signal(rgb)[source]

Returns the achromatic post adaptation signal A from given Hunt-Pointer-Estevez ργβ colourspace matrix.

Parameters:rgb (array_like, (3,)) – Hunt-Pointer-Estevez ργβ colourspace matrix.
Returns:Achromatic post adaptation signal A.
Return type:numeric

Examples

>>> rgb = np.array([6.89594549, 6.89599915, 6.89657085])
>>> achromatic_post_adaptation_signal(rgb)  
18.9827186...
colour.appearance.hunt.colour_difference_signals(rgb)[source]

Returns the colour difference signals C1, C2 and C3 from given Hunt-Pointer-Estevez ργβ colourspace matrix.

Parameters:rgb (array_like, (3,)) – Hunt-Pointer-Estevez ργβ colourspace matrix.
Returns:Colour difference signals C1, C2 and C3.
Return type:tuple

Examples

>>> rgb = np.array([6.89594549, 6.89599915, 6.89657085])
>>> colour_difference_signals(rgb)  
(-5.3659999...e-05, -0.0005717..., 0.0006253...)
colour.appearance.hunt.hue_angle(C)[source]

Returns the hue angle h from given colour difference signals C.

Parameters:C (array_like) – Colour difference signals C.
Returns:Hue angle h.
Return type:numeric

Examples

>>> C = (-5.3658655819965873e-05,
...      -0.00057169938364687312,
...      0.00062535803946683899)
>>> hue_angle(C)  
269.2737594...
colour.appearance.hunt.eccentricity_factor(hue)[source]

Returns eccentricity factor es from given hue angle h.

Parameters:numeric – Hue angle h.
Returns:Eccentricity factor es.
Return type:float

Examples

>>> eccentricity_factor(269.273759)  
1.1108365...
colour.appearance.hunt.low_luminance_tritanopia_factor(L_A)[source]

Returns the low luminance tritanopia factor Ft from given adapting field luminance LA in cd/m2.

Parameters:L_A (numeric) – Adapting field luminance LA in cd/m2.
Returns:Low luminance tritanopia factor Ft.
Return type:numeric

Examples

>>> low_luminance_tritanopia_factor(318.31)  
0.9996859...
colour.appearance.hunt.yellowness_blueness_response(C, e_s, N_c, N_cb, F_t)[source]

Returns the yellowness / blueness response Myb.

Parameters:
  • C (array_like) – Colour difference signals C.
  • e_s (numeric) – Eccentricity factor es.
  • N_c (numeric) – Chromatic surround induction factor Nc.
  • N_b (numeric) – Brightness surround induction factor Nb.
  • F_t (numeric) – Low luminance tritanopia factor Ft.
Returns:

Yellowness / blueness response Myb.

Return type:

numeric

Examples

>>> C = (-5.3658655819965873e-05,
...      -0.00057169938364687312,
...      0.00062535803946683899)
>>> e_s = 1.1108365048626296
>>> N_c = 1.0
>>> N_cb = 0.72499999999999998
>>> F_t =0.99968593951195
>>> yellowness_blueness_response(C, e_s, N_c, N_cb, F_t)    
-0.0082372...
colour.appearance.hunt.redness_greenness_response(C, e_s, N_c, N_cb)[source]

Returns the redness / greenness response Myb.

Parameters:
  • C (array_like) – Colour difference signals C.
  • e_s (numeric) – Eccentricity factor es.
  • N_c (numeric) – Chromatic surround induction factor Nc.
  • N_b (numeric) – Brightness surround induction factor Nb.
Returns:

Redness / greenness response Mrg.

Return type:

numeric

Examples

>>> C = (-5.3658655819965873e-05,
...      -0.00057169938364687312,
...      0.00062535803946683899)
>>> e_s = 1.1108365048626296
>>> N_c = 1.0
>>> N_cb = 0.72499999999999998
>>> redness_greenness_response(C, e_s, N_c, N_cb)  
-0.0001044...
colour.appearance.hunt.overall_chromatic_response(M_yb, M_rg)[source]

Returns the overall chromatic response M.

Parameters:
  • M_yb (numeric) – Yellowness / blueness response Myb.
  • M_rg (numeric) – Redness / greenness response Mrg.
Returns:

Overall chromatic response M.

Return type:

numeric

Examples

>>> M_yb = -0.008237223618824608
>>> M_rg = -0.00010444758327626432
>>> overall_chromatic_response(M_yb, M_rg)  
0.0082378...
colour.appearance.hunt.saturation_correlate(M, rgb_a)[source]

Returns the saturation correlate s.

Parameters:
  • M (numeric) – Overall chromatic response M.
  • rgb_a (array_like, (3,)) – Adapted Hunt-Pointer-Estevez ργβ colourspace matrix.
Returns:

Saturation correlate s.

Return type:

numeric

Examples

>>> M = 0.008237885787274198
>>> rgb_a = np.array([6.89594549, 6.89599915, 6.89657085])
>>> saturation_correlate(M, rgb_a)  
0.0199093...
colour.appearance.hunt.achromatic_signal(L_AS, S, S_W, N_bb, A_a)[source]

Returns the achromatic signal A.

Parameters:
  • L_AS (numeric) – Scotopic luminance LAS of the illuminant.
  • S (numeric) – Scotopic response S to the stimulus.
  • S_w (numeric) – Scotopic response Sw for the reference white.
  • N_bb (numeric) – Brightness background induction factor Nbb.
  • A_a (numeric) – Achromatic post adaptation signal of the stimulus Aa.
Returns:

Achromatic signal A.

Return type:

numeric

Examples

>>> L_AS = 769.9376286541402
>>> S = 20.0
>>> S_W = 100.0
>>> N_bb = 0.72499999999999998
>>> A_a = 18.982718664838487
>>> achromatic_signal(L_AS, S, S_W, N_bb, A_a)  
15.5068546...
colour.appearance.hunt.brightness_correlate(A, A_w, M, N_b)[source]

Returns the brightness correlate Q.

Parameters:
  • A (numeric) – Achromatic signal A.
  • A_a (numeric) – Achromatic post adaptation signal of the reference white Aw.
  • M (numeric) – Overall chromatic response M.
  • N_b (numeric) – Brightness surround induction factor Nb.
Returns:

Brightness correlate Q.

Return type:

numeric

Examples

>>> A = 15.506854623621885
>>> A_w = 35.718916676317086
>>> M = 0.0082378857872741976
>>> N_b = 75.0
>>> brightness_correlate(A, A_w, M, N_b)  
22.2097654...
colour.appearance.hunt.lightness_correlate(Y_b, Y_w, Q, Q_w)[source]

Returns the Lightness correlate J.

Parameters:
  • Y_b (numeric) – Tristimulus values Yb the background.
  • Y_w (numeric) – Tristimulus values Yb the reference white.
  • Q (numeric) – Brightness correlate Q of the stimulus.
  • Q_w (numeric) – Brightness correlate Q of the reference white.
Returns:

Lightness correlate J.

Return type:

numeric

Examples

>>> Y_b = 100.0
>>> Y_w = 100.0
>>> Q = 22.209765491265024
>>> Q_w = 40.518065821226081
>>> lightness_correlate(Y_b, Y_w, Q, Q_w)  
30.0462678...
colour.appearance.hunt.chroma_correlate(s, Y_b, Y_w, Q, Q_w)[source]

Returns the chroma correlate C94.

Parameters:
  • s (numeric) – Saturation correlate s.
  • Y_b (numeric) – Tristimulus values Yb the background.
  • Y_w (numeric) – Tristimulus values Yb the reference white.
  • Q (numeric) – Brightness correlate Q of the stimulus.
  • Q_w (numeric) – Brightness correlate Q of the reference white.
Returns:

Chroma correlate C94.

Return type:

numeric

Examples

>>> s = 0.0199093206929
>>> Y_b = 100.0
>>> Y_w = 100.0
>>> Q = 22.209765491265024
>>> Q_w = 40.518065821226081
>>> chroma_correlate(s, Y_b, Y_w, Q, Q_w)  
0.1210508...
colour.appearance.hunt.colourfulness_correlate(F_L, C_94)[source]

Returns the colourfulness correlate M94.

Parameters:
  • F_L (numeric) – Luminance adaptation factor FL.
  • numericChroma correlate C94.
Returns:

Colourfulness correlate M94.

Return type:

numeric

Examples

>>> F_L = 1.16754446414718
>>> C_94 = 0.12105083993617581
>>> colourfulness_correlate(F_L, C_94)  
0.1238964...