Coverage for colour/models/rgb/transfer_functions/smpte_240m.py: 100%
21 statements
« prev ^ index » next coverage.py v7.11.0, created at 2025-11-15 19:01 +1300
« prev ^ index » next coverage.py v7.11.0, created at 2025-11-15 19:01 +1300
1"""
2SMPTE 240M
3==========
5Define the *SMPTE 240M* opto-electrical transfer function (OETF) and
6electro-optical transfer function (EOTF).
8- :func:`colour.models.oetf_SMPTE240M`
9- :func:`colour.models.eotf_SMPTE240M`
11References
12----------
13- :cite:`SocietyofMotionPictureandTelevisionEngineers1999b` : Society of
14 Motion Picture and Television Engineers. (1999). ANSI/SMPTE 240M-1995 -
15 Signal Parameters - 1125-Line High-Definition Production Systems (pp. 1-7).
16 http://car.france3.mars.free.fr/HD/INA-%2026%20jan%2006/\
17SMPTE%20normes%20et%20confs/s240m.pdf
18"""
20from __future__ import annotations
22import numpy as np
24from colour.algebra import spow
25from colour.hints import ( # noqa: TC001
26 Domain1,
27 Range1,
28)
29from colour.utilities import as_float, domain_range_scale, from_range_1, to_domain_1
31__author__ = "Colour Developers"
32__copyright__ = "Copyright 2013 Colour Developers"
33__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause"
34__maintainer__ = "Colour Developers"
35__email__ = "colour-developers@colour-science.org"
36__status__ = "Production"
38__all__ = [
39 "oetf_SMPTE240M",
40 "eotf_SMPTE240M",
41]
44def oetf_SMPTE240M(L_c: Domain1) -> Range1:
45 """
46 Apply the *SMPTE 240M* opto-electronic transfer function (OETF).
48 Parameters
49 ----------
50 L_c
51 Light input :math:`L_c` to the reference camera normalised to the
52 system reference white.
54 Returns
55 -------
56 :class:`numpy.ndarray`
57 Video signal output :math:`V_c` of the reference camera normalised
58 to the system reference white.
60 Notes
61 -----
62 +------------+-----------------------+---------------+
63 | **Domain** | **Scale - Reference** | **Scale - 1** |
64 +============+=======================+===============+
65 | ``L_c`` | 1 | 1 |
66 +------------+-----------------------+---------------+
68 +------------+-----------------------+---------------+
69 | **Range** | **Scale - Reference** | **Scale - 1** |
70 +============+=======================+===============+
71 | ``V_c`` | 1 | 1 |
72 +------------+-----------------------+---------------+
74 References
75 ----------
76 :cite:`SocietyofMotionPictureandTelevisionEngineers1999b`
78 Examples
79 --------
80 >>> oetf_SMPTE240M(0.18) # doctest: +ELLIPSIS
81 0.4022857...
82 """
84 L_c = to_domain_1(L_c)
86 V_c = np.where(L_c < 0.0228, 4 * L_c, 1.1115 * spow(L_c, 0.45) - 0.1115)
88 return as_float(from_range_1(V_c))
91def eotf_SMPTE240M(V_r: Domain1) -> Range1:
92 """
93 Apply the *SMPTE 240M* electro-optical transfer function (EOTF).
95 Parameters
96 ----------
97 V_r
98 Video signal level :math:`V_r` driving the reference reproducer
99 normalised to the system reference white.
101 Returns
102 -------
103 :class:`numpy.ndarray`
104 Light output :math:`L_r` from the reference reproducer normalised
105 to the system reference white.
107 Notes
108 -----
109 +------------+-----------------------+---------------+
110 | **Domain** | **Scale - Reference** | **Scale - 1** |
111 +============+=======================+===============+
112 | ``V_r`` | 1 | 1 |
113 +------------+-----------------------+---------------+
115 +------------+-----------------------+---------------+
116 | **Range** | **Scale - Reference** | **Scale - 1** |
117 +============+=======================+===============+
118 | ``L_r`` | 1 | 1 |
119 +------------+-----------------------+---------------+
121 References
122 ----------
123 :cite:`SocietyofMotionPictureandTelevisionEngineers1999b`
125 Examples
126 --------
127 >>> eotf_SMPTE240M(0.402285796753870) # doctest: +ELLIPSIS
128 0.1...
129 """
131 V_r = to_domain_1(V_r)
133 with domain_range_scale("ignore"):
134 L_r = np.where(
135 V_r < oetf_SMPTE240M(0.0228),
136 V_r / 4,
137 spow((V_r + 0.1115) / 1.1115, 1 / 0.45),
138 )
140 return as_float(from_range_1(L_r))