-
-
Notifications
You must be signed in to change notification settings - Fork 259
/
srgb.py
100 lines (85 loc) · 2.74 KB
/
srgb.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
"""
SRGB Colourspace
================
Define the *sRGB* colourspace:
- :attr:`colour.models.RGB_COLOURSPACE_sRGB`.
References
----------
- :cite:`InternationalElectrotechnicalCommission1999a` : International
Electrotechnical Commission. (1999). IEC 61966-2-1:1999 - Multimedia
systems and equipment - Colour measurement and management - Part 2-1:
Colour management - Default RGB colour space - sRGB (p. 51).
https://webstore.iec.ch/publication/6169
- :cite:`InternationalTelecommunicationUnion2015i` : International
Telecommunication Union. (2015). Recommendation ITU-R BT.709-6 - Parameter
values for the HDTV standards for production and international programme
exchange BT Series Broadcasting service (pp. 1-32).
https://www.itu.int/dms_pubrec/itu-r/rec/bt/\
R-REC-BT.709-6-201506-I!!PDF-E.pdf
"""
from __future__ import annotations
import numpy as np
from colour.colorimetry import CCS_ILLUMINANTS
from colour.hints import NDArrayFloat
from colour.models.rgb import RGB_Colourspace, eotf_inverse_sRGB, eotf_sRGB
__author__ = "Colour Developers"
__copyright__ = "Copyright 2013 Colour Developers"
__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause"
__maintainer__ = "Colour Developers"
__email__ = "colour-developers@colour-science.org"
__status__ = "Production"
__all__ = [
"PRIMARIES_sRGB",
"WHITEPOINT_NAME_sRGB",
"CCS_WHITEPOINT_sRGB",
"MATRIX_sRGB_TO_XYZ",
"MATRIX_XYZ_TO_sRGB",
"RGB_COLOURSPACE_sRGB",
]
PRIMARIES_sRGB: NDArrayFloat = np.array(
[
[0.6400, 0.3300],
[0.3000, 0.6000],
[0.1500, 0.0600],
]
)
"""*sRGB* colourspace primaries."""
WHITEPOINT_NAME_sRGB: str = "D65"
"""*sRGB* colourspace whitepoint name."""
CCS_WHITEPOINT_sRGB: NDArrayFloat = CCS_ILLUMINANTS[
"CIE 1931 2 Degree Standard Observer"
][WHITEPOINT_NAME_sRGB]
"""*sRGB* colourspace whitepoint chromaticity coordinates."""
MATRIX_sRGB_TO_XYZ: NDArrayFloat = np.array(
[
[0.4124, 0.3576, 0.1805],
[0.2126, 0.7152, 0.0722],
[0.0193, 0.1192, 0.9505],
]
)
"""*sRGB* colourspace to *CIE XYZ* tristimulus values matrix."""
MATRIX_XYZ_TO_sRGB: NDArrayFloat = np.array(
[
[3.2406, -1.5372, -0.4986],
[-0.9689, 1.8758, 0.0415],
[0.0557, -0.2040, 1.0570],
]
)
"""*CIE XYZ* tristimulus values to *sRGB* colourspace matrix."""
RGB_COLOURSPACE_sRGB: RGB_Colourspace = RGB_Colourspace(
"sRGB",
PRIMARIES_sRGB,
CCS_WHITEPOINT_sRGB,
WHITEPOINT_NAME_sRGB,
MATRIX_sRGB_TO_XYZ,
MATRIX_XYZ_TO_sRGB,
eotf_inverse_sRGB,
eotf_sRGB,
)
RGB_COLOURSPACE_sRGB.__doc__ = """
*sRGB* colourspace.
References
----------
:cite:`InternationalElectrotechnicalCommission1999a`,
:cite:`InternationalTelecommunicationUnion2015i`
"""