Fix typo in ITU-R BT.1361 implementation + added doctest cases
@@ -22,6 +22,10 @@ from colour.utilities import (
)
+L_LINEAR_THRESHOLD_POSITIVE = 0.018
+L_LINEAR_THRESHOLD_NEGATIVE = -0.0045
+
+
def oetf_BT1361_extended(L):
"""
Define the opto-electronic transfer functions (OETF) for *ITU-R BT.1361* extended
@@ -35,7 +39,7 @@ def oetf_BT1361_extended(L):
Returns
-------
:class:`numpy.floating` or :class:`numpy.ndarray`
- Corresponding non-linear primary signal :math:`V`.
+ Corresponding non-linear primary signal :math:`E'`.
Notes
-----
@@ -45,11 +49,11 @@ def oetf_BT1361_extended(L):
| ``L`` | [-0.25, 1.33] | [-0.25, 1.33] |
+------------+-----------------------+---------------+
- +------------+-----------------------+---------------+
+ +------------+-----------------------+-------------------+
| **Range** | **Scale - Reference** | **Scale - 1** |
- +============+=======================+===============+
- | ``E`` | [-1, -1] | [-1, 1] |
- +------------+-----------------------+---------------+
+ +============+=======================+===================+
+ | ``Ep'`` | [-0.25, 1.152...] | [-0.25, 1.152...] |
+ +------------+-----------------------+-------------------+
References
----------
@@ -59,23 +63,31 @@ def oetf_BT1361_extended(L):
--------
>>> oetf_BT1361_extended(0.18) # doctest: +ELLIPSIS
0.4090077288641...
+ >>> oetf_BT1361_extended(-0.25) # doctest: +ELLIPSIS
+ -0.25
+ >>> oetf_BT1361_extended(1.33) # doctest: +ELLIPSIS
+ 1.1504846663972...
"""
L = as_float_array(L)
- E = np.where(
+ Ep = np.where(
L >= 0,
np.where(
- L >= 0.018,
- 1.099 * spow(L, 0.45) - 0.099, # [0.018, 1.33] range
- 4.500 * L, # [0, 0.018] range
+ L >= L_LINEAR_THRESHOLD_POSITIVE,
+ # L in [0.018, 1.33] range
+ 1.099 * spow(L, 0.45) - 0.099,
+ # L in [0, 0.018] range
+ 4.500 * L,
),
np.where(
- L <= -0.0045,
- 4.500 * L, # [-0.0045, 0] range
- -(spow(1.099 * (-4 * L), 0.45) - 0.099)
- / 4, # [-0.25, -0.0045] range
+ L <= L_LINEAR_THRESHOLD_NEGATIVE,
+ # L in [-0.25, -0.0045] range
+ -(1.099 * spow(-4 * L, 0.45) - 0.099)
+ / 4,
+ # L in [-0.0045, 0] range
+ 4.500 * L,
),
)
- return as_float(E)
+ return as_float(Ep)
