Coverage for difference/huang2015.py: 15%
20 statements
« prev ^ index » next coverage.py v7.11.0, created at 2025-11-16 22:49 +1300
« prev ^ index » next coverage.py v7.11.0, created at 2025-11-16 22:49 +1300
1"""
2Huang et al. (2015) Power-Functions
3===================================
5Define the *Huang, Cui, Melgosa, Sanchez-Maranon, Li, Luo and Liu (2015)*
6power-functions for improving the performance of colour-difference formulas.
8- :func:`colour.difference.power_function_Huang2015`
10References
11----------
12- :cite:`Huang2015` : Huang, M., Cui, G., Melgosa, M., Sanchez-Maranon, M.,
13 Li, C., Luo, M. R., & Liu, H. (2015). Power functions improving the
14 performance of color-difference formulas. Optical Society of America,
15 23(1), 597-610. doi:10.1364/OE.23.000597
16- :cite:`Li2017` : Li, C., Li, Z., Wang, Z., Xu, Y., Luo, M. R., Cui, G.,
17 Melgosa, M., Brill, M. H., & Pointer, M. (2017). Comprehensive color
18 solutions: CAM16, CAT16, and CAM16-UCS. Color Research & Application,
19 42(6), 703-718. doi:10.1002/col.22131
20"""
22from __future__ import annotations
24import typing
26import numpy as np
28if typing.TYPE_CHECKING:
29 from colour.hints import ArrayLike, Literal, NDArrayFloat
31from colour.utilities import CanonicalMapping, tsplit, validate_method
33__author__ = "Colour Developers"
34__copyright__ = "Copyright 2013 Colour Developers"
35__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause"
36__maintainer__ = "Colour Developers"
37__email__ = "colour-developers@colour-science.org"
38__status__ = "Production"
40__all__ = [
41 "power_function_Huang2015",
42]
44COEFFICIENTS_HUANG2015: CanonicalMapping = CanonicalMapping(
45 {
46 "CIE 1976": np.array([1.26, 0.55]),
47 "CIE 1994": np.array([1.41, 0.70]),
48 "CIE 2000": np.array([1.43, 0.70]),
49 "CMC": np.array([1.34, 0.66]),
50 "CAM02-LCD": np.array([1.00, 0.85]),
51 "CAM02-SCD": np.array([1.45, 0.75]),
52 "CAM02-UCS": np.array([1.30, 0.75]),
53 "CAM16-UCS": np.array([1.41, 0.63]),
54 "DIN99d": np.array([1.28, 0.74]),
55 "OSA": np.array([3.32, 0.62]),
56 "OSA-GP-Euclidean": np.array([1.52, 0.76]),
57 "ULAB": np.array([1.17, 0.69]),
58 }
59)
60COEFFICIENTS_HUANG2015.__doc__ = """
61*Huang et al. (2015)* power-functions coefficients.
63References
64----------
65:cite:`Huang2015`, :cite:`Li2017`
67Notes
68-----
69- :cite:`Li2017` does not give the coefficients for the *CAM16-LCD* and
70 *CAM16-SCD* colourspaces. *Ronnie Luo* has been contacted to know if
71 they have been computed.
73Aliases:
75- 'cie1976': 'CIE 1976'
76- 'cie1994': 'CIE 1994'
77- 'cie2000': 'CIE 2000'
78"""
79COEFFICIENTS_HUANG2015["cie1976"] = COEFFICIENTS_HUANG2015["CIE 1976"]
80COEFFICIENTS_HUANG2015["cie1994"] = COEFFICIENTS_HUANG2015["CIE 1994"]
81COEFFICIENTS_HUANG2015["cie2000"] = COEFFICIENTS_HUANG2015["CIE 2000"]
84def power_function_Huang2015(
85 d_E: ArrayLike,
86 coefficients: (
87 Literal[
88 "CIE 1976",
89 "CIE 1994",
90 "CIE 2000",
91 "CMC",
92 "CAM02-LCD",
93 "CAM02-SCD",
94 "CAM16-UCS",
95 "DIN99d",
96 "OSA",
97 "OSA-GP-Euclidean",
98 "ULAB",
99 ]
100 | str
101 ) = "CIE 2000",
102) -> NDArrayFloat:
103 """
104 Apply the *Huang, Cui, Melgosa, Sanchez-Maranon, Li, Luo and Liu
105 (2015)* power-function to improve colour difference values for
106 specified coefficients: :math:`d_E^{\\prime}=a \\cdot d_{E}^{b}`.
108 Parameters
109 ----------
110 d_E
111 Computed colour difference array :math:`\\Delta E`.
112 coefficients
113 Coefficients for the power-function.
115 Returns
116 -------
117 :class:`numpy.ndarray`
118 Improved :math:`\\Delta E` value.
120 References
121 ----------
122 :cite:`Huang2015`, :cite:`Li2017`
124 Examples
125 --------
126 >>> d_E = np.array([2.0425, 2.8615, 3.4412])
127 >>> power_function_Huang2015(d_E) # doctest: +ELLIPSIS
128 array([ 2.3574879..., 2.9850503..., 3.3965106...])
129 """
131 coefficients = validate_method(
132 coefficients,
133 tuple(COEFFICIENTS_HUANG2015),
134 '"{0}" coefficients are invalid, they must be one of {1}!',
135 )
137 a, b = tsplit(COEFFICIENTS_HUANG2015[coefficients])
139 return a * d_E**b