Skip to content

Commit

Permalink
Update colour.XYZ_to_RGB and colour.RGB_to_XYZ definition signatu…
Browse files Browse the repository at this point in the history
…res.

References #1127
  • Loading branch information
KelSolaar committed Mar 31, 2023
1 parent be836ad commit efe56ea
Show file tree
Hide file tree
Showing 13 changed files with 309 additions and 203 deletions.
14 changes: 5 additions & 9 deletions colour/characterisation/aces_it.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,7 @@ def k(x: NDArrayFloat, y: NDArrayFloat) -> DTypeFloat:
NPM,
chromatic_adaptation_transform,
)
E_rgb = XYZ_to_RGB(
XYZ,
RGB_COLOURSPACE_ACES2065_1.whitepoint,
RGB_COLOURSPACE_ACES2065_1.whitepoint,
RGB_COLOURSPACE_ACES2065_1.matrix_XYZ_to_RGB,
)
E_rgb = XYZ_to_RGB(XYZ, RGB_COLOURSPACE_ACES2065_1)

return from_range_1(E_rgb)

Expand Down Expand Up @@ -864,9 +859,10 @@ def matrix_idt(
| str
| None = "CAT02",
additional_data: bool = False,
) -> Tuple[NDArrayFloat, NDArrayFloat, NDArrayFloat, NDArrayFloat] | Tuple[
NDArrayFloat, NDArrayFloat
]:
) -> (
Tuple[NDArrayFloat, NDArrayFloat, NDArrayFloat, NDArrayFloat]
| Tuple[NDArrayFloat, NDArrayFloat]
):
"""
Compute an *Input Device Transform* (IDT) matrix for given camera *RGB*
spectral sensitivities, illuminant, training data, standard observer colour
Expand Down
5 changes: 2 additions & 3 deletions colour/examples/characterisation/examples_colour_checkers.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@
for name, xyY in data.items():
RGB = colour.XYZ_to_RGB(
colour.xyY_to_XYZ(xyY),
colour.RGB_COLOURSPACES["sRGB"],
illuminant,
colour.CCS_ILLUMINANTS["CIE 1931 2 Degree Standard Observer"]["D65"],
colour.RGB_COLOURSPACES["sRGB"].matrix_XYZ_to_RGB,
"Bradford",
colour.RGB_COLOURSPACES["sRGB"].cctf_encoding,
apply_cctf_encoding=True,
)

RGB_i = [int(round(x * 255)) if x >= 0 else 0 for x in np.ravel(RGB)]
Expand Down
14 changes: 2 additions & 12 deletions colour/examples/models/examples_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,7 @@
D65 = colour.CCS_ILLUMINANTS["CIE 1931 2 Degree Standard Observer"]["D65"]
print(
colour.XYZ_to_RGB(
XYZ,
D65,
colour.RGB_COLOURSPACES["sRGB"].whitepoint,
colour.RGB_COLOURSPACES["sRGB"].matrix_XYZ_to_RGB,
"Bradford",
colour.RGB_COLOURSPACES["sRGB"].cctf_encoding,
XYZ, colour.RGB_COLOURSPACES["sRGB"], D65, "Bradford", True
)
)

Expand All @@ -85,12 +80,7 @@
)
print(
colour.RGB_to_XYZ(
RGB,
colour.RGB_COLOURSPACES["sRGB"].whitepoint,
D65,
colour.RGB_COLOURSPACES["sRGB"].matrix_RGB_to_XYZ,
"Bradford",
colour.RGB_COLOURSPACES["sRGB"].cctf_decoding,
RGB, colour.RGB_COLOURSPACES["sRGB"], D65, "Bradford", True
)
)

Expand Down
14 changes: 2 additions & 12 deletions colour/graph/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,22 +756,12 @@ def mired_to_CCT_D_uv(mired: ArrayLike) -> NDArrayFloat:
(
"CIE XYZ",
"RGB",
partial(
XYZ_to_RGB,
illuminant_XYZ=_RGB_COLOURSPACE_DEFAULT.whitepoint,
illuminant_RGB=_RGB_COLOURSPACE_DEFAULT.whitepoint,
matrix_XYZ_to_RGB=_RGB_COLOURSPACE_DEFAULT.matrix_XYZ_to_RGB,
),
partial(XYZ_to_RGB, colourspace=_RGB_COLOURSPACE_DEFAULT),
),
(
"RGB",
"CIE XYZ",
partial(
RGB_to_XYZ,
illuminant_RGB=_RGB_COLOURSPACE_DEFAULT.whitepoint,
illuminant_XYZ=_RGB_COLOURSPACE_DEFAULT.whitepoint,
matrix_RGB_to_XYZ=_RGB_COLOURSPACE_DEFAULT.matrix_RGB_to_XYZ,
),
partial(RGB_to_XYZ, colourspace=_RGB_COLOURSPACE_DEFAULT),
),
(
"RGB",
Expand Down
7 changes: 2 additions & 5 deletions colour/models/rgb/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,12 @@ def XYZ_to_sRGB(
array([ 0.7057393..., 0.1924826..., 0.2235416...])
"""

sRGB = RGB_COLOURSPACES["sRGB"]

return XYZ_to_RGB(
XYZ,
RGB_COLOURSPACES["sRGB"],
illuminant,
sRGB.whitepoint,
sRGB.matrix_XYZ_to_RGB,
chromatic_adaptation_transform,
sRGB.cctf_encoding if apply_cctf_encoding else None,
apply_cctf_encoding,
)


Expand Down
5 changes: 1 addition & 4 deletions colour/models/rgb/ictcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,13 +519,10 @@ def XYZ_to_ICtCp(
array([ 0.5924279..., -0.0374073..., 0.2512267...])
"""

BT2020 = RGB_COLOURSPACES["ITU-R BT.2020"]

RGB = XYZ_to_RGB(
XYZ,
RGB_COLOURSPACES["ITU-R BT.2020"],
illuminant,
BT2020.whitepoint,
BT2020.matrix_XYZ_to_RGB,
chromatic_adaptation_transform,
)

Expand Down
Loading

0 comments on commit efe56ea

Please sign in to comment.