diff --git a/README.rst b/README.rst index 29a8006fe9..0d004088cc 100644 --- a/README.rst +++ b/README.rst @@ -1495,9 +1495,12 @@ CCTFs Encoding / Decoding 'F-Log', 'F-Log2', 'Filmic Pro 6', + 'Gamma 1.8', + 'Gamma 2.199', 'Gamma 2.2', 'Gamma 2.4', 'Gamma 2.6', + 'Gamma 2.8', 'ITU-R BT.1886', 'ITU-R BT.2020', 'ITU-R BT.2100 HLG', diff --git a/colour/models/rgb/datasets/adobe_rgb_1998.py b/colour/models/rgb/datasets/adobe_rgb_1998.py index 476148f093..3c9f4da929 100644 --- a/colour/models/rgb/datasets/adobe_rgb_1998.py +++ b/colour/models/rgb/datasets/adobe_rgb_1998.py @@ -14,13 +14,15 @@ from __future__ import annotations -from functools import partial - import numpy as np from colour.colorimetry import CCS_ILLUMINANTS from colour.hints import NDArrayFloat -from colour.models.rgb import RGB_Colourspace, gamma_function +from colour.models.rgb import RGB_Colourspace +from colour.models.rgb.transfer_functions.gamma import ( + decoding_gamma_function_2_199, + encoding_gamma_function_2_199, +) __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" @@ -80,8 +82,8 @@ WHITEPOINT_NAME_ADOBE_RGB1998, MATRIX_ADOBE_RGB1998_TO_XYZ, MATRIX_XYZ_TO_ADOBE_RGB1998, - partial(gamma_function, exponent=1 / (563 / 256)), - partial(gamma_function, exponent=563 / 256), + encoding_gamma_function_2_199, + decoding_gamma_function_2_199, ) RGB_COLOURSPACE_ADOBE_RGB1998.__doc__ = """ *Adobe RGB (1998)* colourspace. diff --git a/colour/models/rgb/datasets/adobe_wide_gamut_rgb.py b/colour/models/rgb/datasets/adobe_wide_gamut_rgb.py index 601c6ebda9..8d5b8a1fcd 100644 --- a/colour/models/rgb/datasets/adobe_wide_gamut_rgb.py +++ b/colour/models/rgb/datasets/adobe_wide_gamut_rgb.py @@ -15,16 +15,14 @@ from __future__ import annotations -from functools import partial - import numpy as np from colour.colorimetry import CCS_ILLUMINANTS from colour.hints import NDArrayFloat -from colour.models.rgb import ( - RGB_Colourspace, - gamma_function, - normalised_primary_matrix, +from colour.models.rgb import RGB_Colourspace, normalised_primary_matrix +from colour.models.rgb.transfer_functions.gamma import ( + decoding_gamma_function_2_199, + encoding_gamma_function_2_199, ) __author__ = "Colour Developers" @@ -77,8 +75,8 @@ WHITEPOINT_NAME_ADOBE_WIDE_GAMUT_RGB, MATRIX_ADOBE_WIDE_GAMUT_RGB_TO_XYZ, MATRIX_XYZ_TO_ADOBE_WIDE_GAMUT_RGB, - partial(gamma_function, exponent=1 / (563 / 256)), - partial(gamma_function, exponent=563 / 256), + encoding_gamma_function_2_199, + decoding_gamma_function_2_199, ) RGB_COLOURSPACE_ADOBE_WIDE_GAMUT_RGB.__doc__ = """ *Adobe Wide Gamut RGB* colourspace. diff --git a/colour/models/rgb/datasets/apple_rgb.py b/colour/models/rgb/datasets/apple_rgb.py index f18ee6487e..1b52aabb42 100644 --- a/colour/models/rgb/datasets/apple_rgb.py +++ b/colour/models/rgb/datasets/apple_rgb.py @@ -14,17 +14,18 @@ from __future__ import annotations -from functools import partial - import numpy as np from colour.colorimetry import CCS_ILLUMINANTS from colour.hints import NDArrayFloat from colour.models.rgb import ( RGB_Colourspace, - gamma_function, normalised_primary_matrix, ) +from colour.models.rgb.transfer_functions.gamma import ( + decoding_gamma_function_1_8, + encoding_gamma_function_1_8, +) __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" @@ -74,8 +75,8 @@ WHITEPOINT_NAME_APPLE_RGB, MATRIX_APPLE_RGB_TO_XYZ, MATRIX_XYZ_TO_APPLE_RGB, - partial(gamma_function, exponent=1 / 1.8), - partial(gamma_function, exponent=1.8), + encoding_gamma_function_1_8, + decoding_gamma_function_1_8, ) RGB_COLOURSPACE_APPLE_RGB.__doc__ = """ *Apple RGB* colourspace. diff --git a/colour/models/rgb/datasets/best_rgb.py b/colour/models/rgb/datasets/best_rgb.py index 89e31484ab..d64c86d9f2 100644 --- a/colour/models/rgb/datasets/best_rgb.py +++ b/colour/models/rgb/datasets/best_rgb.py @@ -14,16 +14,14 @@ from __future__ import annotations -from functools import partial - import numpy as np from colour.colorimetry import CCS_ILLUMINANTS from colour.hints import NDArrayFloat -from colour.models.rgb import ( - RGB_Colourspace, - gamma_function, - normalised_primary_matrix, +from colour.models.rgb import RGB_Colourspace, normalised_primary_matrix +from colour.models.rgb.transfer_functions.gamma import ( + decoding_gamma_function_2_2, + encoding_gamma_function_2_2, ) __author__ = "Colour Developers" @@ -74,8 +72,8 @@ WHITEPOINT_NAME_BEST_RGB, MATRIX_BEST_RGB_TO_XYZ, MATRIX_XYZ_TO_BEST_RGB, - partial(gamma_function, exponent=1 / 2.2), - partial(gamma_function, exponent=2.2), + encoding_gamma_function_2_2, + decoding_gamma_function_2_2, ) RGB_COLOURSPACE_BEST_RGB.__doc__ = """ *Best RGB* colourspace. diff --git a/colour/models/rgb/datasets/beta_rgb.py b/colour/models/rgb/datasets/beta_rgb.py index 555742512a..d3f086231d 100644 --- a/colour/models/rgb/datasets/beta_rgb.py +++ b/colour/models/rgb/datasets/beta_rgb.py @@ -15,16 +15,14 @@ from __future__ import annotations -from functools import partial - import numpy as np from colour.colorimetry import CCS_ILLUMINANTS from colour.hints import NDArrayFloat -from colour.models.rgb import ( - RGB_Colourspace, - gamma_function, - normalised_primary_matrix, +from colour.models.rgb import RGB_Colourspace, normalised_primary_matrix +from colour.models.rgb.transfer_functions.gamma import ( + decoding_gamma_function_2_2, + encoding_gamma_function_2_2, ) __author__ = "Colour Developers" @@ -75,8 +73,8 @@ WHITEPOINT_NAME_BETA_RGB, MATRIX_BETA_RGB_TO_XYZ, MATRIX_XYZ_TO_BETA_RGB, - partial(gamma_function, exponent=1 / 2.2), - partial(gamma_function, exponent=2.2), + encoding_gamma_function_2_2, + decoding_gamma_function_2_2, ) RGB_COLOURSPACE_BETA_RGB.__doc__ = """ *Beta RGB* colourspace. diff --git a/colour/models/rgb/datasets/cie_rgb.py b/colour/models/rgb/datasets/cie_rgb.py index 3f61fc91d9..3070cf5832 100644 --- a/colour/models/rgb/datasets/cie_rgb.py +++ b/colour/models/rgb/datasets/cie_rgb.py @@ -16,13 +16,15 @@ from __future__ import annotations -from functools import partial - import numpy as np from colour.colorimetry import CCS_ILLUMINANTS from colour.hints import NDArrayFloat -from colour.models.rgb import RGB_Colourspace, gamma_function +from colour.models.rgb import RGB_Colourspace +from colour.models.rgb.transfer_functions.gamma import ( + decoding_gamma_function_2_2, + encoding_gamma_function_2_2, +) __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" @@ -84,8 +86,8 @@ WHITEPOINT_NAME_CIE_RGB, MATRIX_CIE_RGB_TO_XYZ, MATRIX_XYZ_TO_CIE_RGB, - partial(gamma_function, exponent=1 / 2.2), - partial(gamma_function, exponent=2.2), + encoding_gamma_function_2_2, + decoding_gamma_function_2_2, ) RGB_COLOURSPACE_CIE_RGB.__doc__ = """ *CIE RGB* colourspace. diff --git a/colour/models/rgb/datasets/color_match_rgb.py b/colour/models/rgb/datasets/color_match_rgb.py index 9ff0f00421..d1a79f09d5 100644 --- a/colour/models/rgb/datasets/color_match_rgb.py +++ b/colour/models/rgb/datasets/color_match_rgb.py @@ -15,16 +15,14 @@ from __future__ import annotations -from functools import partial - import numpy as np from colour.colorimetry import CCS_ILLUMINANTS from colour.hints import NDArrayFloat -from colour.models.rgb import ( - RGB_Colourspace, - gamma_function, - normalised_primary_matrix, +from colour.models.rgb import RGB_Colourspace, normalised_primary_matrix +from colour.models.rgb.transfer_functions.gamma import ( + decoding_gamma_function_1_8, + encoding_gamma_function_1_8, ) __author__ = "Colour Developers" @@ -77,8 +75,8 @@ WHITEPOINT_NAME_COLOR_MATCH_RGB, MATRIX_COLOR_MATCH_RGB_TO_XYZ, MATRIX_XYZ_TO_COLOR_MATCH_RGB, - partial(gamma_function, exponent=1 / 1.8), - partial(gamma_function, exponent=1.8), + encoding_gamma_function_1_8, + decoding_gamma_function_1_8, ) RGB_COLOURSPACE_COLOR_MATCH_RGB.__doc__ = """ *ColorMatch RGB* colourspace. diff --git a/colour/models/rgb/datasets/dci_p3.py b/colour/models/rgb/datasets/dci_p3.py index 9ae2b7fb86..c9414a5873 100644 --- a/colour/models/rgb/datasets/dci_p3.py +++ b/colour/models/rgb/datasets/dci_p3.py @@ -26,16 +26,14 @@ from __future__ import annotations -from functools import partial - import numpy as np from colour.colorimetry import CCS_ILLUMINANTS from colour.hints import NDArrayFloat -from colour.models.rgb import ( - RGB_Colourspace, - gamma_function, - normalised_primary_matrix, +from colour.models.rgb import RGB_Colourspace, normalised_primary_matrix +from colour.models.rgb.transfer_functions.gamma import ( + decoding_gamma_function_2_6, + encoding_gamma_function_2_6, ) __author__ = "Colour Developers" @@ -115,8 +113,8 @@ WHITEPOINT_NAME_DCI_P3, MATRIX_DCI_P3_TO_XYZ, MATRIX_XYZ_TO_DCI_P3, - partial(gamma_function, exponent=1 / 2.6), - partial(gamma_function, exponent=2.6), + encoding_gamma_function_2_6, + decoding_gamma_function_2_6, ) RGB_COLOURSPACE_DCI_P3.__doc__ = """ *DCI-P3* colourspace. @@ -134,8 +132,8 @@ WHITEPOINT_NAME_DCI_P3, MATRIX_DCI_P3_P_TO_XYZ, MATRIX_XYZ_TO_DCI_P3_P, - partial(gamma_function, exponent=1 / 2.6), - partial(gamma_function, exponent=2.6), + encoding_gamma_function_2_6, + decoding_gamma_function_2_6, ) RGB_COLOURSPACE_DCI_P3_P.__doc__ = """ *DCI-P3+* colourspace. diff --git a/colour/models/rgb/datasets/don_rgb_4.py b/colour/models/rgb/datasets/don_rgb_4.py index 25638df6b5..25f289f3c0 100644 --- a/colour/models/rgb/datasets/don_rgb_4.py +++ b/colour/models/rgb/datasets/don_rgb_4.py @@ -14,16 +14,14 @@ from __future__ import annotations -from functools import partial - import numpy as np from colour.colorimetry import CCS_ILLUMINANTS from colour.hints import NDArrayFloat -from colour.models.rgb import ( - RGB_Colourspace, - gamma_function, - normalised_primary_matrix, +from colour.models.rgb import RGB_Colourspace, normalised_primary_matrix +from colour.models.rgb.transfer_functions.gamma import ( + decoding_gamma_function_2_2, + encoding_gamma_function_2_2, ) __author__ = "Colour Developers" @@ -74,8 +72,8 @@ WHITEPOINT_NAME_DON_RGB_4, MATRIX_DON_RGB_4_TO_XYZ, MATRIX_XYZ_TO_DON_RGB_4, - partial(gamma_function, exponent=1 / 2.2), - partial(gamma_function, exponent=2.2), + encoding_gamma_function_2_2, + decoding_gamma_function_2_2, ) RGB_COLOURSPACE_DON_RGB_4.__doc__ = """ *Don RGB 4* colourspace. diff --git a/colour/models/rgb/datasets/ekta_space_ps5.py b/colour/models/rgb/datasets/ekta_space_ps5.py index c0f6de3ddb..6014441a38 100644 --- a/colour/models/rgb/datasets/ekta_space_ps5.py +++ b/colour/models/rgb/datasets/ekta_space_ps5.py @@ -14,16 +14,14 @@ from __future__ import annotations -from functools import partial - import numpy as np from colour.colorimetry import CCS_ILLUMINANTS from colour.hints import NDArrayFloat -from colour.models.rgb import ( - RGB_Colourspace, - gamma_function, - normalised_primary_matrix, +from colour.models.rgb import RGB_Colourspace, normalised_primary_matrix +from colour.models.rgb.transfer_functions.gamma import ( + decoding_gamma_function_2_2, + encoding_gamma_function_2_2, ) __author__ = "Colour Developers" @@ -76,8 +74,8 @@ WHITEPOINT_NAME_EKTA_SPACE_PS_5_V, MATRIX_EKTA_SPACE_PS_5_TO_XYZ, MATRIX_XYZ_TO_EKTA_SPACE_PS_5, - partial(gamma_function, exponent=1 / 2.2), - partial(gamma_function, exponent=2.2), + encoding_gamma_function_2_2, + decoding_gamma_function_2_2, ) RGB_COLOURSPACE_EKTA_SPACE_PS_5.__doc__ = """ *Ekta Space PS 5* colourspace. diff --git a/colour/models/rgb/datasets/itur_bt_470.py b/colour/models/rgb/datasets/itur_bt_470.py index 252c6b62c1..1a0959a563 100644 --- a/colour/models/rgb/datasets/itur_bt_470.py +++ b/colour/models/rgb/datasets/itur_bt_470.py @@ -18,16 +18,14 @@ from __future__ import annotations -from functools import partial - import numpy as np from colour.colorimetry import CCS_ILLUMINANTS from colour.hints import NDArrayFloat -from colour.models.rgb import ( - RGB_Colourspace, - gamma_function, - normalised_primary_matrix, +from colour.models.rgb import RGB_Colourspace, normalised_primary_matrix +from colour.models.rgb.transfer_functions.gamma import ( + decoding_gamma_function_2_8, + encoding_gamma_function_2_8, ) __author__ = "Colour Developers" @@ -93,8 +91,8 @@ WHITEPOINT_NAME_BT470_525, MATRIX_BT470_525_TO_XYZ, MATRIX_XYZ_TO_BT470_525, - partial(gamma_function, exponent=1 / 2.8), - partial(gamma_function, exponent=2.8), + encoding_gamma_function_2_8, + decoding_gamma_function_2_8, ) RGB_COLOURSPACE_BT470_525.__doc__ = """ *Recommendation ITU-R BT.470 - 525* colourspace. @@ -145,8 +143,8 @@ WHITEPOINT_NAME_BT470_625, MATRIX_BT470_625_TO_XYZ, MATRIX_XYZ_TO_BT470_625, - partial(gamma_function, exponent=1 / 2.8), - partial(gamma_function, exponent=2.8), + encoding_gamma_function_2_8, + decoding_gamma_function_2_8, ) RGB_COLOURSPACE_BT470_625.__doc__ = """ *Recommendation ITU-R BT.470 - 625* colourspace. diff --git a/colour/models/rgb/datasets/max_rgb.py b/colour/models/rgb/datasets/max_rgb.py index 5b0206faf4..105a15b094 100644 --- a/colour/models/rgb/datasets/max_rgb.py +++ b/colour/models/rgb/datasets/max_rgb.py @@ -14,16 +14,14 @@ from __future__ import annotations -from functools import partial - import numpy as np from colour.colorimetry import CCS_ILLUMINANTS from colour.hints import NDArrayFloat -from colour.models.rgb import ( - RGB_Colourspace, - gamma_function, - normalised_primary_matrix, +from colour.models.rgb import RGB_Colourspace, normalised_primary_matrix +from colour.models.rgb.transfer_functions.gamma import ( + decoding_gamma_function_2_2, + encoding_gamma_function_2_2, ) __author__ = "Colour Developers" @@ -74,8 +72,8 @@ WHITEPOINT_NAME_MAX_RGB, MATRIX_MAX_RGB_TO_XYZ, MATRIX_XYZ_TO_MAX_RGB, - partial(gamma_function, exponent=1 / 2.2), - partial(gamma_function, exponent=2.2), + encoding_gamma_function_2_2, + decoding_gamma_function_2_2, ) RGB_COLOURSPACE_MAX_RGB.__doc__ = """ *Max RGB* colourspace. diff --git a/colour/models/rgb/datasets/p3_d65.py b/colour/models/rgb/datasets/p3_d65.py index 9fedf2e33e..4af468d2df 100644 --- a/colour/models/rgb/datasets/p3_d65.py +++ b/colour/models/rgb/datasets/p3_d65.py @@ -9,16 +9,14 @@ from __future__ import annotations -from functools import partial - import numpy as np from colour.colorimetry import CCS_ILLUMINANTS from colour.hints import NDArrayFloat -from colour.models.rgb import ( - RGB_Colourspace, - gamma_function, - normalised_primary_matrix, +from colour.models.rgb import RGB_Colourspace, normalised_primary_matrix +from colour.models.rgb.transfer_functions.gamma import ( + decoding_gamma_function_2_6, + encoding_gamma_function_2_6, ) __author__ = "Colour Developers" @@ -69,8 +67,8 @@ WHITEPOINT_NAME_P3_D65, MATRIX_P3_D65_TO_XYZ, MATRIX_XYZ_TO_P3_D65, - partial(gamma_function, exponent=1 / 2.6), - partial(gamma_function, exponent=2.6), + encoding_gamma_function_2_6, + decoding_gamma_function_2_6, ) RGB_COLOURSPACE_P3_D65.__doc__ = """ *P3-D65* colourspace. diff --git a/colour/models/rgb/datasets/russell_rgb.py b/colour/models/rgb/datasets/russell_rgb.py index 3932e3080f..145ed79e4c 100644 --- a/colour/models/rgb/datasets/russell_rgb.py +++ b/colour/models/rgb/datasets/russell_rgb.py @@ -14,16 +14,14 @@ from __future__ import annotations -from functools import partial - import numpy as np from colour.colorimetry.datasets import CCS_ILLUMINANTS from colour.hints import NDArrayFloat -from colour.models.rgb import ( - RGB_Colourspace, - gamma_function, - normalised_primary_matrix, +from colour.models.rgb import RGB_Colourspace, normalised_primary_matrix +from colour.models.rgb.transfer_functions.gamma import ( + decoding_gamma_function_2_2, + encoding_gamma_function_2_2, ) __author__ = "Colour Developers" @@ -74,8 +72,8 @@ WHITEPOINT_NAME_RUSSELL_RGB, MATRIX_RUSSELL_RGB_TO_XYZ, MATRIX_XYZ_TO_RUSSELL_RGB, - partial(gamma_function, exponent=1 / 2.2), - partial(gamma_function, exponent=2.2), + encoding_gamma_function_2_2, + decoding_gamma_function_2_2, ) RGB_COLOURSPACE_RUSSELL_RGB.__doc__ = """ *Russell RGB* colourspace. diff --git a/colour/models/rgb/datasets/smpte_c.py b/colour/models/rgb/datasets/smpte_c.py index 6a509fecf3..2000b40136 100644 --- a/colour/models/rgb/datasets/smpte_c.py +++ b/colour/models/rgb/datasets/smpte_c.py @@ -16,16 +16,14 @@ from __future__ import annotations -from functools import partial - import numpy as np from colour.colorimetry import CCS_ILLUMINANTS from colour.hints import NDArrayFloat -from colour.models.rgb import ( - RGB_Colourspace, - gamma_function, - normalised_primary_matrix, +from colour.models.rgb import RGB_Colourspace, normalised_primary_matrix +from colour.models.rgb.transfer_functions.gamma import ( + decoding_gamma_function_2_2, + encoding_gamma_function_2_2, ) __author__ = "Colour Developers" @@ -76,8 +74,8 @@ WHITEPOINT_NAME_SMPTE_C, MATRIX_SMPTE_C_TO_XYZ, MATRIX_XYZ_TO_SMPTE_C, - partial(gamma_function, exponent=1 / 2.2), - partial(gamma_function, exponent=2.2), + encoding_gamma_function_2_2, + decoding_gamma_function_2_2, ) RGB_COLOURSPACE_SMPTE_C.__doc__ = """ *SMPTE C* colourspace. diff --git a/colour/models/rgb/datasets/xtreme_rgb.py b/colour/models/rgb/datasets/xtreme_rgb.py index 7b1cd4a55a..bd3a52b2c0 100644 --- a/colour/models/rgb/datasets/xtreme_rgb.py +++ b/colour/models/rgb/datasets/xtreme_rgb.py @@ -14,16 +14,14 @@ from __future__ import annotations -from functools import partial - import numpy as np from colour.colorimetry import CCS_ILLUMINANTS from colour.hints import NDArrayFloat -from colour.models.rgb import ( - RGB_Colourspace, - gamma_function, - normalised_primary_matrix, +from colour.models.rgb import RGB_Colourspace, normalised_primary_matrix +from colour.models.rgb.transfer_functions.gamma import ( + decoding_gamma_function_2_2, + encoding_gamma_function_2_2, ) __author__ = "Colour Developers" @@ -74,8 +72,8 @@ WHITEPOINT_NAME_XTREME_RGB, MATRIX_XTREME_RGB_TO_XYZ, MATRIX_XYZ_TO_XTREME_RGB, - partial(gamma_function, exponent=1 / 2.2), - partial(gamma_function, exponent=2.2), + encoding_gamma_function_2_2, + decoding_gamma_function_2_2, ) RGB_COLOURSPACE_XTREME_RGB.__doc__ = """ *Xtreme RGB* colourspace. diff --git a/colour/models/rgb/transfer_functions/__init__.py b/colour/models/rgb/transfer_functions/__init__.py index 378dfbfdd2..a5b851ed7a 100644 --- a/colour/models/rgb/transfer_functions/__init__.py +++ b/colour/models/rgb/transfer_functions/__init__.py @@ -1,5 +1,3 @@ -from functools import partial - from colour.hints import ( Any, ArrayLike, @@ -25,7 +23,22 @@ ) from .common import CV_range, legal_to_full, full_to_legal -from .gamma import gamma_function +from .gamma import ( + gamma_function, + encoding_gamma_function_1_8, + decoding_gamma_function_1_8, + encoding_gamma_function_2_199, + decoding_gamma_function_2_199, + encoding_gamma_function_2_2, + decoding_gamma_function_2_2, + encoding_gamma_function_2_4, + decoding_gamma_function_2_4, + encoding_gamma_function_2_6, + decoding_gamma_function_2_6, + encoding_gamma_function_2_8, + decoding_gamma_function_2_8, +) + from .aces import ( log_encoding_ACESproxy, log_decoding_ACESproxy, @@ -938,9 +951,12 @@ def eotf_inverse( CCTF_ENCODINGS: CanonicalMapping = CanonicalMapping( { - "Gamma 2.2": partial(gamma_function, exponent=1 / 2.2), - "Gamma 2.4": partial(gamma_function, exponent=1 / 2.4), - "Gamma 2.6": partial(gamma_function, exponent=1 / 2.6), + "Gamma 1.8": encoding_gamma_function_1_8, + "Gamma 2.199": encoding_gamma_function_2_199, + "Gamma 2.2": encoding_gamma_function_2_2, + "Gamma 2.4": encoding_gamma_function_2_4, + "Gamma 2.6": encoding_gamma_function_2_6, + "Gamma 2.8": encoding_gamma_function_2_8, "ProPhoto RGB": cctf_encoding_ProPhotoRGB, "RIMM RGB": cctf_encoding_RIMMRGB, "ROMM RGB": cctf_encoding_ROMMRGB, @@ -1035,9 +1051,12 @@ def cctf_encoding( CCTF_DECODINGS: CanonicalMapping = CanonicalMapping( { - "Gamma 2.2": partial(gamma_function, exponent=2.2), - "Gamma 2.4": partial(gamma_function, exponent=2.4), - "Gamma 2.6": partial(gamma_function, exponent=2.6), + "Gamma 1.8": decoding_gamma_function_1_8, + "Gamma 2.199": decoding_gamma_function_2_199, + "Gamma 2.2": decoding_gamma_function_2_2, + "Gamma 2.4": decoding_gamma_function_2_4, + "Gamma 2.6": decoding_gamma_function_2_6, + "Gamma 2.8": decoding_gamma_function_2_8, "ProPhoto RGB": cctf_decoding_ProPhotoRGB, "RIMM RGB": cctf_decoding_RIMMRGB, "ROMM RGB": cctf_decoding_ROMMRGB, diff --git a/colour/models/rgb/transfer_functions/gamma.py b/colour/models/rgb/transfer_functions/gamma.py index 49eb6d7fc9..778b945378 100644 --- a/colour/models/rgb/transfer_functions/gamma.py +++ b/colour/models/rgb/transfer_functions/gamma.py @@ -10,6 +10,8 @@ from __future__ import annotations +from functools import partial + import numpy as np from colour.algebra import spow @@ -25,6 +27,18 @@ __all__ = [ "gamma_function", + "encoding_gamma_function_1_8", + "decoding_gamma_function_1_8", + "encoding_gamma_function_2_199", + "decoding_gamma_function_2_199", + "encoding_gamma_function_2_2", + "decoding_gamma_function_2_2", + "encoding_gamma_function_2_4", + "decoding_gamma_function_2_4", + "encoding_gamma_function_2_6", + "decoding_gamma_function_2_6", + "encoding_gamma_function_2_8", + "decoding_gamma_function_2_8", ] @@ -95,3 +109,22 @@ def gamma_function( return as_float(np.where(a <= 0, a, a**exponent)) else: # negative_number_handling == 'clamp': return as_float(np.where(a <= 0, 0, a**exponent)) + + +encoding_gamma_function_1_8 = partial(gamma_function, exponent=1 / 1.8) +decoding_gamma_function_1_8 = partial(gamma_function, exponent=1.8) + +encoding_gamma_function_2_199 = partial(gamma_function, exponent=1 / (563 / 256)) +decoding_gamma_function_2_199 = partial(gamma_function, exponent=563 / 256) + +encoding_gamma_function_2_2 = partial(gamma_function, exponent=1 / 2.2) +decoding_gamma_function_2_2 = partial(gamma_function, exponent=2.2) + +encoding_gamma_function_2_4 = partial(gamma_function, exponent=1 / 2.4) +decoding_gamma_function_2_4 = partial(gamma_function, exponent=2.4) + +encoding_gamma_function_2_6 = partial(gamma_function, exponent=1 / 2.6) +decoding_gamma_function_2_6 = partial(gamma_function, exponent=2.6) + +encoding_gamma_function_2_8 = partial(gamma_function, exponent=1 / 2.8) +decoding_gamma_function_2_8 = partial(gamma_function, exponent=2.8) diff --git a/docs/index.rst b/docs/index.rst index 9a81fed694..902aa9790e 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1269,9 +1269,12 @@ CCTFs Encoding / Decoding 'F-Log', 'F-Log2', 'Filmic Pro 6', + 'Gamma 1.8', + 'Gamma 2.199', 'Gamma 2.2', 'Gamma 2.4', 'Gamma 2.6', + 'Gamma 2.8', 'ITU-R BT.1886', 'ITU-R BT.2020', 'ITU-R BT.2100 HLG',