Coverage for models/rgb/transfer_functions/dji_d_log.py: 32%

19 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2025-11-16 22:49 +1300

1""" 

2DJI D-Log Log Encoding 

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

4 

5Define the *DJI D-Log* log encoding. 

6 

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

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

9 

10References 

11---------- 

12- :cite:`DJI2017` : Dji. (2017). White Paper on D-Log and D-Gamut of DJI 

13 Cinema Color System (pp. 1-5). 

14 https://dl.djicdn.com/downloads/zenmuse+x7/20171010/\ 

15D-Log_D-Gamut_Whitepaper.pdf 

16""" 

17 

18from __future__ import annotations 

19 

20import numpy as np 

21 

22from colour.hints import ( # noqa: TC001 

23 Domain1, 

24 Range1, 

25) 

26from colour.utilities import as_float, from_range_1, to_domain_1 

27 

28__author__ = "Colour Developers" 

29__copyright__ = "Copyright 2013 Colour Developers" 

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

31__maintainer__ = "Colour Developers" 

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

33__status__ = "Production" 

34 

35__all__ = [ 

36 "log_encoding_DJIDLog", 

37 "log_decoding_DJIDLog", 

38] 

39 

40 

41def log_encoding_DJIDLog(x: Domain1) -> Range1: 

42 """ 

43 Apply the *DJI D-Log* log encoding opto-electronic transfer function (OETF). 

44 

45 Parameters 

46 ---------- 

47 x 

48 Linear reflection data :math:`x`. 

49 

50 Returns 

51 ------- 

52 :class:`numpy.ndarray` 

53 *DJI D-Log* non-linear encoded data :math:`y`. 

54 

55 References 

56 ---------- 

57 :cite:`DJI2017` 

58 

59 Notes 

60 ----- 

61 +------------+-----------------------+---------------+ 

62 | **Domain** | **Scale - Reference** | **Scale - 1** | 

63 +============+=======================+===============+ 

64 | ``x`` | 1 | 1 | 

65 +------------+-----------------------+---------------+ 

66 

67 +------------+-----------------------+---------------+ 

68 | **Range** | **Scale - Reference** | **Scale - 1** | 

69 +============+=======================+===============+ 

70 | ``y`` | 1 | 1 | 

71 +------------+-----------------------+---------------+ 

72 

73 Examples 

74 -------- 

75 >>> log_encoding_DJIDLog(0.18) # doctest: +ELLIPSIS 

76 0.3987645... 

77 """ 

78 

79 x = to_domain_1(x) 

80 

81 y = np.where( 

82 x <= 0.0078, 

83 6.025 * x + 0.0929, 

84 (np.log10(x * 0.9892 + 0.0108)) * 0.256663 + 0.584555, 

85 ) 

86 

87 return as_float(from_range_1(y)) 

88 

89 

90def log_decoding_DJIDLog(y: Domain1) -> Range1: 

91 """ 

92 Apply the *DJI D-Log* log decoding inverse opto-electronic transfer function (OETF). 

93 

94 Parameters 

95 ---------- 

96 y 

97 *DJI D-Log* non-linear encoded data :math:`y`. 

98 

99 Returns 

100 ------- 

101 :class:`numpy.ndarray` 

102 Linear reflection data :math:`x`. 

103 

104 References 

105 ---------- 

106 :cite:`DJI2017` 

107 

108 Notes 

109 ----- 

110 +------------+-----------------------+---------------+ 

111 | **Domain** | **Scale - Reference** | **Scale - 1** | 

112 +============+=======================+===============+ 

113 | ``y`` | 1 | 1 | 

114 +------------+-----------------------+---------------+ 

115 

116 +------------+-----------------------+---------------+ 

117 | **Range** | **Scale - Reference** | **Scale - 1** | 

118 +============+=======================+===============+ 

119 | ``x`` | 1 | 1 | 

120 +------------+-----------------------+---------------+ 

121 

122 Examples 

123 -------- 

124 >>> log_decoding_DJIDLog(0.3987645561893306) # doctest: +ELLIPSIS 

125 0.1799998... 

126 """ 

127 

128 y = to_domain_1(y) 

129 

130 x = np.where( 

131 y <= 0.14, 

132 (y - 0.0929) / 6.025, 

133 (10 ** (3.89616 * y - 2.27752) - 0.0108) / 0.9892, 

134 ) 

135 

136 return as_float(from_range_1(x))