Coverage for models/rgb/transfer_functions/panalog.py: 38%
21 statements
« prev ^ index » next coverage.py v7.11.0, created at 2025-11-16 22:49 +1300
« prev ^ index » next coverage.py v7.11.0, created at 2025-11-16 22:49 +1300
1"""
2Panalog Encoding
3================
5Define the *Panalog* encoding.
7- :func:`colour.models.log_encoding_Panalog`
8- :func:`colour.models.log_decoding_Panalog`
10References
11----------
12- :cite:`SonyImageworks2012a` : Sony Imageworks. (2012). make.py. Retrieved
13 November 27, 2014, from
14 https://github.com/imageworks/OpenColorIO-Configs/blob/master/\
15nuke-default/make.py
16"""
18from __future__ import annotations
20import numpy as np
22from colour.hints import ( # noqa: TC001
23 ArrayLike,
24 Domain1,
25 Range1,
26)
27from colour.utilities import as_float, as_float_array, from_range_1, to_domain_1
29__author__ = "Colour Developers"
30__copyright__ = "Copyright 2013 Colour Developers"
31__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause"
32__maintainer__ = "Colour Developers"
33__email__ = "colour-developers@colour-science.org"
34__status__ = "Production"
36__all__ = [
37 "log_encoding_Panalog",
38 "log_decoding_Panalog",
39]
42def log_encoding_Panalog(
43 x: Domain1,
44 black_offset: ArrayLike = 10 ** ((64 - 681) / 444),
45) -> Range1:
46 """
47 Apply the *Panalog* log encoding opto-electronic transfer function (OETF).
49 Parameters
50 ----------
51 x
52 Linear data :math:`x`.
53 black_offset
54 Black offset.
56 Returns
57 -------
58 :class:`numpy.ndarray`
59 *Panalog* non-linear encoded data :math:`y`.
61 Warnings
62 --------
63 These are estimations known to be close enough, the actual log encoding
64 curves are not published.
66 Notes
67 -----
68 +------------+-----------------------+---------------+
69 | **Domain** | **Scale - Reference** | **Scale - 1** |
70 +============+=======================+===============+
71 | ``x`` | 1 | 1 |
72 +------------+-----------------------+---------------+
74 +------------+-----------------------+---------------+
75 | **Range** | **Scale - Reference** | **Scale - 1** |
76 +============+=======================+===============+
77 | ``y`` | 1 | 1 |
78 +------------+-----------------------+---------------+
80 References
81 ----------
82 :cite:`SonyImageworks2012a`
84 Examples
85 --------
86 >>> log_encoding_Panalog(0.18) # doctest: +ELLIPSIS
87 0.3745767...
88 """
90 x = to_domain_1(x)
91 black_offset = as_float_array(black_offset)
93 y = (681 + 444 * np.log10(x * (1 - black_offset) + black_offset)) / 1023
95 return as_float(from_range_1(y))
98def log_decoding_Panalog(
99 y: Domain1,
100 black_offset: ArrayLike = 10 ** ((64 - 681) / 444),
101) -> Range1:
102 """
103 Apply the *Panalog* log decoding inverse opto-electronic transfer function (OETF).
105 Parameters
106 ----------
107 y
108 *Panalog* non-linear encoded data :math:`y`.
109 black_offset
110 Black offset.
112 Returns
113 -------
114 :class:`numpy.ndarray`
115 Linear data :math:`x`.
117 Warnings
118 --------
119 These are estimations known to be close enough, the actual log
120 encoding curves are not published.
122 Notes
123 -----
124 +------------+-----------------------+---------------+
125 | **Domain** | **Scale - Reference** | **Scale - 1** |
126 +============+=======================+===============+
127 | ``y`` | 1 | 1 |
128 +------------+-----------------------+---------------+
130 +------------+-----------------------+---------------+
131 | **Range** | **Scale - Reference** | **Scale - 1** |
132 +============+=======================+===============+
133 | ``x`` | 1 | 1 |
134 +------------+-----------------------+---------------+
136 References
137 ----------
138 :cite:`SonyImageworks2012a`
140 Examples
141 --------
142 >>> log_decoding_Panalog(0.374576791382298) # doctest: +ELLIPSIS
143 0.1...
144 """
146 y = to_domain_1(y)
147 black_offset = as_float_array(black_offset)
149 x = (10 ** ((1023 * y - 681) / 444) - black_offset) / (1 - black_offset)
151 return as_float(from_range_1(x))