Coverage for models/rgb/transfer_functions/smpte_240m.py: 33%

1"""

2 SMPTE 240M

3==========

4

5 Define the *SMPTE 240M* opto-electrical transfer function (OETF) and

6 electro-optical transfer function (EOTF).

7

8- :func:`colour.models.oetf_SMPTE240M`

9- :func:`colour.models.eotf_SMPTE240M`

10

11 References

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/\

17 SMPTE%20normes%20et%20confs/s240m.pdf

18"""

19

20 from __future__ import annotations

21

22 import numpy as np

23

24 from colour.algebra import spow

25 from colour.hints import ( # noqa: TC001

26 Domain1,

27 Range1,

28)

29 from colour.utilities import as_float, domain_range_scale, from_range_1, to_domain_1

30

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"

37

38 __all__ = [

39 "oetf_SMPTE240M",

40 "eotf_SMPTE240M",

41]

42

43

44 def oetf_SMPTE240M(L_c: Domain1) -> Range1:

45 """

46 Apply the *SMPTE 240M* opto-electronic transfer function (OETF).

47

48 Parameters

49 ----------

50 L_c

51 Light input :math:`L_c` to the reference camera normalised to the

52 system reference white.

53

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.

59

60 Notes

61 -----

62 +------------+-----------------------+---------------+

63 | **Domain** | **Scale - Reference** | **Scale - 1** |

64 +============+=======================+===============+

65 | ``L_c`` | 1 | 1 |

66 +------------+-----------------------+---------------+

67

68 +------------+-----------------------+---------------+

69 | **Range** | **Scale - Reference** | **Scale - 1** |

70 +============+=======================+===============+

71 | ``V_c`` | 1 | 1 |

72 +------------+-----------------------+---------------+

73

74 References

75 ----------

76 :cite:`SocietyofMotionPictureandTelevisionEngineers1999b`

77

78 Examples

79 --------

80 >>> oetf_SMPTE240M(0.18) # doctest: +ELLIPSIS

81 0.4022857...

82 """

83

84 L_c = to_domain_1(L_c)

85

86 V_c = np.where(L_c < 0.0228, 4 * L_c, 1.1115 * spow(L_c, 0.45) - 0.1115)

87

88 return as_float(from_range_1(V_c))

89

90

91 def eotf_SMPTE240M(V_r: Domain1) -> Range1:

92 """

93 Apply the *SMPTE 240M* electro-optical transfer function (EOTF).

94

95 Parameters

96 ----------

97 V_r

98 Video signal level :math:`V_r` driving the reference reproducer

99 normalised to the system reference white.

100

101 Returns

102 -------

103 :class:`numpy.ndarray`

104 Light output :math:`L_r` from the reference reproducer normalised

105 to the system reference white.

106

107 Notes

108 -----

109 +------------+-----------------------+---------------+

110 | **Domain** | **Scale - Reference** | **Scale - 1** |

111 +============+=======================+===============+

112 | ``V_r`` | 1 | 1 |

113 +------------+-----------------------+---------------+

114

115 +------------+-----------------------+---------------+

116 | **Range** | **Scale - Reference** | **Scale - 1** |

117 +============+=======================+===============+

118 | ``L_r`` | 1 | 1 |

119 +------------+-----------------------+---------------+

120

121 References

122 ----------

123 :cite:`SocietyofMotionPictureandTelevisionEngineers1999b`

124

125 Examples

126 --------

127 >>> eotf_SMPTE240M(0.402285796753870) # doctest: +ELLIPSIS

128 0.1...

129 """

130

131 V_r = to_domain_1(V_r)

132

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 )

139

140 return as_float(from_range_1(L_r))