Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Implement support for "ARRI Wide Gamut 4" and "ARRI LogC4". #1056

Merged
merged 3 commits into from
Nov 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,8 @@ RGB Colourspaces
'ACEScct',
'ACEScg',
'ACESproxy',
'ALEXA Wide Gamut',
'ARRI Wide Gamut 3',
'ARRI Wide Gamut 4',
'Adobe RGB (1998)',
'Adobe Wide Gamut RGB',
'Apple RGB',
Expand Down Expand Up @@ -1017,7 +1018,8 @@ Log Encoding / Decoding
['ACEScc',
'ACEScct',
'ACESproxy',
'ALEXA Log C',
'ARRI LogC3',
'ARRI LogC4',
'Canon Log',
'Canon Log 2',
'Canon Log 3',
Expand Down Expand Up @@ -1052,7 +1054,8 @@ CCTFs Encoding / Decoding
['ACEScc',
'ACEScct',
'ACESproxy',
'ALEXA Log C',
'ARRI LogC3',
'ARRI LogC4',
'ARIB STD-B67',
'Canon Log',
'Canon Log 2',
Expand Down
30 changes: 24 additions & 6 deletions colour/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,10 @@
log_decoding_ACEScct,
oetf_ARIBSTDB67,
oetf_inverse_ARIBSTDB67,
log_encoding_ALEXALogC,
log_decoding_ALEXALogC,
log_encoding_ARRILogC3,
log_decoding_ARRILogC3,
log_encoding_ARRILogC4,
log_decoding_ARRILogC4,
oetf_BlackmagicFilmGeneration5,
oetf_inverse_BlackmagicFilmGeneration5,
log_encoding_CanonLog,
Expand Down Expand Up @@ -270,7 +272,8 @@
RGB_COLOURSPACE_ACESCG,
RGB_COLOURSPACE_ADOBE_RGB1998,
RGB_COLOURSPACE_ADOBE_WIDE_GAMUT_RGB,
RGB_COLOURSPACE_ALEXA_WIDE_GAMUT,
RGB_COLOURSPACE_ARRI_WIDE_GAMUT_3,
RGB_COLOURSPACE_ARRI_WIDE_GAMUT_4,
RGB_COLOURSPACE_APPLE_RGB,
RGB_COLOURSPACE_BEST_RGB,
RGB_COLOURSPACE_BETA_RGB,
Expand Down Expand Up @@ -524,8 +527,10 @@
"log_decoding_ACEScct",
"oetf_ARIBSTDB67",
"oetf_inverse_ARIBSTDB67",
"log_encoding_ALEXALogC",
"log_decoding_ALEXALogC",
"log_encoding_ARRILogC3",
"log_decoding_ARRILogC3",
"log_encoding_ARRILogC4",
"log_decoding_ARRILogC4",
"oetf_BlackmagicFilmGeneration5",
"oetf_inverse_BlackmagicFilmGeneration5",
"log_encoding_CanonLog",
Expand Down Expand Up @@ -668,7 +673,8 @@
"RGB_COLOURSPACE_ACESCG",
"RGB_COLOURSPACE_ADOBE_RGB1998",
"RGB_COLOURSPACE_ADOBE_WIDE_GAMUT_RGB",
"RGB_COLOURSPACE_ALEXA_WIDE_GAMUT",
"RGB_COLOURSPACE_ARRI_WIDE_GAMUT_3",
"RGB_COLOURSPACE_ARRI_WIDE_GAMUT_4",
"RGB_COLOURSPACE_APPLE_RGB",
"RGB_COLOURSPACE_BEST_RGB",
"RGB_COLOURSPACE_BETA_RGB",
Expand Down Expand Up @@ -804,6 +810,10 @@ def __getattr__(self, attribute) -> Any:
# v0.4.2
API_CHANGES["ObjectRenamed"].extend(
[
[
"colour.models.RGB_COLOURSPACE_ALEXA_WIDE_GAMUT",
"colour.models.RGB_COLOURSPACE_ARRI_WIDE_GAMUT_3",
],
[
"colour.models.eotf_inverse_BT2020",
"colour.models.oetf_BT2020",
Expand Down Expand Up @@ -860,6 +870,14 @@ def __getattr__(self, attribute) -> Any:
"colour.models.ootf_inverse_HLG_BT2100",
"colour.models.ootf_inverse_BT2100_HLG",
],
[
"colour.models.log_decoding_ALEXALogC",
"colour.models.log_decoding_ARRILogC3",
],
[
"colour.models.log_encoding_ALEXALogC",
"colour.models.log_encoding_ARRILogC3",
],
]
)
"""Defines the *colour.models* sub-package API changes."""
Expand Down
18 changes: 12 additions & 6 deletions colour/models/rgb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
log_decoding_ACEScct,
oetf_ARIBSTDB67,
oetf_inverse_ARIBSTDB67,
log_encoding_ALEXALogC,
log_decoding_ALEXALogC,
log_encoding_ARRILogC3,
log_decoding_ARRILogC3,
log_encoding_ARRILogC4,
log_decoding_ARRILogC4,
oetf_BlackmagicFilmGeneration5,
oetf_inverse_BlackmagicFilmGeneration5,
log_encoding_CanonLog,
Expand Down Expand Up @@ -165,7 +167,8 @@
RGB_COLOURSPACE_ACESCG,
RGB_COLOURSPACE_ADOBE_RGB1998,
RGB_COLOURSPACE_ADOBE_WIDE_GAMUT_RGB,
RGB_COLOURSPACE_ALEXA_WIDE_GAMUT,
RGB_COLOURSPACE_ARRI_WIDE_GAMUT_3,
RGB_COLOURSPACE_ARRI_WIDE_GAMUT_4,
RGB_COLOURSPACE_APPLE_RGB,
RGB_COLOURSPACE_BEST_RGB,
RGB_COLOURSPACE_BETA_RGB,
Expand Down Expand Up @@ -286,8 +289,10 @@
"log_decoding_ACEScct",
"oetf_ARIBSTDB67",
"oetf_inverse_ARIBSTDB67",
"log_encoding_ALEXALogC",
"log_decoding_ALEXALogC",
"log_encoding_ARRILogC3",
"log_decoding_ARRILogC3",
"log_encoding_ARRILogC4",
"log_decoding_ARRILogC4",
"oetf_BlackmagicFilmGeneration5",
"oetf_inverse_BlackmagicFilmGeneration5",
"log_encoding_CanonLog",
Expand Down Expand Up @@ -430,7 +435,8 @@
"RGB_COLOURSPACE_ACESCG",
"RGB_COLOURSPACE_ADOBE_RGB1998",
"RGB_COLOURSPACE_ADOBE_WIDE_GAMUT_RGB",
"RGB_COLOURSPACE_ALEXA_WIDE_GAMUT",
"RGB_COLOURSPACE_ARRI_WIDE_GAMUT_3",
"RGB_COLOURSPACE_ARRI_WIDE_GAMUT_4",
"RGB_COLOURSPACE_APPLE_RGB",
"RGB_COLOURSPACE_BEST_RGB",
"RGB_COLOURSPACE_BETA_RGB",
Expand Down
29 changes: 25 additions & 4 deletions colour/models/rgb/datasets/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from colour.utilities import CanonicalMapping
from colour.utilities import LazyCanonicalMapping, usage_warning
from .aces import (
RGB_COLOURSPACE_ACES2065_1,
RGB_COLOURSPACE_ACESCC,
Expand All @@ -11,7 +11,10 @@
from .adobe_rgb_1998 import RGB_COLOURSPACE_ADOBE_RGB1998
from .adobe_wide_gamut_rgb import RGB_COLOURSPACE_ADOBE_WIDE_GAMUT_RGB
from .apple_rgb import RGB_COLOURSPACE_APPLE_RGB
from .arri_alexa_wide_gamut import RGB_COLOURSPACE_ALEXA_WIDE_GAMUT
from .arri import (
RGB_COLOURSPACE_ARRI_WIDE_GAMUT_3,
RGB_COLOURSPACE_ARRI_WIDE_GAMUT_4,
)
from .best_rgb import RGB_COLOURSPACE_BEST_RGB
from .beta_rgb import RGB_COLOURSPACE_BETA_RGB
from .blackmagic_design import RGB_COLOURSPACE_BLACKMAGIC_WIDE_GAMUT
Expand Down Expand Up @@ -74,7 +77,7 @@

from colour.models.rgb import RGB_Colourspace

RGB_COLOURSPACES: CanonicalMapping = CanonicalMapping(
RGB_COLOURSPACES: LazyCanonicalMapping = LazyCanonicalMapping(
dict(
sorted(
(colourspace.name, colourspace)
Expand Down Expand Up @@ -112,7 +115,8 @@
"RGB_COLOURSPACE_ACESCG",
"RGB_COLOURSPACE_ADOBE_RGB1998",
"RGB_COLOURSPACE_ADOBE_WIDE_GAMUT_RGB",
"RGB_COLOURSPACE_ALEXA_WIDE_GAMUT",
"RGB_COLOURSPACE_ARRI_WIDE_GAMUT_3",
"RGB_COLOURSPACE_ARRI_WIDE_GAMUT_4",
"RGB_COLOURSPACE_APPLE_RGB",
"RGB_COLOURSPACE_BEST_RGB",
"RGB_COLOURSPACE_BETA_RGB",
Expand Down Expand Up @@ -169,3 +173,20 @@
"RGB_COLOURSPACE_XTREME_RGB",
"RGB_COLOURSPACE_F_GAMUT",
]


# ----------------------------------------------------------------------------#
# --- API Changes and Deprecation Management ---#
# ----------------------------------------------------------------------------#
# v0.4.2
def _alexa_wide_gamut():
usage_warning(
'The "ALEXA Wide Gamut" RGB colourspace has been renamed to '
'"ARRI Wide Gamut 3" for consistency with "ARRI" new naming '
"convention."
)

return RGB_COLOURSPACE_ARRI_WIDE_GAMUT_3


RGB_COLOURSPACES["ALEXA Wide Gamut"] = _alexa_wide_gamut
156 changes: 156 additions & 0 deletions colour/models/rgb/datasets/arri.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
"""
ARRI Colourspaces
=================

Defines the *ARRI* colourspaces:

- :attr:`colour.models.RGB_COLOURSPACE_ARRI_WIDE_GAMUT_3`.
- :attr:`colour.models.RGB_COLOURSPACE_ARRI_WIDE_GAMUT_4`.

References
----------
- :cite:`ARRI2012a` : ARRI. (2012). ALEXA - Log C Curve - Usage in VFX.
https://drive.google.com/open?id=1t73fAG_QpV7hJxoQPYZDWvOojYkYDgvn
- :cite:`Cooper2022` : Cooper, S., & Brendel, H. (2022). ARRI LogC4
Logarithmic Color Space SPECIFICATION. Retrieved October 24, 2022, from
https://www.arri.com/resource/blob/278790/bea879ac0d041a925bed27a096ab3ec2/\
2022-05-arri-logc4-specification-data.pdf
"""

from __future__ import annotations

import numpy as np

from colour.colorimetry import CCS_ILLUMINANTS
from colour.hints import NDArray
from colour.models.rgb import (
RGB_Colourspace,
log_encoding_ARRILogC3,
log_decoding_ARRILogC3,
log_encoding_ARRILogC4,
log_decoding_ARRILogC4,
)

__author__ = "Colour Developers"
__copyright__ = "Copyright 2013 Colour Developers"
__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause"
__maintainer__ = "Colour Developers"
__email__ = "colour-developers@colour-science.org"
__status__ = "Production"

__all__ = [
"PRIMARIES_ARRI_WIDE_GAMUT_3",
"WHITEPOINT_NAME_ARRI_WIDE_GAMUT_3",
"CCS_WHITEPOINT_ARRI_WIDE_GAMUT_3",
"MATRIX_ARRI_WIDE_GAMUT_3_TO_XYZ",
"MATRIX_XYZ_TO_ARRI_WIDE_GAMUT_3",
"RGB_COLOURSPACE_ARRI_WIDE_GAMUT_3",
"PRIMARIES_ARRI_WIDE_GAMUT_4",
"WHITEPOINT_NAME_ARRI_WIDE_GAMUT_4",
"CCS_WHITEPOINT_ARRI_WIDE_GAMUT_4",
"MATRIX_ARRI_WIDE_GAMUT_4_TO_XYZ",
"MATRIX_XYZ_TO_ARRI_WIDE_GAMUT_4",
"RGB_COLOURSPACE_ARRI_WIDE_GAMUT_4",
]

PRIMARIES_ARRI_WIDE_GAMUT_3: NDArray = np.array(
[
[0.6840, 0.3130],
[0.2210, 0.8480],
[0.0861, -0.1020],
]
)
"""*ARRI Wide Gamut 3* colourspace primaries."""

WHITEPOINT_NAME_ARRI_WIDE_GAMUT_3: str = "D65"
"""*ARRI Wide Gamut 3* colourspace whitepoint name."""

CCS_WHITEPOINT_ARRI_WIDE_GAMUT_3: NDArray = CCS_ILLUMINANTS[
"CIE 1931 2 Degree Standard Observer"
][WHITEPOINT_NAME_ARRI_WIDE_GAMUT_3]
"""*ARRI Wide Gamut 3* colourspace whitepoint chromaticity coordinates."""

MATRIX_ARRI_WIDE_GAMUT_3_TO_XYZ: NDArray = np.array(
[
[0.638008, 0.214704, 0.097744],
[0.291954, 0.823841, -0.115795],
[0.002798, -0.067034, 1.153294],
]
)
"""*ARRI Wide Gamut 3* colourspace to *CIE XYZ* tristimulus values matrix."""

MATRIX_XYZ_TO_ARRI_WIDE_GAMUT_3: NDArray = np.array(
[
[1.789066, -0.482534, -0.200076],
[-0.639849, 1.396400, 0.194432],
[-0.041532, 0.082335, 0.878868],
]
)
"""*CIE XYZ* tristimulus values to *ARRI Wide Gamut 3* colourspace matrix."""

RGB_COLOURSPACE_ARRI_WIDE_GAMUT_3: RGB_Colourspace = RGB_Colourspace(
"ARRI Wide Gamut 3",
PRIMARIES_ARRI_WIDE_GAMUT_3,
CCS_WHITEPOINT_ARRI_WIDE_GAMUT_3,
WHITEPOINT_NAME_ARRI_WIDE_GAMUT_3,
MATRIX_ARRI_WIDE_GAMUT_3_TO_XYZ,
MATRIX_XYZ_TO_ARRI_WIDE_GAMUT_3,
log_encoding_ARRILogC3,
log_decoding_ARRILogC3,
)
RGB_COLOURSPACE_ARRI_WIDE_GAMUT_3.__doc__ = """
*ARRI Wide Gamut 3* colourspace.

References
----------
:cite:`ARRI2012a`
"""

PRIMARIES_ARRI_WIDE_GAMUT_4: NDArray = np.array(
[
[0.7347, 0.2653],
[0.1424, 0.8576],
[0.0991, -0.0308],
]
)
"""*ARRI Wide Gamut 4* colourspace primaries."""

WHITEPOINT_NAME_ARRI_WIDE_GAMUT_4: str = "D65"
"""*ARRI Wide Gamut 4* colourspace whitepoint name."""

CCS_WHITEPOINT_ARRI_WIDE_GAMUT_4: NDArray = CCS_ILLUMINANTS[
"CIE 1931 2 Degree Standard Observer"
][WHITEPOINT_NAME_ARRI_WIDE_GAMUT_4]
"""*ARRI Wide Gamut 4* colourspace whitepoint chromaticity coordinates."""

MATRIX_ARRI_WIDE_GAMUT_4_TO_XYZ: NDArray = np.array(
[
[0.7048583204, 0.1297602952, 0.1158373115],
[0.2545241764, 0.7814777327, -0.0360019091],
[0.0000000000, 0.0000000000, 1.0890577508],
]
)
"""*ARRI Wide Gamut 4* colourspace to *CIE XYZ* tristimulus values matrix."""

MATRIX_XYZ_TO_ARRI_WIDE_GAMUT_4: NDArray = np.linalg.inv(
MATRIX_ARRI_WIDE_GAMUT_4_TO_XYZ
)
"""*CIE XYZ* tristimulus values to *ARRI Wide Gamut 4* colourspace matrix."""

RGB_COLOURSPACE_ARRI_WIDE_GAMUT_4: RGB_Colourspace = RGB_Colourspace(
"ARRI Wide Gamut 4",
PRIMARIES_ARRI_WIDE_GAMUT_4,
CCS_WHITEPOINT_ARRI_WIDE_GAMUT_4,
WHITEPOINT_NAME_ARRI_WIDE_GAMUT_4,
MATRIX_ARRI_WIDE_GAMUT_4_TO_XYZ,
MATRIX_XYZ_TO_ARRI_WIDE_GAMUT_4,
log_encoding_ARRILogC4,
log_decoding_ARRILogC4,
)
RGB_COLOURSPACE_ARRI_WIDE_GAMUT_4.__doc__ = """
*ARRI Wide Gamut 4* colourspace.

References
----------
:cite:`Cooper2022`
"""