Coverage for colour/models/rgb/transfer_functions/xiaomi_mi_log.py: 100%
17 statements
« prev ^ index » next coverage.py v7.11.0, created at 2025-11-15 19:01 +1300
« prev ^ index » next coverage.py v7.11.0, created at 2025-11-15 19:01 +1300
1"""
2Xiaomi Mi-Log Profile Log Encoding
3==================================
5Define the *Xiaomi Mi-Log Profile* log encoding.
7- :func:`colour.models.log_encoding_MiLog`
8- :func:`colour.models.log_decoding_MiLog`
10References
11----------
12- :cite:`Zhang2024` : Xiaomi Inc. (2024). Xiaomi Log Profile White Paper.
13 December 2024.
14"""
16from __future__ import annotations
18from colour.hints import ( # noqa: TC001
19 Domain1,
20 Range1,
21)
22from colour.utilities import Structure, optional
24from .apple_log_profile import (
25 log_decoding_AppleLogProfile,
26 log_encoding_AppleLogProfile,
27)
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"
36__all__ = [
37 "CONSTANTS_MI_LOG",
38 "log_encoding_MiLog",
39 "log_decoding_MiLog",
40]
42CONSTANTS_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."""
53def 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).
61 Parameters
62 ----------
63 R
64 Linear reflection data :math:`R`.
65 constants
66 *Xiaomi Mi-Log Profile* constants.
68 Returns
69 -------
70 :class:`numpy.ndarray`
71 Logarithmically encoded value :math:`P`.
73 References
74 ----------
75 :cite:`Zhang2024`
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.
84 +------------+-----------------------+---------------+
85 | **Domain** | **Scale - Reference** | **Scale - 1** |
86 +============+=======================+===============+
87 | ``R`` | 1 | 1 |
88 +------------+-----------------------+---------------+
90 +------------+-----------------------+---------------+
91 | **Range** | **Scale - Reference** | **Scale - 1** |
92 +============+=======================+===============+
93 | ``P`` | 1 | 1 |
94 +------------+-----------------------+---------------+
96 Examples
97 --------
98 >>> log_encoding_MiLog(0.18) # doctest: +ELLIPSIS
99 0.4534596...
100 """
102 return log_encoding_AppleLogProfile(R, optional(constants, CONSTANTS_MI_LOG))
105def 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).
113 Parameters
114 ----------
115 P
116 Logarithmically encoded value :math:`P`.
117 constants
118 *Xiaomi Mi-Log Profile* constants.
120 Returns
121 -------
122 :class:`numpy.ndarray`
123 Linear reflection data :math:`R`.
125 References
126 ----------
127 :cite:`Zhang2024`
129 Notes
130 -----
131 - The captured pixel :math:`P` value uses floating point encoding
132 normalized to the [0, 1] range.
134 +------------+-----------------------+---------------+
135 | **Domain** | **Scale - Reference** | **Scale - 1** |
136 +============+=======================+===============+
137 | ``P`` | 1 | 1 |
138 +------------+-----------------------+---------------+
140 +------------+-----------------------+---------------+
141 | **Range** | **Scale - Reference** | **Scale - 1** |
142 +============+=======================+===============+
143 | ``R`` | 1 | 1 |
144 +------------+-----------------------+---------------+
146 Examples
147 --------
148 >>> log_decoding_MiLog(0.45345968) # doctest: +ELLIPSIS
149 0.1800000...
150 """
152 return log_decoding_AppleLogProfile(P, optional(constants, CONSTANTS_MI_LOG))