Coverage for colour/models/rgb/datasets/sharp.py: 100%
24 statements
« prev ^ index » next coverage.py v7.11.0, created at 2025-11-15 19:01 +1300
« prev ^ index » next coverage.py v7.11.0, created at 2025-11-15 19:01 +1300
1"""
2Sharp RGB Colourspace
3=====================
5Define the *Sharp RGB* colourspace:
7- :attr:`colour.models.RGB_COLOURSPACE_SHARP_RGB`
9References
10----------
11- :cite:`Susstrunk2000` : Susstrunk, S. E., Holm, J. M., & Finlayson, G. D.
12 (2000). Chromatic adaptation performance of different RGB sensors. In R.
13 Eschbach & G. G. Marcu (Eds.), Photonics West 2001 - Electronic Imaging
14 (Vol. 4300, Issue January, pp. 172-183). doi:10.1117/12.410788
15- :cite:`Ward2002` : Ward, G., & Eydelberg-Vileshin, E. (2002). Picture
16 Perfect RGB Rendering Using Spectral Prefiltering and Sharp Color
17 Primaries. Eurographics Workshop on Rendering, 117-124.
18 doi:10.2312/EGWR/EGWR02/117-124
19- :cite:`Ward2016` : Borer, T. (2017). Private Discussion with Mansencal, T.
20 and Shaw, N.
21"""
23from __future__ import annotations
25import typing
27import numpy as np
29from colour.colorimetry import CCS_ILLUMINANTS
31if typing.TYPE_CHECKING:
32 from colour.hints import NDArrayFloat
34from colour.models.rgb import (
35 RGB_Colourspace,
36 linear_function,
37 normalised_primary_matrix,
38)
40__author__ = "Colour Developers"
41__copyright__ = "Copyright 2013 Colour Developers"
42__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause"
43__maintainer__ = "Colour Developers"
44__email__ = "colour-developers@colour-science.org"
45__status__ = "Production"
47__all__ = [
48 "PRIMARIES_SHARP_RGB",
49 "WHITEPOINT_NAME_SHARP_RGB",
50 "CCS_WHITEPOINT_SHARP_RGB",
51 "MATRIX_SHARP_RGB_TO_XYZ",
52 "MATRIX_XYZ_TO_SHARP_RGB",
53 "RGB_COLOURSPACE_SHARP_RGB",
54]
56PRIMARIES_SHARP_RGB: NDArrayFloat = np.array(
57 [
58 [0.6898, 0.3206],
59 [0.0736, 0.9003],
60 [0.1166, 0.0374],
61 ]
62)
63"""
64*Sharp RGB* colourspace primaries.
66Notes
67-----
68The primaries were originally derived from the :math:`M_{Sharp}` matrix as
69specified in *Ward and Eydelberg-Vileshin (2002)*:
71 M_Sharp = np.array(
72 [[1.2694, -0.0988, -0.1706],
73 [-0.8364, 1.8006, 0.0357],
74 [0.0297, -0.0315, 1.0018]])
76 P, W = (
77 array([[ 0.68976058, 0.32060751],
78 [ 0.07358274, 0.90029055],
79 [ 0.1166078 , 0.0373923 ]]),
80 array([ 0.33332778, 0.33334544]))
82Private discussion with Ward (2016) confirmed he used the following primaries
83and whitepoint:
85 [0.6898, 0.3206, 0.0736, 0.9003, 0.1166, 0.0374, 1 / 3, 1 / 3]
86"""
88WHITEPOINT_NAME_SHARP_RGB: str = "E"
89"""*Sharp RGB* colourspace whitepoint name."""
91CCS_WHITEPOINT_SHARP_RGB: NDArrayFloat = CCS_ILLUMINANTS[
92 "CIE 1931 2 Degree Standard Observer"
93][WHITEPOINT_NAME_SHARP_RGB]
94"""*Sharp RGB* colourspace whitepoint chromaticity coordinates."""
96MATRIX_SHARP_RGB_TO_XYZ: NDArrayFloat = normalised_primary_matrix(
97 PRIMARIES_SHARP_RGB, CCS_WHITEPOINT_SHARP_RGB
98)
99"""*Sharp RGB* colourspace to *CIE XYZ* tristimulus values matrix."""
101MATRIX_XYZ_TO_SHARP_RGB: NDArrayFloat = np.linalg.inv(MATRIX_SHARP_RGB_TO_XYZ)
102"""*CIE XYZ* tristimulus values to *Sharp RGB* colourspace matrix."""
104RGB_COLOURSPACE_SHARP_RGB: RGB_Colourspace = RGB_Colourspace(
105 "Sharp RGB",
106 PRIMARIES_SHARP_RGB,
107 CCS_WHITEPOINT_SHARP_RGB,
108 WHITEPOINT_NAME_SHARP_RGB,
109 MATRIX_SHARP_RGB_TO_XYZ,
110 MATRIX_XYZ_TO_SHARP_RGB,
111 linear_function,
112 linear_function,
113)
114RGB_COLOURSPACE_SHARP_RGB.__doc__ = """
115*Sharp RGB* colourspace.
117References
118----------
119:cite:`Susstrunk2000`, :cite:`Ward2002`, :cite:`Ward2016`
120"""