Coverage for colour/models/rgb/transfer_functions/gopro.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"""
2GoPro Encoding
3==============
5Define the *GoPro* *Protune* encoding.
7- :func:`colour.models.log_encoding_Protune`
8- :func:`colour.models.log_decoding_Protune`
10References
11----------
12- :cite:`GoPro2016a` : GoPro, Duiker, H.-P., & Mansencal, T. (2016).
13 gopro.py. Retrieved April 12, 2017, from
14 https://github.com/hpd/OpenColorIO-Configs/blob/master/aces_1.0.3/python/\
15aces_ocio/colorspaces/gopro.py
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_Protune",
37 "log_decoding_Protune",
38]
41def log_encoding_Protune(x: Domain1) -> Range1:
42 """
43 Apply the *Protune* log encoding opto-electronic transfer function (OETF).
45 Parameters
46 ----------
47 x
48 Linear data :math:`x`.
50 Returns
51 -------
52 :class:`numpy.ndarray`
53 Non-linear encoded data :math:`y`.
55 Notes
56 -----
57 +------------+-----------------------+---------------+
58 | **Domain** | **Scale - Reference** | **Scale - 1** |
59 +============+=======================+===============+
60 | ``x`` | 1 | 1 |
61 +------------+-----------------------+---------------+
63 +------------+-----------------------+---------------+
64 | **Range** | **Scale - Reference** | **Scale - 1** |
65 +============+=======================+===============+
66 | ``y`` | 1 | 1 |
67 +------------+-----------------------+---------------+
69 References
70 ----------
71 :cite:`GoPro2016a`
73 Examples
74 --------
75 >>> log_encoding_Protune(0.18) # doctest: +ELLIPSIS
76 0.6456234...
77 """
79 x = to_domain_1(x)
81 y = np.log1p(x * 112) / np.log(113)
83 return as_float(from_range_1(y))
86def log_decoding_Protune(y: Domain1) -> Range1:
87 """
88 Apply the *Protune* log decoding inverse opto-electronic transfer function (OETF).
90 Parameters
91 ----------
92 y
93 Non-linear encoded data :math:`y`.
95 Returns
96 -------
97 :class:`numpy.ndarray`
98 Linear data :math:`x`.
100 Notes
101 -----
102 +------------+-----------------------+---------------+
103 | **Domain** | **Scale - Reference** | **Scale - 1** |
104 +============+=======================+===============+
105 | ``y`` | 1 | 1 |
106 +------------+-----------------------+---------------+
108 +------------+-----------------------+---------------+
109 | **Range** | **Scale - Reference** | **Scale - 1** |
110 +============+=======================+===============+
111 | ``x`` | 1 | 1 |
112 +------------+-----------------------+---------------+
114 References
115 ----------
116 :cite:`GoPro2016a`
118 Examples
119 --------
120 >>> log_decoding_Protune(0.645623486803636) # doctest: +ELLIPSIS
121 0.1...
122 """
124 y = to_domain_1(y)
126 x = (113**y - 1) / 112
128 return as_float(from_range_1(x))