• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

colour-science / colour / 12452776384

22 Dec 2024 08:43AM UTC coverage: 97.524% (-1.7%) from 99.255%
12452776384

push

github

KelSolaar
Code formatting.

41247 of 42294 relevant lines covered (97.52%)

0.98 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.15
/colour/models/rgb/datasets/sharp.py
1
"""
2
Sharp RGB Colourspace
3
=====================
4

5
Define the *Sharp RGB* colourspace:
6

7
-   :attr:`colour.models.RGB_COLOURSPACE_SHARP_RGB`
8

9
References
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
"""
22

23
from __future__ import annotations
1✔
24

25
import typing
1✔
26

27
import numpy as np
1✔
28

29
from colour.colorimetry import CCS_ILLUMINANTS
1✔
30

31
if typing.TYPE_CHECKING:
1✔
32
    from colour.hints import NDArrayFloat
×
33

34
from colour.models.rgb import (
1✔
35
    RGB_Colourspace,
36
    linear_function,
37
    normalised_primary_matrix,
38
)
39

40
__author__ = "Colour Developers"
1✔
41
__copyright__ = "Copyright 2013 Colour Developers"
1✔
42
__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause"
1✔
43
__maintainer__ = "Colour Developers"
1✔
44
__email__ = "colour-developers@colour-science.org"
1✔
45
__status__ = "Production"
1✔
46

47
__all__ = [
1✔
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
]
55

56
PRIMARIES_SHARP_RGB: NDArrayFloat = np.array(
1✔
57
    [
58
        [0.6898, 0.3206],
59
        [0.0736, 0.9003],
60
        [0.1166, 0.0374],
61
    ]
62
)
63
"""
1✔
64
*Sharp RGB* colourspace primaries.
65

66
Notes
67
-----
68
The primaries were originally derived from the :math:`M_{Sharp}` matrix as
69
given in *Ward and Eydelberg-Vileshin (2002)*:
70

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]])
75

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]))
81

82
Private discussion with Ward (2016) confirmed he used the following primaries
83
and whitepoint:
84

85
    [0.6898, 0.3206, 0.0736, 0.9003, 0.1166, 0.0374, 1 / 3, 1 / 3]
86
"""
87

88
WHITEPOINT_NAME_SHARP_RGB: str = "E"
1✔
89
"""*Sharp RGB* colourspace whitepoint name."""
1✔
90

91
CCS_WHITEPOINT_SHARP_RGB: NDArrayFloat = CCS_ILLUMINANTS[
1✔
92
    "CIE 1931 2 Degree Standard Observer"
93
][WHITEPOINT_NAME_SHARP_RGB]
94
"""*Sharp RGB* colourspace whitepoint chromaticity coordinates."""
1✔
95

96
MATRIX_SHARP_RGB_TO_XYZ: NDArrayFloat = normalised_primary_matrix(
1✔
97
    PRIMARIES_SHARP_RGB, CCS_WHITEPOINT_SHARP_RGB
98
)
99
"""*Sharp RGB* colourspace to *CIE XYZ* tristimulus values matrix."""
1✔
100

101
MATRIX_XYZ_TO_SHARP_RGB: NDArrayFloat = np.linalg.inv(MATRIX_SHARP_RGB_TO_XYZ)
1✔
102
"""*CIE XYZ* tristimulus values to *Sharp RGB* colourspace matrix."""
1✔
103

104
RGB_COLOURSPACE_SHARP_RGB: RGB_Colourspace = RGB_Colourspace(
1✔
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
)
114
RGB_COLOURSPACE_SHARP_RGB.__doc__ = """
1✔
115
*Sharp RGB* colourspace.
116

117
References
118
----------
119
:cite:`Susstrunk2000`, :cite:`Ward2002`, :cite:`Ward2016`
120
"""
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc