Coverage for colour/adaptation/datasets/cat.py: 100%
37 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"""
2Chromatic Adaptation Transforms
3===============================
5Define various chromatic adaptation transforms (CAT):
7- :attr:`colour.adaptation.CAT_BIANCO2010`: *Bianco and Schettini (2010)*
8 chromatic adaptation transform.
9- :attr:`colour.adaptation.CAT_BRADFORD`: *Bradford* chromatic adaptation
10 transform.
11- :attr:`colour.adaptation.CAT_CAT02`: *CAT02* chromatic adaptation
12 transform.
13- :attr:`colour.adaptation.CAT_CAT02_BRILL2008`: *Brill and Susstrunk
14 (2008)* corrected CAT02 chromatic adaptation transform.
15- :attr:`colour.adaptation.CAT_CAT16`: *CAT16* chromatic adaptation
16 transform.
17- :attr:`colour.adaptation.CAT_CMCCAT2000`: *CMCCAT2000* chromatic
18 adaptation transform.
19- :attr:`colour.adaptation.CAT_CMCCAT97`: *CMCCAT97* chromatic adaptation
20 transform.
21- :attr:`colour.adaptation.CAT_FAIRCHILD`: *Fairchild* chromatic adaptation
22 transform.
23- :attr:`colour.adaptation.CAT_PC_BIANCO2010`: *Bianco and Schettini PC
24 (2010)* chromatic adaptation transform.
25- :attr:`colour.adaptation.CAT_SHARP`: *Sharp* chromatic adaptation
26 transform.
27- :attr:`colour.adaptation.CAT_VON_KRIES`: *Von Kries* chromatic adaptation
28 transform.
29- :attr:`colour.adaptation.CAT_XYZ_SCALING`: *XYZ Scaling* chromatic
30 adaptation transform.
32References
33----------
34- :cite:`Bianco2010a` : Bianco, S., & Schettini, R. (2010). Two new von
35 Kries based chromatic adaptation transforms found by numerical
36 optimization. Color Research & Application, 35(3), 184-192.
37 doi:10.1002/col.20573
38- :cite:`Brill2008a` : Brill, M. H., & Susstrunk, S. (2008). Repairing
39 gamut problems in CIECAM02: A progress report. Color Research &
40 Application, 33(5), 424-426. doi:10.1002/col.20432
41- :cite:`CIETC1-321994b` : CIE TC 1-32. (1994). CIE 109-1994 A Method of
42 Predicting Corresponding Colours under Different Chromatic and Illuminance
43 Adaptations. Commission Internationale de l'Eclairage.
44 ISBN:978-3-900734-51-0
45- :cite:`Fairchild2013ba` : Fairchild, M. D. (2013). The Nayatani et al.
46 Model. In Color Appearance Models (3rd ed., pp. 4810-5085). Wiley.
47 ISBN:B00DAYO8E2
48- :cite:`Fairchildb` : Fairchild, M. D. (n.d.). Fairchild YSh.
49 http://rit-mcsl.org/fairchild//files/FairchildYSh.zip
50- :cite:`Li2007e` : Li, C., Perales, E., Luo, M. R., & Martinez-verdu, F.
51 (2007). The Problem with CAT02 and Its Correction.
52 https://pdfs.semanticscholar.org/b5a9/0215ad9a1fb6b01f310b3d64305f7c9feb3a.pdf
53- :cite:`Li2017` : Li, C., Li, Z., Wang, Z., Xu, Y., Luo, M. R., Cui, G.,
54 Melgosa, M., Brill, M. H., & Pointer, M. (2017). Comprehensive color
55 solutions: CAM16, CAT16, and CAM16-UCS. Color Research & Application,
56 42(6), 703-718. doi:10.1002/col.22131
57- :cite:`Lindbloom2009g` : Fairchild, M. D. (2013). Chromatic Adaptation
58 Models. In Color Appearance Models (3rd ed., pp. 4179-4252). Wiley.
59 ISBN:B00DAYO8E2
60- :cite:`Nayatani1995a` : Nayatani, Y., Sobagaki, H., & Yano, K. H. T.
61 (1995). Lightness dependency of chroma scales of a nonlinear
62 color-appearance model and its latest formulation. Color Research &
63 Application, 20(3), 156-167. doi:10.1002/col.5080200305
64- :cite:`Westland2012g` : Westland, S., Ripamonti, C., & Cheung, V.
65 (2012). CMCCAT97. In Computational Colour Science Using MATLAB (2nd ed.,
66 p. 80). ISBN:978-0-470-66569-5
67- :cite:`Westland2012k` : Westland, S., Ripamonti, C., & Cheung, V.
68 (2012). CMCCAT2000. In Computational Colour Science Using MATLAB (2nd
69 ed., pp. 83-86). ISBN:978-0-470-66569-5
70- :cite:`Wikipedia2007` : Wikipedia. (2007). CAT02. Retrieved February 24,
71 2014, from http://en.wikipedia.org/wiki/CIECAM02#CAT02
72"""
74from __future__ import annotations
76import typing
78import numpy as np
80if typing.TYPE_CHECKING:
81 from colour.hints import NDArrayFloat
83from colour.utilities import CanonicalMapping
85__author__ = "Colour Developers"
86__copyright__ = "Copyright 2013 Colour Developers"
87__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause"
88__maintainer__ = "Colour Developers"
89__email__ = "colour-developers@colour-science.org"
90__status__ = "Production"
92__all__ = [
93 "CAT_BIANCO2010",
94 "CAT_BRADFORD",
95 "CAT_CAT02",
96 "CAT_CAT02_BRILL2008",
97 "CAT_CAT16",
98 "CAT_CMCCAT2000",
99 "CAT_CMCCAT97",
100 "CAT_FAIRCHILD",
101 "CAT_PC_BIANCO2010",
102 "CAT_SHARP",
103 "CAT_VON_KRIES",
104 "CAT_XYZ_SCALING",
105 "CHROMATIC_ADAPTATION_TRANSFORMS",
106]
108CAT_BIANCO2010: NDArrayFloat = np.array(
109 [
110 [0.8752, 0.2787, -0.1539],
111 [-0.8904, 1.8709, 0.0195],
112 [-0.0061, 0.0162, 0.9899],
113 ]
114)
115"""
116*Bianco and Schettini (2010)* chromatic adaptation transform.
118References
119----------
120:cite:`Bianco2010a`
121"""
123CAT_BRADFORD: NDArrayFloat = np.array(
124 [
125 [0.8951000, 0.2664000, -0.1614000],
126 [-0.7502000, 1.7135000, 0.0367000],
127 [0.0389000, -0.0685000, 1.0296000],
128 ]
129)
130"""
131*Bradford* chromatic adaptation transform.
133References
134----------
135:cite:`Lindbloom2009g`
136"""
138CAT_CAT02: NDArrayFloat = np.array(
139 [
140 [0.7328, 0.4296, -0.1624],
141 [-0.7036, 1.6975, 0.0061],
142 [0.0030, 0.0136, 0.9834],
143 ]
144)
145"""
146*CAT02* chromatic adaptation transform.
148References
149----------
150:cite:`Wikipedia2007`
151"""
153CAT_CAT02_BRILL2008: NDArrayFloat = np.array(
154 [
155 [0.7328, 0.4296, -0.1624],
156 [-0.7036, 1.6975, 0.0061],
157 [0.0000, 0.0000, 1.0000],
158 ]
159)
160"""
161*Brill and Susstrunk (2008)* corrected CAT02 chromatic adaptation
162transform.
164References
165----------
166:cite:`Brill2008a`, :cite:`Li2007e`
167"""
169CAT_CAT16: NDArrayFloat = np.array(
170 [
171 [0.401288, 0.650173, -0.051461],
172 [-0.250268, 1.204414, 0.045854],
173 [-0.002079, 0.048952, 0.953127],
174 ]
175)
176"""
177*CAT16* chromatic adaptation transform.
179References
180----------
181:cite:`Li2017`
182"""
184CAT_CMCCAT2000: NDArrayFloat = np.array(
185 [
186 [0.7982, 0.3389, -0.1371],
187 [-0.5918, 1.5512, 0.0406],
188 [0.0008, 0.0239, 0.9753],
189 ]
190)
191"""
192*CMCCAT2000* chromatic adaptation transform.
194References
195----------
196:cite:`Westland2012k`
197"""
199CAT_CMCCAT97: NDArrayFloat = np.array(
200 [
201 [0.8951, -0.7502, 0.0389],
202 [0.2664, 1.7135, 0.0685],
203 [-0.1614, 0.0367, 1.0296],
204 ]
205)
206"""
207*CMCCAT97* chromatic adaptation transform.
209References
210----------
211:cite:`Westland2012g`
212"""
214CAT_FAIRCHILD: NDArrayFloat = np.array(
215 [
216 [0.8562, 0.3372, -0.1934],
217 [-0.8360, 1.8327, 0.0033],
218 [0.0357, -0.0469, 1.0112],
219 ]
220)
221"""
222*Fairchild* chromatic adaptation transform.
224References
225----------
226:cite:`Fairchildb`
227"""
229CAT_PC_BIANCO2010: NDArrayFloat = np.array(
230 [
231 [0.6489, 0.3915, -0.0404],
232 [-0.3775, 1.3055, 0.0720],
233 [-0.0271, 0.0888, 0.9383],
234 ]
235)
236"""
237*Bianco and Schettini PC (2010)* chromatic adaptation transform.
239References
240----------
241:cite:`Bianco2010a`
243Notes
244-----
245- This chromatic adaptation transform has no negative lobes.
246"""
248CAT_SHARP: NDArrayFloat = np.array(
249 [
250 [1.2694, -0.0988, -0.1706],
251 [-0.8364, 1.8006, 0.0357],
252 [0.0297, -0.0315, 1.0018],
253 ]
254)
255"""
256*Sharp* chromatic adaptation transform.
258References
259----------
260:cite:`Bianco2010a`
261"""
263CAT_VON_KRIES: NDArrayFloat = np.array(
264 [
265 [0.4002400, 0.7076000, -0.0808100],
266 [-0.2263000, 1.1653200, 0.0457000],
267 [0.0000000, 0.0000000, 0.9182200],
268 ]
269)
270"""
271*Von Kries* chromatic adaptation transform.
273References
274----------
275:cite:`CIETC1-321994b`, :cite:`Fairchild2013ba`, :cite:`Lindbloom2009g`,
276:cite:`Nayatani1995a`
277"""
279CAT_XYZ_SCALING: NDArrayFloat = np.reshape(np.array(np.identity(3)), (3, 3))
280"""
281*XYZ Scaling* chromatic adaptation transform.
283References
284----------
285:cite:`Lindbloom2009g`
286"""
288CHROMATIC_ADAPTATION_TRANSFORMS: CanonicalMapping = CanonicalMapping(
289 {
290 "Bianco 2010": CAT_BIANCO2010,
291 "Bianco PC 2010": CAT_PC_BIANCO2010,
292 "Bradford": CAT_BRADFORD,
293 "CAT02": CAT_CAT02,
294 "CAT02 Brill 2008": CAT_CAT02_BRILL2008,
295 "CAT16": CAT_CAT16,
296 "CMCCAT2000": CAT_CMCCAT2000,
297 "CMCCAT97": CAT_CMCCAT97,
298 "Fairchild": CAT_FAIRCHILD,
299 "Sharp": CAT_SHARP,
300 "Von Kries": CAT_VON_KRIES,
301 "XYZ Scaling": CAT_XYZ_SCALING,
302 }
303)
304CHROMATIC_ADAPTATION_TRANSFORMS.__doc__ = """
305Supported chromatic adaptation transforms.
307References
308----------
309:cite:`Bianco2010a`, :cite:`Brill2008a`, :cite:`Fairchildb`,
310:cite:`Li2007e`, :cite:`Li2017`, :cite:`Lindbloom2009g`,
311:cite:`Westland2012g`, :cite:`Westland2012k`, :cite:`Wikipedia2007`
312"""