Coverage for colour/models/rgb/transfer_functions/panalog.py: 100%

21 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2025-11-15 19:01 +1300

1""" 

2Panalog Encoding 

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

4 

5Define the *Panalog* encoding. 

6 

7- :func:`colour.models.log_encoding_Panalog` 

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

9 

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""" 

17 

18from __future__ import annotations 

19 

20import numpy as np 

21 

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 

28 

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" 

35 

36__all__ = [ 

37 "log_encoding_Panalog", 

38 "log_decoding_Panalog", 

39] 

40 

41 

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). 

48 

49 Parameters 

50 ---------- 

51 x 

52 Linear data :math:`x`. 

53 black_offset 

54 Black offset. 

55 

56 Returns 

57 ------- 

58 :class:`numpy.ndarray` 

59 *Panalog* non-linear encoded data :math:`y`. 

60 

61 Warnings 

62 -------- 

63 These are estimations known to be close enough, the actual log encoding 

64 curves are not published. 

65 

66 Notes 

67 ----- 

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

69 | **Domain** | **Scale - Reference** | **Scale - 1** | 

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

71 | ``x`` | 1 | 1 | 

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

73 

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

75 | **Range** | **Scale - Reference** | **Scale - 1** | 

76 +============+=======================+===============+ 

77 | ``y`` | 1 | 1 | 

78 +------------+-----------------------+---------------+ 

79 

80 References 

81 ---------- 

82 :cite:`SonyImageworks2012a` 

83 

84 Examples 

85 -------- 

86 >>> log_encoding_Panalog(0.18) # doctest: +ELLIPSIS 

87 0.3745767... 

88 """ 

89 

90 x = to_domain_1(x) 

91 black_offset = as_float_array(black_offset) 

92 

93 y = (681 + 444 * np.log10(x * (1 - black_offset) + black_offset)) / 1023 

94 

95 return as_float(from_range_1(y)) 

96 

97 

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). 

104 

105 Parameters 

106 ---------- 

107 y 

108 *Panalog* non-linear encoded data :math:`y`. 

109 black_offset 

110 Black offset. 

111 

112 Returns 

113 ------- 

114 :class:`numpy.ndarray` 

115 Linear data :math:`x`. 

116 

117 Warnings 

118 -------- 

119 These are estimations known to be close enough, the actual log 

120 encoding curves are not published. 

121 

122 Notes 

123 ----- 

124 +------------+-----------------------+---------------+ 

125 | **Domain** | **Scale - Reference** | **Scale - 1** | 

126 +============+=======================+===============+ 

127 | ``y`` | 1 | 1 | 

128 +------------+-----------------------+---------------+ 

129 

130 +------------+-----------------------+---------------+ 

131 | **Range** | **Scale - Reference** | **Scale - 1** | 

132 +============+=======================+===============+ 

133 | ``x`` | 1 | 1 | 

134 +------------+-----------------------+---------------+ 

135 

136 References 

137 ---------- 

138 :cite:`SonyImageworks2012a` 

139 

140 Examples 

141 -------- 

142 >>> log_decoding_Panalog(0.374576791382298) # doctest: +ELLIPSIS 

143 0.1... 

144 """ 

145 

146 y = to_domain_1(y) 

147 black_offset = as_float_array(black_offset) 

148 

149 x = (10 ** ((1023 * y - 681) / 444) - black_offset) / (1 - black_offset) 

150 

151 return as_float(from_range_1(x))