Coverage for models/rgb/transfer_functions/itur_bt_1886.py: 53%

1"""

2 Recommendation ITU-R BT.1886

3============================

4

5 Define the *Recommendation ITU-R BT.1886* electro-optical transfer function

6(EOTF) and its inverse.

7

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

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

10

11 References

12----------

13- :cite:`InternationalTelecommunicationUnion2011h` : International

14 Telecommunication Union. (2011). Recommendation ITU-R BT.1886 - Reference

15 electro-optical transfer function for flat panel displays used in HDTV

16 studio production BT Series Broadcasting service.

17 https://www.itu.int/dms_pubrec/itu-r/rec/bt/\

18 R-REC-BT.1886-0-201103-I!!PDF-E.pdf

19"""

20

21 from __future__ import annotations

22

23 import numpy as np

24

25 from colour.algebra import spow

26 from colour.hints import ( # noqa: TC001

27 Domain1,

28 Range1,

29)

30 from colour.utilities import as_float, from_range_1, to_domain_1

31

32 __author__ = "Colour Developers"

33 __copyright__ = "Copyright 2013 Colour Developers"

34 __license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause"

35 __maintainer__ = "Colour Developers"

36 __email__ = "colour-developers@colour-science.org"

37 __status__ = "Production"

38

39 __all__ = [

40 "eotf_inverse_BT1886",

41 "eotf_BT1886",

42]

43

44

45 def eotf_inverse_BT1886(L: Domain1, L_B: float = 0, L_W: float = 1) -> Range1:

46 """

47 Apply the *Recommendation ITU-R BT.1886* inverse electro-optical

48 transfer function (EOTF) for flat panel displays.

49

50 Parameters

51 ----------

52 L

53 Screen luminance in :math:`cd/m^2`.

54 L_B

55 Screen luminance for black in :math:`cd/m^2`.

56 L_W

57 Screen luminance for white in :math:`cd/m^2`.

58

59 Returns

60 -------

61 :class:`numpy.ndarray`

62 Input video signal level (normalised, with black at :math:`V = 0`

63 and white at :math:`V = 1`). For content mastered per

64 *Recommendation ITU-R BT.709*, 10-bit digital code values

65 :math:`D` map into values of :math:`V` per the following equation:

66 :math:`V = (D-64)/876`

67

68 Notes

69 -----

70 +------------+-----------------------+---------------+

71 | **Domain** | **Scale - Reference** | **Scale - 1** |

72 +============+=======================+===============+

73 | ``L`` | 1 | 1 |

74 +------------+-----------------------+---------------+

75

76 +------------+-----------------------+---------------+

77 | **Range** | **Scale - Reference** | **Scale - 1** |

78 +============+=======================+===============+

79 | ``V`` | 1 | 1 |

80 +------------+-----------------------+---------------+

81

82 References

83 ----------

84 :cite:`InternationalTelecommunicationUnion2011h`

85

86 Examples

87 --------

88 >>> eotf_inverse_BT1886(0.11699185725296059) # doctest: +ELLIPSIS

89 0.4090077...

90 """

91

92 L = to_domain_1(L)

93

94 gamma = 2.40

95 gamma_d = 1 / gamma

96

97 n = L_W**gamma_d - L_B**gamma_d

98 a = n**gamma

99 b = L_B**gamma_d / n

100

101 V = spow(L / a, gamma_d) - b

102

103 return as_float(from_range_1(V))

104

105

106 def eotf_BT1886(V: Domain1, L_B: float = 0, L_W: float = 1) -> Range1:

107 """

108 Apply the *Recommendation ITU-R BT.1886* electro-optical transfer

109 function (EOTF) for flat panel displays.

110

111 Parameters

112 ----------

113 V

114 Input video signal level (normalised, with black at :math:`V = 0`

115 and white at :math:`V = 1`). For content mastered per

116 *Recommendation ITU-R BT.709*, 10-bit digital code values

117 :math:`D` map into values of :math:`V` per the following equation:

118 :math:`V = (D-64)/876`

119 L_B

120 Screen luminance for black in :math:`cd/m^2`.

121 L_W

122 Screen luminance for white in :math:`cd/m^2`.

123

124 Returns

125 -------

126 :class:`numpy.ndarray`

127 Screen luminance in :math:`cd/m^2`.

128

129 Notes

130 -----

131 +------------+-----------------------+---------------+

132 | **Domain** | **Scale - Reference** | **Scale - 1** |

133 +============+=======================+===============+

134 | ``V`` | 1 | 1 |

135 +------------+-----------------------+---------------+

136

137 +------------+-----------------------+---------------+

138 | **Range** | **Scale - Reference** | **Scale - 1** |

139 +============+=======================+===============+

140 | ``L`` | 1 | 1 |

141 +------------+-----------------------+---------------+

142

143 References

144 ----------

145 :cite:`InternationalTelecommunicationUnion2011h`

146

147 Examples

148 --------

149 >>> eotf_BT1886(0.409007728864150) # doctest: +ELLIPSIS

150 0.1169918...

151 """

152

153 V = to_domain_1(V)

154

155 gamma = 2.40

156 gamma_d = 1 / gamma

157

158 n = L_W**gamma_d - L_B**gamma_d

159 a = n**gamma

160 b = L_B**gamma_d / n

161 L = a * spow(np.maximum(V + b, 0), gamma)

162

163 return as_float(from_range_1(L))