colour.appearance.hunt Module

Hunt Colour Appearance Model

Defines Hunt colour appearance model objects:

References

[1]Fairchild, M. D. (2013). The Hunt Model. In Color Appearance Models (3rd ed., pp. 5094–5556). Wiley. ASIN:B00DAYO8E2
[2]Hunt, R. W. G. (2004). The Reproduction of Colour (6th ed.). Wiley. ISBN:978-0-470-02425-6
class colour.appearance.hunt.Hunt_InductionFactors[source]

Bases: colour.appearance.hunt.Hunt_InductionFactors

Hunt colour appearance model induction factors.

Parameters:
  • N_c (numeric or array_like) – Chromatic surround induction factor \(N_c\).
  • N_b (numeric or array_like) – Brightness surround induction factor \(N_b\).
  • N_cb (numeric or array_like, optional) – Chromatic background induction factor \(N_{cb}\), approximated using tristimulus values \(Y_w\) and \(Y_b\) of respectively the reference white and the background if not specified.
  • N_bb (numeric or array_like, optional) – Brightness background induction factor \(N_{bb}\), approximated using tristimulus values \(Y_w\) and \(Y_b\) of respectively the reference white and the background if not specified.

Returns a new instance of the Hunt_InductionFactors class.

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 : CaseInsensitiveMapping
{‘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 tristimulus values to Hunt-Pointer-Estevez \(\rho\gamma\beta\) 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 \(\rho\gamma\beta\) colourspace to CIE XYZ tristimulus values 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 Fairchild (2013) reference.

Parameters:
  • J (numeric or array_like) – Correlate of Lightness \(J\).
  • C_94 (numeric or array_like) – Correlate of chroma \(C_94\).
  • h_S (numeric or array_like) – Hue angle \(h_S\) in degrees.
  • s (numeric or array_like) – Correlate of saturation \(s\).
  • Q (numeric or array_like) – Correlate of brightness \(Q\).
  • M_94 (numeric or array_like) – Correlate of colourfulness \(M_94\).
  • H (numeric or array_like) – Hue \(h\) quadrature \(H\).
  • H_C (numeric or array_like) – Hue \(h\) composition \(H_C\).

Create new instance of Hunt_ReferenceSpecification(J, C_94, h_S, s, Q, M_94, H, H_C)

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 Fairchild (2013) reference.

Parameters:
  • J (numeric or array_like) – Correlate of Lightness \(J\).
  • C (numeric or array_like) – Correlate of chroma \(C_94\).
  • h (numeric or array_like) – Hue angle \(h_S\) in degrees.
  • s (numeric or array_like) – Correlate of saturation \(s\).
  • Q (numeric or array_like) – Correlate of brightness \(Q\).
  • M (numeric or array_like) – Correlate of colourfulness \(M_94\).
  • H (numeric or array_like) – Hue \(h\) quadrature \(H\).
  • HC (numeric or array_like) – Hue \(h\) composition \(H_C\).

Notes

  • This specification is the one used in the current model implementation.

Create new instance of Hunt_Specification(J, C, h, s, Q, M, H, 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) – CIE XYZ tristimulus values of test sample / stimulus in domain [0, 100].
  • XYZ_w (array_like) – CIE XYZ tristimulus values of reference white in domain [0, 100].
  • XYZ_b (array_like) – CIE XYZ tristimulus values of background in domain [0, 100].
  • L_A (numeric or array_like) – Adapting field luminance \(L_A\) in \(cd/m^2\).
  • surround (Hunt_InductionFactors, optional) – Surround viewing conditions induction factors.
  • L_AS (numeric or array_like, optional) – Scotopic luminance \(L_{AS}\) of the illuminant, approximated if not specified.
  • CCT_w (numeric or array_like, optional) – Correlated color temperature \(T_{cp}\): of the illuminant, needed to approximate \(L_{AS}\).
  • XYZ_p (array_like, optional) – CIE XYZ tristimulus values of proximal field in domain [0, 100], assumed to be equal to background if not specified.
  • p (numeric or array_like, 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 or array_like, optional) – Scotopic response \(S\) to the stimulus, approximated using tristimulus values \(Y\) of the stimulus if not specified.
  • S_w (numeric or array_like, optional) – Scotopic response \(S_w\) for the reference white, approximated using the tristimulus values \(Y_w\) 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 tristimulus values are in domain [0, 100].
  • Input CIE XYZ_b tristimulus values are in domain [0, 100].
  • Input CIE XYZ_w tristimulus values are in domain [0, 100].
  • Input CIE XYZ_p tristimulus values are 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 \(F_L\).

Parameters:L_A (numeric or array_like) – Adapting field luminance \(L_A\) in \(cd/m^2\).
Returns:Luminance level adaptation factor \(F_L\)
Return type:numeric or ndarray

Examples

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

Returns the approximate scotopic luminance \(L_{AS}\) of the illuminant.

Parameters:
  • L_A (numeric or array_like) – Adapting field luminance \(L_A\) in \(cd/m^2\).
  • CCT (numeric or array_like) – Correlated color temperature \(T_{cp}\) of the illuminant.
Returns:

Approximate scotopic luminance \(L_{AS}\).

Return type:

numeric or ndarray

Examples

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

Converts from CIE XYZ tristimulus values to Hunt-Pointer-Estevez \(\rho\gamma\beta\) colourspace.

Parameters:XYZ (array_like) – CIE XYZ tristimulus values.
Returns:Hunt-Pointer-Estevez \(\rho\gamma\beta\) colourspace.
Return type:ndarray

Examples

>>> XYZ = np.array([19.01, 20.00, 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 behaviour of various visual responses.

Parameters:x (numeric or array_like 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 tristimulus values.

Parameters:
  • XYZ (array_like) – CIE XYZ tristimulus values of test sample in domain [0, 100].
  • XYZ_b (array_like) – CIE XYZ tristimulus values of background in domain [0, 100].
  • XYZ_w (array_like) – CIE XYZ tristimulus values of reference white in domain [0, 100].
  • L_A (numeric or array_like) – Adapting field luminance \(L_A\) in \(cd/m^2\).
  • F_L (numeric or array_like) – Luminance adaptation factor \(F_L\).
  • XYZ_p (array_like, optional) – CIE XYZ tristimulus values of proximal field in domain [0, 100], assumed to be equal to background if not specified.
  • p (numeric or array_like, 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 tristimulus values.

Return type:

ndarray

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) – Cone signals Hunt-Pointer-Estevez \(\rho\gamma\beta\) colourspace array of the proximal field.
  • rgb_b (array_like) – Cone signals Hunt-Pointer-Estevez \(\rho\gamma\beta\) colourspace array of the background.
  • rgb_w (array_like) – Cone signals array Hunt-Pointer-Estevez \(\rho\gamma\beta\) colourspace array of the reference white.
  • p (numeric or array_like) – 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 \(\rho\gamma\beta\) colourspace array of the reference white.

Return type:

ndarray

Examples

>>> rgb_p = np.array([98.07193550, 101.13755950, 100.00000000])
>>> rgb_b = np.array([0.99984505, 0.99983840, 0.99982674])
>>> rgb_w = np.array([97.37325710, 101.54968030, 108.88000000])
>>> 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 \(\rho\gamma\beta\) colourspace array.

Parameters:rgb (array_like) – Hunt-Pointer-Estevez \(\rho\gamma\beta\) colourspace array.
Returns:Achromatic post adaptation signal \(A\).
Return type:numeric or ndarray

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 \(C_1\), \(C_2\) and \(C_3\) from given Hunt-Pointer-Estevez \(\rho\gamma\beta\) colourspace array.

Parameters:rgb (array_like) – Hunt-Pointer-Estevez \(\rho\gamma\beta\) colourspace array.
Returns:Colour difference signals \(C_1\), \(C_2\) and \(C_3\).
Return type:ndarray

Examples

>>> rgb = np.array([6.89594549, 6.89599915, 6.89657085])
>>> colour_difference_signals(rgb)  
array([ -5.3660000...e-05,  -5.7170000...e-04,   6.2536000...e-04])
colour.appearance.hunt.hue_angle(C)[source]

Returns the hue angle \(h\) in degrees from given colour difference signals \(C\).

Parameters:C (array_like) – Colour difference signals \(C\).
Returns:Hue angle \(h\) in degrees.
Return type:numeric or ndarray

Examples

>>> C = np.array([
...     -5.365865581996587e-05,
...     -0.000571699383647,
...     0.000625358039467])
>>> hue_angle(C)  
269.2737594...
colour.appearance.hunt.eccentricity_factor(hue)[source]

Returns eccentricity factor \(e_s\) from given hue angle \(h\) in degrees.

Parameters:hue (numeric or array_like) – Hue angle \(h\) in degrees.
Returns:Eccentricity factor \(e_s\).
Return type:numeric or ndarray

Examples

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

Returns the low luminance tritanopia factor \(F_t\) from given adapting field luminance \(L_A\) in \(cd/m^2\).

Parameters:L_A (numeric or array_like) – Adapting field luminance \(L_A\) in \(cd/m^2\).
Returns:Low luminance tritanopia factor \(F_t\).
Return type:numeric or ndarray

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 \(M_{yb}\).

Parameters:
  • C (array_like) – Colour difference signals \(C\).
  • e_s (numeric or array_like) – Eccentricity factor \(e_s\).
  • N_c (numeric or array_like) – Chromatic surround induction factor \(N_c\).
  • N_cb (numeric or array_like) – Chromatic background induction factor \(N_{cb}\).
  • F_t (numeric or array_like) – Low luminance tritanopia factor \(F_t\).
Returns:

Yellowness / blueness response \(M_{yb}\).

Return type:

numeric or ndarray

Examples

>>> C = np.array([
...     -5.365865581996587e-05,
...     -0.000571699383647,
...     0.000625358039467])
>>> e_s = 1.110836504862630
>>> N_c = 1.0
>>> N_cb = 0.725000000000000
>>> 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 \(M_{yb}\).

Parameters:
  • C (array_like) – Colour difference signals \(C\).
  • e_s (numeric or array_like) – Eccentricity factor \(e_s\).
  • N_c (numeric or array_like) – Chromatic surround induction factor \(N_c\).
  • N_cb (numeric or array_like) – Chromatic background induction factor \(N_{cb}\).
Returns:

Redness / greenness response \(M_{rg}\).

Return type:

numeric or ndarray

Examples

>>> C = np.array([
...     -5.365865581996587e-05,
...     -0.000571699383647,
...     0.000625358039467])
>>> e_s = 1.110836504862630
>>> N_c = 1.0
>>> N_cb = 0.725000000000000
>>> 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 or array_like) – Yellowness / blueness response \(M_{yb}\).
  • M_rg (numeric or array_like) – Redness / greenness response \(M_{rg}\).
Returns:

Overall chromatic response \(M\).

Return type:

numeric or ndarray

Examples

>>> M_yb = -0.008237223618825
>>> M_rg = -0.000104447583276
>>> 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 or array_like) – Overall chromatic response \(M\).
  • rgb_a (array_like) – Adapted Hunt-Pointer-Estevez \(\rho\gamma\beta\) colourspace array.
Returns:

Saturation correlate \(s\).

Return type:

numeric or ndarray

Examples

>>> M = 0.008237885787274
>>> 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 or array_like) – Scotopic luminance \(L_{AS}\) of the illuminant.
  • S (numeric or array_like) – Scotopic response \(S\) to the stimulus.
  • S_w (numeric or array_like) – Scotopic response \(S_w\) for the reference white.
  • N_bb (numeric or array_like) – Brightness background induction factor \(N_{bb}\).
  • A_a (numeric or array_like) – Achromatic post adaptation signal of the stimulus \(A_a\).
Returns:

Achromatic signal \(A\).

Return type:

numeric or ndarray

Examples

>>> L_AS = 769.9376286541402
>>> S = 20.0
>>> S_w = 100.0
>>> N_bb = 0.725000000000000
>>> 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 or array_like) – Achromatic signal \(A\).
  • A_w (numeric or array_like) – Achromatic post adaptation signal of the reference white \(A_w\).
  • M (numeric or array_like) – Overall chromatic response \(M\).
  • N_b (numeric or array_like) – Brightness surround induction factor \(N_b\).
Returns:

Brightness correlate \(Q\).

Return type:

numeric or ndarray

Examples

>>> A = 15.506854623621885
>>> A_w = 35.718916676317086
>>> M = 0.008237885787274
>>> 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 or array_like) – Tristimulus values \(Y_b\) the background.
  • Y_w (numeric or array_like) – Tristimulus values \(Y_b\) the reference white.
  • Q (numeric or array_like) – Brightness correlate \(Q\) of the stimulus.
  • Q_w (numeric or array_like) – Brightness correlate \(Q\) of the reference white.
Returns:

Lightness correlate \(J\).

Return type:

numeric or ndarray

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 \(C_94\).

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

Chroma correlate \(C_94\).

Return type:

numeric or ndarray

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 \(M_94\).

Parameters:
  • F_L (numeric or array_like) – Luminance adaptation factor \(F_L\).
  • C_94 (numeric) – Chroma correlate \(C_94\).
Returns:

Colourfulness correlate \(M_94\).

Return type:

numeric

Examples

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