Coverage for models/rgb/transfer_functions/xiaomi_mi_log.py: 12%

1"""

2 Xiaomi Mi-Log Profile Log Encoding

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

4

5 Define the *Xiaomi Mi-Log Profile* log encoding.

6

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

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

9

10 References

11----------

12- :cite:`Zhang2024` : Xiaomi Inc. (2024). Xiaomi Log Profile White Paper.

13 December 2024.

14"""

15

16 from __future__ import annotations

17

18 from colour.hints import ( # noqa: TC001

19 Domain1,

20 Range1,

21)

22 from colour.utilities import Structure, optional

23

24 from .apple_log_profile import (

25 log_decoding_AppleLogProfile,

26 log_encoding_AppleLogProfile,

27)

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

38 "log_encoding_MiLog",

39 "log_decoding_MiLog",

40]

41

42 CONSTANTS_MI_LOG: Structure = Structure(

43 R_0=-0.09023729,

44 R_t=0.01974185,

45 sigma=18.10531998, # 'c' in whitepaper, 'sigma' for Apple compatibility

46 beta=0.01384578,

47 gamma=0.09271529,

48 delta=0.67291850,

49)

50"""*Xiaomi Mi-Log Profile* constants."""

51

52

53 def log_encoding_MiLog(

54 R: Domain1,

55 constants: Structure | None = None,

56) -> Range1:

57 """

58 Apply the *Xiaomi Mi-Log Profile* log encoding opto-electronic transfer

59 function (OETF).

60

61 Parameters

62 ----------

63 R

64 Linear reflection data :math:`R`.

65 constants

66 *Xiaomi Mi-Log Profile* constants.

67

68 Returns

69 -------

70 :class:`numpy.ndarray`

71 Logarithmically encoded value :math:`P`.

72

73 References

74 ----------

75 :cite:`Zhang2024`

76

77 Notes

78 -----

79 - The scene reflection signal :math:`R` captured by the camera is

80 represented using a floating point encoding. The :math:`R` value

81 of 0.18 corresponds to the signal produced by an 18% reflectance

82 reference gray chart.

83

84 +------------+-----------------------+---------------+

85 | **Domain** | **Scale - Reference** | **Scale - 1** |

86 +============+=======================+===============+

87 | ``R`` | 1 | 1 |

88 +------------+-----------------------+---------------+

89

90 +------------+-----------------------+---------------+

91 | **Range** | **Scale - Reference** | **Scale - 1** |

92 +============+=======================+===============+

93 | ``P`` | 1 | 1 |

94 +------------+-----------------------+---------------+

95

96 Examples

97 --------

98 >>> log_encoding_MiLog(0.18) # doctest: +ELLIPSIS

99 0.4534596...

100 """

101

102 return log_encoding_AppleLogProfile(R, optional(constants, CONSTANTS_MI_LOG))

103

104

105 def log_decoding_MiLog(

106 P: Domain1,

107 constants: Structure | None = None,

108) -> Range1:

109 """

110 Apply the *Xiaomi Mi-Log Profile* log decoding inverse opto-electronic transfer

111 function (OETF).

112

113 Parameters

114 ----------

115 P

116 Logarithmically encoded value :math:`P`.

117 constants

118 *Xiaomi Mi-Log Profile* constants.

119

120 Returns

121 -------

122 :class:`numpy.ndarray`

123 Linear reflection data :math:`R`.

124

125 References

126 ----------

127 :cite:`Zhang2024`

128

129 Notes

130 -----

131 - The captured pixel :math:`P` value uses floating point encoding

132 normalized to the [0, 1] range.

133

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

135 | **Domain** | **Scale - Reference** | **Scale - 1** |

136 +============+=======================+===============+

137 | ``P`` | 1 | 1 |

138 +------------+-----------------------+---------------+

139

140 +------------+-----------------------+---------------+

141 | **Range** | **Scale - Reference** | **Scale - 1** |

142 +============+=======================+===============+

143 | ``R`` | 1 | 1 |

144 +------------+-----------------------+---------------+

145

146 Examples

147 --------

148 >>> log_decoding_MiLog(0.45345968) # doctest: +ELLIPSIS

149 0.1800000...

150 """

151

152 return log_decoding_AppleLogProfile(P, optional(constants, CONSTANTS_MI_LOG))