Skip to content

Commit f5f4930

Browse files
authored
Add Canon CLFs (#71)
* Add Canon CLFs Signed-off-by: Doug Walker <[email protected]> * Address formatting issues Signed-off-by: Doug Walker <[email protected]> * Address rst line Signed-off-by: Doug Walker <[email protected]> Signed-off-by: Doug Walker <[email protected]>
1 parent 484930d commit f5f4930

File tree

5 files changed

+4276
-0
lines changed

5 files changed

+4276
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
# Copyright Contributors to the OpenColorIO Project.
3+
4+
from .generate import (
5+
generate_clf_transforms_canon,
6+
)
7+
8+
__all__ = [
9+
"generate_clf_transforms_canon",
10+
]
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
# Copyright Contributors to the OpenColorIO Project.
3+
"""
4+
*Canon* CLF Transforms Generation
5+
=================================
6+
7+
Defines procedures for generating Canon *Common LUT Format* (CLF)
8+
transforms:
9+
10+
- :func:`opencolorio_config_aces.clf.generate_clf_transforms_canon`
11+
"""
12+
13+
import PyOpenColorIO as ocio
14+
from pathlib import Path
15+
16+
from opencolorio_config_aces.clf.transforms import (
17+
clf_basename,
18+
format_clf_transform_id,
19+
generate_clf_transform,
20+
matrix_RGB_to_RGB_transform,
21+
)
22+
23+
__author__ = "OpenColorIO Contributors"
24+
__copyright__ = "Copyright Contributors to the OpenColorIO Project."
25+
__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause"
26+
__maintainer__ = "OpenColorIO Contributors"
27+
__email__ = "[email protected]"
28+
__status__ = "Production"
29+
30+
__all__ = [
31+
"FAMILY",
32+
"GENUS",
33+
"VERSION",
34+
"generate_clf_transforms_canon",
35+
]
36+
37+
FAMILY = "Canon"
38+
"""
39+
*CLF* transforms family.
40+
"""
41+
42+
GENUS = "Input"
43+
"""
44+
*CLF* transforms genus.
45+
"""
46+
47+
VERSION = "1.0"
48+
"""
49+
*CLF* transforms version.
50+
"""
51+
52+
53+
def generate_clf_transforms_canon(output_directory):
54+
"""
55+
Make the CLF file for Canon C-Log3 Cinema Gamut plus matrix/curve CLFs.
56+
57+
Returns
58+
-------
59+
dict
60+
Dictionary of *CLF* transforms and *OpenColorIO* `GroupTransform`
61+
instances.
62+
63+
References
64+
----------
65+
- Canon. (2018). White Paper on Canon Log.
66+
Retrieved September 22, 2022, from http://downloads.canon.com/nw/learn/\
67+
white-papers/cinema-eos/white-paper-canon-log-gamma-curves.pdf
68+
69+
Notes
70+
-----
71+
- The resulting *CLF* transforms were reviewed by *Canon*.
72+
"""
73+
74+
output_directory.mkdir(parents=True, exist_ok=True)
75+
76+
clf_transforms = {}
77+
78+
bt = ocio.BuiltinTransform(style="CANON_CLOG3-CGAMUT_to_ACES2065-1")
79+
80+
mtx = matrix_RGB_to_RGB_transform("Cinema Gamut", "ACES2065-1", "CAT02")
81+
82+
aces_transform_id = (
83+
"urn:ampas:aces:transformId:v1.5:"
84+
"ACEScsc.Academy.CLog3_CGamut_to_ACES.a1.1.0"
85+
)
86+
87+
# Generate full transform.
88+
# NB: This is being saved in CTF format to allow us of a Built-in Transform
89+
# and thus avoid the need for an external LUT file.
90+
91+
name = "CanonLog3_CinemaGamut-D55_to_ACES2065-1"
92+
input_descriptor = "Canon Log 3 Cinema Gamut (Daylight)"
93+
output_descriptor = "ACES2065-1"
94+
clf_transform_id = format_clf_transform_id(FAMILY, GENUS, name, VERSION)
95+
filename = output_directory / clf_basename(clf_transform_id)
96+
clf_transforms[filename] = generate_clf_transform(
97+
filename,
98+
[bt],
99+
clf_transform_id,
100+
f"{input_descriptor} to {output_descriptor}",
101+
input_descriptor,
102+
output_descriptor,
103+
aces_transform_id,
104+
)
105+
106+
# Generate transform for primaries only.
107+
108+
name = "Linear-CinemaGamut-D55_to_ACES2065-1"
109+
input_descriptor = "Linear Canon Cinema Gamut (Daylight)"
110+
output_descriptor = "ACES2065-1"
111+
clf_transform_id = format_clf_transform_id(FAMILY, GENUS, name, VERSION)
112+
filename = output_directory / clf_basename(clf_transform_id)
113+
clf_transforms[filename] = generate_clf_transform(
114+
filename,
115+
[mtx],
116+
clf_transform_id,
117+
f"{input_descriptor} to {output_descriptor}",
118+
input_descriptor,
119+
output_descriptor,
120+
)
121+
122+
# Generate `NamedTransform` for log curve only.
123+
124+
# TODO: This will have to wait for OCIO 2.2 in order to do this without
125+
# requiring an external LUT file.
126+
127+
return clf_transforms
128+
129+
130+
if __name__ == "__main__":
131+
import logging
132+
133+
logging.basicConfig()
134+
logging.getLogger().setLevel(logging.INFO)
135+
136+
output_directory = Path(__file__).parent.resolve() / "input"
137+
138+
generate_clf_transforms_canon(output_directory)

0 commit comments

Comments
 (0)