Skip to content

Commit 20e0ba0

Browse files
committed
Update colour.XYZ_to_RGB and colour.RGB_to_XYZ definition signatures.
Closes #1127
1 parent 8d577ee commit 20e0ba0

File tree

19 files changed

+348
-301
lines changed

19 files changed

+348
-301
lines changed

colour/characterisation/aces_it.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@
8383
from colour.io import read_sds_from_csv_file
8484
from colour.models import XYZ_to_Jzazbz, XYZ_to_Lab, XYZ_to_xy, xy_to_XYZ
8585
from colour.models.rgb import (
86+
RGB_Colourspace,
8687
RGB_COLOURSPACE_ACES2065_1,
8788
RGB_to_XYZ,
8889
XYZ_to_RGB,
89-
normalised_primary_matrix,
9090
)
9191
from colour.temperature import CCT_to_xy_CIE_D
9292
from colour.utilities import (
@@ -259,23 +259,18 @@ def k(x: NDArrayFloat, y: NDArrayFloat) -> DTypeFloat:
259259
E_rgb *= S_FLARE_FACTOR
260260

261261
if chromatic_adaptation_transform is not None:
262-
xy = XYZ_to_xy(sd_to_XYZ(illuminant) / 100)
263-
NPM = normalised_primary_matrix(
264-
RGB_COLOURSPACE_ACES2065_1.primaries, xy
265-
)
266262
XYZ = RGB_to_XYZ(
267263
E_rgb,
268-
xy,
264+
RGB_Colourspace(
265+
"~ACES2065-1",
266+
RGB_COLOURSPACE_ACES2065_1.primaries,
267+
XYZ_to_xy(sd_to_XYZ(illuminant) / 100),
268+
illuminant.name,
269+
),
269270
RGB_COLOURSPACE_ACES2065_1.whitepoint,
270-
NPM,
271271
chromatic_adaptation_transform,
272272
)
273-
E_rgb = XYZ_to_RGB(
274-
XYZ,
275-
RGB_COLOURSPACE_ACES2065_1.whitepoint,
276-
RGB_COLOURSPACE_ACES2065_1.whitepoint,
277-
RGB_COLOURSPACE_ACES2065_1.matrix_XYZ_to_RGB,
278-
)
273+
E_rgb = XYZ_to_RGB(XYZ, RGB_COLOURSPACE_ACES2065_1)
279274

280275
return from_range_1(E_rgb)
281276

@@ -864,9 +859,10 @@ def matrix_idt(
864859
| str
865860
| None = "CAT02",
866861
additional_data: bool = False,
867-
) -> Tuple[NDArrayFloat, NDArrayFloat, NDArrayFloat, NDArrayFloat] | Tuple[
868-
NDArrayFloat, NDArrayFloat
869-
]:
862+
) -> (
863+
Tuple[NDArrayFloat, NDArrayFloat, NDArrayFloat, NDArrayFloat]
864+
| Tuple[NDArrayFloat, NDArrayFloat]
865+
):
870866
"""
871867
Compute an *Input Device Transform* (IDT) matrix for given camera *RGB*
872868
spectral sensitivities, illuminant, training data, standard observer colour

colour/examples/characterisation/examples_colour_checkers.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,10 @@
3636
for name, xyY in data.items():
3737
RGB = colour.XYZ_to_RGB(
3838
colour.xyY_to_XYZ(xyY),
39+
colour.RGB_COLOURSPACES["sRGB"],
3940
illuminant,
40-
colour.CCS_ILLUMINANTS["CIE 1931 2 Degree Standard Observer"]["D65"],
41-
colour.RGB_COLOURSPACES["sRGB"].matrix_XYZ_to_RGB,
4241
"Bradford",
43-
colour.RGB_COLOURSPACES["sRGB"].cctf_encoding,
42+
apply_cctf_encoding=True,
4443
)
4544

4645
RGB_i = [int(round(x * 255)) if x >= 0 else 0 for x in np.ravel(RGB)]

colour/examples/models/examples_models.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,7 @@
6767
D65 = colour.CCS_ILLUMINANTS["CIE 1931 2 Degree Standard Observer"]["D65"]
6868
print(
6969
colour.XYZ_to_RGB(
70-
XYZ,
71-
D65,
72-
colour.RGB_COLOURSPACES["sRGB"].whitepoint,
73-
colour.RGB_COLOURSPACES["sRGB"].matrix_XYZ_to_RGB,
74-
"Bradford",
75-
colour.RGB_COLOURSPACES["sRGB"].cctf_encoding,
70+
XYZ, colour.RGB_COLOURSPACES["sRGB"], D65, "Bradford", True
7671
)
7772
)
7873

@@ -85,12 +80,7 @@
8580
)
8681
print(
8782
colour.RGB_to_XYZ(
88-
RGB,
89-
colour.RGB_COLOURSPACES["sRGB"].whitepoint,
90-
D65,
91-
colour.RGB_COLOURSPACES["sRGB"].matrix_RGB_to_XYZ,
92-
"Bradford",
93-
colour.RGB_COLOURSPACES["sRGB"].cctf_decoding,
83+
RGB, colour.RGB_COLOURSPACES["sRGB"], D65, "Bradford", True
9484
)
9585
)
9686

colour/graph/conversion.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -756,22 +756,12 @@ def mired_to_CCT_D_uv(mired: ArrayLike) -> NDArrayFloat:
756756
(
757757
"CIE XYZ",
758758
"RGB",
759-
partial(
760-
XYZ_to_RGB,
761-
illuminant_XYZ=_RGB_COLOURSPACE_DEFAULT.whitepoint,
762-
illuminant_RGB=_RGB_COLOURSPACE_DEFAULT.whitepoint,
763-
matrix_XYZ_to_RGB=_RGB_COLOURSPACE_DEFAULT.matrix_XYZ_to_RGB,
764-
),
759+
partial(XYZ_to_RGB, colourspace=_RGB_COLOURSPACE_DEFAULT),
765760
),
766761
(
767762
"RGB",
768763
"CIE XYZ",
769-
partial(
770-
RGB_to_XYZ,
771-
illuminant_RGB=_RGB_COLOURSPACE_DEFAULT.whitepoint,
772-
illuminant_XYZ=_RGB_COLOURSPACE_DEFAULT.whitepoint,
773-
matrix_RGB_to_XYZ=_RGB_COLOURSPACE_DEFAULT.matrix_RGB_to_XYZ,
774-
),
764+
partial(RGB_to_XYZ, colourspace=_RGB_COLOURSPACE_DEFAULT),
775765
),
776766
(
777767
"RGB",

colour/models/rgb/common.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,12 @@ def XYZ_to_sRGB(
8989
array([ 0.7057393..., 0.1924826..., 0.2235416...])
9090
"""
9191

