• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

colour-science / colour / 12452776384

22 Dec 2024 08:43AM UTC coverage: 97.524% (-1.7%) from 99.255%
12452776384

push

github

KelSolaar
Code formatting.

41247 of 42294 relevant lines covered (97.52%)

0.98 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.97
/colour/models/rgb/transfer_functions/davinci_intermediate.py
1
"""
2
DaVinci Intermediate
3
====================
4

5
Define the *DaVinci Intermediate* opto-electrical transfer function
6
(OETF) and its inverse:
7

8
-   :func:`colour.models.oetf_DaVinciIntermediate`
9
-   :func:`colour.models.oetf_inverse_DaVinciIntermediate`
10

11
References
12
----------
13
-   :cite:`BlackmagicDesign2020a` : Blackmagic Design. (2020). Wide Gamut
14
    Intermediate DaVinci Resolve. Retrieved December 12, 2020, from
15
    https://documents.blackmagicdesign.com/InformationNotes/\
16
DaVinci_Resolve_17_Wide_Gamut_Intermediate.pdf?_v=1607414410000
17
"""
18

19
from __future__ import annotations
1✔
20

21
import typing
1✔
22

23
import numpy as np
1✔
24

25
if typing.TYPE_CHECKING:
1✔
26
    from colour.hints import ArrayLike, NDArrayFloat
×
27

28
from colour.utilities import Structure, as_float, from_range_1, to_domain_1
1✔
29

30
__author__ = "Colour Developers"
1✔
31
__copyright__ = "Copyright 2013 Colour Developers"
1✔
32
__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause"
1✔
33
__maintainer__ = "Colour Developers"
1✔
34
__email__ = "colour-developers@colour-science.org"
1✔
35
__status__ = "Production"
1✔
36

37
__all__ = [
1✔
38
    "CONSTANTS_DAVINCI_INTERMEDIATE",
39
    "oetf_DaVinciIntermediate",
40
    "oetf_inverse_DaVinciIntermediate",
41
]
42

43
CONSTANTS_DAVINCI_INTERMEDIATE: Structure = Structure(
1✔
44
    DI_A=0.0075,
45
    DI_B=7.0,
46
    DI_C=0.07329248,
47
    DI_M=10.44426855,
48
    DI_LIN_CUT=0.00262409,
49
    DI_LOG_CUT=0.02740668,
50
)
51
"""*DaVinci Intermediate* colour component transfer functions constants."""
1✔
52

53

54
def oetf_DaVinciIntermediate(
1✔
55
    L: ArrayLike,
56
    constants: Structure = CONSTANTS_DAVINCI_INTERMEDIATE,
57
) -> NDArrayFloat:
58
    """
59
    Define the *DaVinci Intermediate* opto-electronic transfer function.
60

61
    Parameters
62
    ----------
63
    L
64
        Linear light value :math`L`.
65
    constants
66
        *DaVinci Intermediate* colour component transfer function constants.
67

68
    Returns
69
    -------
70
    :class:`numpy.ndarray`
71
        Encoded value :math:`V`.
72

73
    Notes
74
    -----
75
    +------------+-----------------------+---------------+
76
    | **Domain** | **Scale - Reference** | **Scale - 1** |
77
    +============+=======================+===============+
78
    | ``L``      | [0, 1]                | [0, 1]        |
79
    +------------+-----------------------+---------------+
80

81
    +------------+-----------------------+---------------+
82
    | **Range**  | **Scale - Reference** | **Scale - 1** |
83
    +============+=======================+===============+
84
    | ``V``      | [0, 1]                | [0, 1]        |
85
    +------------+-----------------------+---------------+
86

87
    References
88
    ----------
89
    :cite:`BlackmagicDesign2020a`
90

91
    Examples
92
    --------
93
    >>> oetf_DaVinciIntermediate(0.18)  # doctest: +ELLIPSIS
94
    0.3360432...
95
    """
96

97
    L = to_domain_1(L)
1✔
98

99
    DI_LIN_CUT = constants.DI_LIN_CUT
1✔
100
    DI_A = constants.DI_A
1✔
101
    DI_B = constants.DI_B
1✔
102
    DI_C = constants.DI_C
1✔
103
    DI_M = constants.DI_M
1✔
104

105
    V_out = np.where(
1✔
106
        L <= DI_LIN_CUT,
107
        L * DI_M,
108
        DI_C * (np.log2(L + DI_A) + DI_B),
109
    )
110

111
    return as_float(from_range_1(V_out))
1✔
112

113

114
def oetf_inverse_DaVinciIntermediate(
1✔
115
    V: ArrayLike,
116
    constants: Structure = CONSTANTS_DAVINCI_INTERMEDIATE,
117
) -> NDArrayFloat:
118
    """
119
    Define the *DaVinci Intermediate* inverse opto-electronic transfer
120
    function (OETF).
121

122
    Parameters
123
    ----------
124
    V
125
        Encoded value :math:`V`.
126
    constants
127
        *DaVinci Intermediate* colour component transfer function constants.
128

129
    Returns
130
    -------
131
    :class:`numpy.ndarray`
132
        Linear light value :math`L`.
133

134
    Notes
135
    -----
136
    +------------+-----------------------+---------------+
137
    | **Domain** | **Scale - Reference** | **Scale - 1** |
138
    +============+=======================+===============+
139
    | ``y``      | [0, 1]                | [0, 1]        |
140
    +------------+-----------------------+---------------+
141

142
    +------------+-----------------------+---------------+
143
    | **Range**  | **Scale - Reference** | **Scale - 1** |
144
    +============+=======================+===============+
145
    | ``x``      | [0, 1]                | [0, 1]        |
146
    +------------+-----------------------+---------------+
147

148
    References
149
    ----------
150
    :cite:`BlackmagicDesign2020a`
151

152
    Examples
153
    --------
154
    >>> oetf_inverse_DaVinciIntermediate(0.336043272384855)
155
    ... # doctest: +ELLIPSIS
156
    0.1799999...
157
    """
158

159
    V = to_domain_1(V)
1✔
160

161
    DI_LOG_CUT = constants.DI_LOG_CUT
1✔
162
    DI_A = constants.DI_A
1✔
163
    DI_B = constants.DI_B
1✔
164
    DI_C = constants.DI_C
1✔
165
    DI_M = constants.DI_M
1✔
166

167
    L_out = np.where(
1✔
168
        V <= DI_LOG_CUT,
169
        V / DI_M,
170
        2 ** ((V / DI_C) - DI_B) - DI_A,
171
    )
172
    return as_float(from_range_1(L_out))
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc