Coverage for difference/huang2015.py: 15%

1"""

2 Huang et al. (2015) Power-Functions

3===================================

4

5 Define the *Huang, Cui, Melgosa, Sanchez-Maranon, Li, Luo and Liu (2015)*

6 power-functions for improving the performance of colour-difference formulas.

7

8- :func:`colour.difference.power_function_Huang2015`

9

10 References

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"""

21

22 from __future__ import annotations

23

24 import typing

25

26 import numpy as np

27

28 if typing.TYPE_CHECKING:

29 from colour.hints import ArrayLike, Literal, NDArrayFloat

30

31 from colour.utilities import CanonicalMapping, tsplit, validate_method

32

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"

39

40 __all__ = [

41 "power_function_Huang2015",

42]

43

44 COEFFICIENTS_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)

60 COEFFICIENTS_HUANG2015.__doc__ = """

61*Huang et al. (2015)* power-functions coefficients.

62

63 References

64----------

65:cite:`Huang2015`, :cite:`Li2017`

66

67 Notes

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.

72

73 Aliases:

74

75- 'cie1976': 'CIE 1976'

76- 'cie1994': 'CIE 1994'

77- 'cie2000': 'CIE 2000'

78"""

79 COEFFICIENTS_HUANG2015["cie1976"] = COEFFICIENTS_HUANG2015["CIE 1976"]

80 COEFFICIENTS_HUANG2015["cie1994"] = COEFFICIENTS_HUANG2015["CIE 1994"]

81 COEFFICIENTS_HUANG2015["cie2000"] = COEFFICIENTS_HUANG2015["CIE 2000"]

82

83

84 def 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}`.

107

108 Parameters

109 ----------

110 d_E

111 Computed colour difference array :math:`\\Delta E`.

112 coefficients

113 Coefficients for the power-function.

114

115 Returns

116 -------

117 :class:`numpy.ndarray`

118 Improved :math:`\\Delta E` value.

119

120 References

121 ----------

122 :cite:`Huang2015`, :cite:`Li2017`

123

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 """

130

131 coefficients = validate_method(

132 coefficients,

133 tuple(COEFFICIENTS_HUANG2015),

134 '"{0}" coefficients are invalid, they must be one of {1}!',

135 )

136

137 a, b = tsplit(COEFFICIENTS_HUANG2015[coefficients])

138

139 return a * d_E**b