92-
sRGB = RGB_COLOURSPACES["sRGB"]
93-
9492
return XYZ_to_RGB(
9593
XYZ,
94+
RGB_COLOURSPACES["sRGB"],
9695
illuminant,
97-
sRGB.whitepoint,
98-
sRGB.matrix_XYZ_to_RGB,
9996
chromatic_adaptation_transform,
100-
sRGB.cctf_encoding if apply_cctf_encoding else None,
97+
apply_cctf_encoding,
10198
)
10299

103100

@@ -166,13 +163,10 @@ def sRGB_to_XYZ(
166163
array([ 0.2065429..., 0.1219794..., 0.0513714...])
167164
"""
168165

169-
sRGB = RGB_COLOURSPACES["sRGB"]
170-
171166
return RGB_to_XYZ(
172167
RGB,
173-
sRGB.whitepoint,
168+
RGB_COLOURSPACES["sRGB"],
174169
illuminant,
175-
sRGB.matrix_RGB_to_XYZ,
176170
chromatic_adaptation_transform,
177-
sRGB.cctf_decoding if apply_cctf_decoding else None,
171+
apply_cctf_decoding,
178172
)

colour/models/rgb/ictcp.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -519,13 +519,10 @@ def XYZ_to_ICtCp(
519519
array([ 0.5924279..., -0.0374073..., 0.2512267...])
520520
"""
521521

522-
BT2020 = RGB_COLOURSPACES["ITU-R BT.2020"]
523-
524522
RGB = XYZ_to_RGB(
525523
XYZ,
524+
RGB_COLOURSPACES["ITU-R BT.2020"],
526525
illuminant,
527-
BT2020.whitepoint,
528-
BT2020.matrix_XYZ_to_RGB,
529526
chromatic_adaptation_transform,
530527
)
531528

@@ -655,13 +652,10 @@ def ICtCp_to_XYZ(
655652

656653
RGB = ICtCp_to_RGB(ICtCp, method, L_p)
657654

658-
BT2020 = RGB_COLOURSPACES["ITU-R BT.2020"]
659-
660655
XYZ = RGB_to_XYZ(
661656
RGB,
662-
BT2020.whitepoint,
657+
RGB_COLOURSPACES["ITU-R BT.2020"],
663658
illuminant,
664-
BT2020.matrix_RGB_to_XYZ,
665659
chromatic_adaptation_transform,
666660
)
667661

0 commit comments

Comments
 (0)