Skip to content

Commit

Permalink
Uniquely define common gamma functions using partial.
Browse files Browse the repository at this point in the history
  • Loading branch information
KelSolaar committed Jun 22, 2024
1 parent b2da242 commit 23f045c
Show file tree
Hide file tree
Showing 20 changed files with 169 additions and 132 deletions.
3 changes: 3 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
12 changes: 7 additions & 5 deletions colour/models/rgb/datasets/adobe_rgb_1998.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
Expand Down
14 changes: 6 additions & 8 deletions colour/models/rgb/datasets/adobe_wide_gamut_rgb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
Expand Down
11 changes: 6 additions & 5 deletions colour/models/rgb/datasets/apple_rgb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
Expand Down
14 changes: 6 additions & 8 deletions colour/models/rgb/datasets/best_rgb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
Expand Down
14 changes: 6 additions & 8 deletions colour/models/rgb/datasets/beta_rgb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
Expand Down
12 changes: 7 additions & 5 deletions colour/models/rgb/datasets/cie_rgb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
Expand Down
14 changes: 6 additions & 8 deletions colour/models/rgb/datasets/color_match_rgb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
Expand Down
18 changes: 8 additions & 10 deletions colour/models/rgb/datasets/dci_p3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down
14 changes: 6 additions & 8 deletions colour/models/rgb/datasets/don_rgb_4.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
Expand Down
14 changes: 6 additions & 8 deletions colour/models/rgb/datasets/ekta_space_ps5.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
Expand Down
18 changes: 8 additions & 10 deletions colour/models/rgb/datasets/itur_bt_470.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
Loading

0 comments on commit 23f045c

Please sign in to comment.