Coverage for colour/models/rgb/transfer_functions/dji_d_log.py: 100%
19 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"""
2DJI D-Log Log Encoding
3======================
5Define the *DJI D-Log* log encoding.
7- :func:`colour.models.log_encoding_DJIDLog`
8- :func:`colour.models.log_decoding_DJIDLog`
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"""
18from __future__ import annotations
20import numpy as np
22from colour.hints import ( # noqa: TC001
23 Domain1,
24 Range1,
25)
26from colour.utilities import as_float, from_range_1, to_domain_1
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"
35__all__ = [
36 "log_encoding_DJIDLog",
37 "log_decoding_DJIDLog",
38]
41def log_encoding_DJIDLog(x: Domain1) -> Range1:
42 """
43 Apply the *DJI D-Log* log encoding opto-electronic transfer function (OETF).
45 Parameters
46 ----------
47 x
48 Linear reflection data :math:`x`.
50 Returns
51 -------
52 :class:`numpy.ndarray`
53 *DJI D-Log* non-linear encoded data :math:`y`.
55 References
56 ----------
57 :cite:`DJI2017`
59 Notes
60 -----
61 +------------+-----------------------+---------------+
62 | **Domain** | **Scale - Reference** | **Scale - 1** |
63 +============+=======================+===============+
64 | ``x`` | 1 | 1 |
65 +------------+-----------------------+---------------+
67 +------------+-----------------------+---------------+
68 | **Range** | **Scale - Reference** | **Scale - 1** |
69 +============+=======================+===============+
70 | ``y`` | 1 | 1 |
71 +------------+-----------------------+---------------+
73 Examples
74 --------
75 >>> log_encoding_DJIDLog(0.18) # doctest: +ELLIPSIS
76 0.3987645...
77 """
79 x = to_domain_1(x)
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 )
87 return as_float(from_range_1(y))
90def log_decoding_DJIDLog(y: Domain1) -> Range1:
91 """
92 Apply the *DJI D-Log* log decoding inverse opto-electronic transfer function (OETF).
94 Parameters
95 ----------
96 y
97 *DJI D-Log* non-linear encoded data :math:`y`.
99 Returns
100 -------
101 :class:`numpy.ndarray`
102 Linear reflection data :math:`x`.
104 References
105 ----------
106 :cite:`DJI2017`
108 Notes
109 -----
110 +------------+-----------------------+---------------+
111 | **Domain** | **Scale - Reference** | **Scale - 1** |
112 +============+=======================+===============+
113 | ``y`` | 1 | 1 |
114 +------------+-----------------------+---------------+
116 +------------+-----------------------+---------------+
117 | **Range** | **Scale - Reference** | **Scale - 1** |
118 +============+=======================+===============+
119 | ``x`` | 1 | 1 |
120 +------------+-----------------------+---------------+
122 Examples
123 --------
124 >>> log_decoding_DJIDLog(0.3987645561893306) # doctest: +ELLIPSIS
125 0.1799998...
126 """
128 y = to_domain_1(y)
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 )
136 return as_float(from_range_1(x))