Coverage for models/rgb/datasets/eci_rgb_v2.py: 7%

1"""

2 ECI RGB v2 Colourspace

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

4

5 Define the *ECI RGB v2* colourspace:

6

7- :attr:`colour.models.RGB_COLOURSPACE_ECI_RGB_V2`.

8

9 References

10----------

11- :cite:`EuropeanColorInitiative2002a` : European Color Initiative. (2002).

12 ECI RGB v2.

13 http://www.eci.org/_media/downloads/icc_profiles_from_eci/ecirgbv20.zip

14"""

15

16 from __future__ import annotations

17

18 import typing

19 from functools import partial

20

21 import numpy as np

22

23 from colour.colorimetry import CCS_ILLUMINANTS, lightness_CIE1976, luminance_CIE1976

24

25 if typing.TYPE_CHECKING:

26 from colour.hints import (

27 ArrayLike,

28 Callable,

29 NDArrayFloat,

30 )

31

32 from colour.models.rgb import RGB_Colourspace, normalised_primary_matrix

33 from colour.utilities import as_float_array

34

35 __author__ = "Colour Developers"

36 __copyright__ = "Copyright 2013 Colour Developers"

37 __license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause"

38 __maintainer__ = "Colour Developers"

39 __email__ = "colour-developers@colour-science.org"

40 __status__ = "Production"

41

42 __all__ = [

43 "PRIMARIES_ECI_RGB_V2",

44 "WHITEPOINT_NAME_ECI_RGB_V",

45 "CCS_WHITEPOINT_ECI_RGB_V2",

46 "MATRIX_ECI_RGB_V2_TO_XYZ",

47 "MATRIX_XYZ_TO_ECI_RGB_V2",

48 "RGB_COLOURSPACE_ECI_RGB_V2",

49]

50

51 PRIMARIES_ECI_RGB_V2: NDArrayFloat = np.array(

52 [

53 [0.670103092783505, 0.329896907216495],

54 [0.209905660377358, 0.709905660377358],

55 [0.140061791967044, 0.080329557157570],

56 ]

57)

58"""*ECI RGB v2* colourspace primaries."""

59

60 WHITEPOINT_NAME_ECI_RGB_V: str = "D50"

61"""*ECI RGB v2* colourspace whitepoint name."""

62

63 CCS_WHITEPOINT_ECI_RGB_V2: NDArrayFloat = CCS_ILLUMINANTS[

64 "CIE 1931 2 Degree Standard Observer"

65][WHITEPOINT_NAME_ECI_RGB_V]

66"""*ECI RGB v2* colourspace whitepoint chromaticity coordinates."""

67

68 MATRIX_ECI_RGB_V2_TO_XYZ: NDArrayFloat = normalised_primary_matrix(

69 PRIMARIES_ECI_RGB_V2, CCS_WHITEPOINT_ECI_RGB_V2

70)

71"""*ECI RGB v2* colourspace to *CIE XYZ* tristimulus values matrix."""

72

73 MATRIX_XYZ_TO_ECI_RGB_V2: NDArrayFloat = np.linalg.inv(MATRIX_ECI_RGB_V2_TO_XYZ)

74"""*CIE XYZ* tristimulus values to *ECI RGB v2* colourspace matrix."""

75

76

77 def _scale_domain_0_100_range_0_1(a: ArrayLike, callable_: Callable) -> NDArrayFloat:

78 """

79 Scale the input domain of the specified *luminance* :math:`Y` or *Lightness*

80 :math:`L^*` array to [0, 100], call the specified callable, and

81 scales the output range to [0, 1].

82

83 Parameters

84 ----------

85 a

86 *Luminance* :math:`Y` or *Lightness* :math:`L^*` array.

87 callable_

88 *Luminance* :math:`Y` or *Lightness* :math:`L^*` computation

89 definition, i.e., :func:`colour.colorimetry.lightness_CIE1976` or

90 :func:`colour.colorimetry.luminance_CIE1976`. Reference white

91 *luminance* :math:`Y_n` has implicit value of :math:`100\\ cd/m^2`.

92

93 Returns

94 -------

95 :class:`numpy.ndarray`

96 Scaled *luminance* :math:`Y` or *Lightness* :math:`L^*` array.

97 """

98

99 a = as_float_array(a)

100

101 return callable_(a * 100, Y_n=100) / 100

102

103

104 RGB_COLOURSPACE_ECI_RGB_V2: RGB_Colourspace = RGB_Colourspace(

105 "ECI RGB v2",

106 PRIMARIES_ECI_RGB_V2,

107 CCS_WHITEPOINT_ECI_RGB_V2,

108 WHITEPOINT_NAME_ECI_RGB_V,

109 MATRIX_ECI_RGB_V2_TO_XYZ,

110 MATRIX_XYZ_TO_ECI_RGB_V2,

111 partial(_scale_domain_0_100_range_0_1, callable_=lightness_CIE1976),

112 partial(_scale_domain_0_100_range_0_1, callable_=luminance_CIE1976),

113)

114 RGB_COLOURSPACE_ECI_RGB_V2.__doc__ = """

115*ECI RGB v2* colourspace.

116

117 References

118----------

119:cite:`EuropeanColorInitiative2002a`

120"""