Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "opencolorio_config_aces/config/reference/aces-system"]
path = opencolorio_config_aces/config/reference/aces-system
url = https://github.com/colour-science/aces-system
[submodule "opencolorio_config_aces/config/reference/aces"]
path = opencolorio_config_aces/config/reference/aces
url = https://github.com/ampas/aces
1 change: 1 addition & 0 deletions docs/opencolorio_config_aces.clf.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Common LUT Format Generation
generate_clf_transforms_bmdfilm
generate_clf_transforms_canon
generate_clf_transforms_davinci
generate_clf_transforms_dji
generate_clf_transforms_itu
generate_clf_transforms_ocio
generate_clf_transforms_panasonic
Expand Down
1 change: 1 addition & 0 deletions docs/opencolorio_config_aces.config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ Reference Configuration
version_aces_dev
classify_aces_ctl_transforms
discover_aces_ctl_transforms
filter_amf_components
filter_ctl_transforms
generate_amf_components
print_aces_taxonomy
Expand Down
2 changes: 2 additions & 0 deletions docs/opencolorio_config_aces.utilities.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ Common
timestamp
as_bool
optional
filter_any
filter_all
2 changes: 2 additions & 0 deletions opencolorio_config_aces/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
conversion_path,
ctl_transform_to_node,
discover_aces_ctl_transforms,
filter_amf_components,
filter_ctl_transforms,
filter_nodes,
generate_amf_components,
Expand Down Expand Up @@ -108,6 +109,7 @@
"conversion_path",
"ctl_transform_to_node",
"discover_aces_ctl_transforms",
"filter_amf_components",
"filter_ctl_transforms",
"filter_nodes",
"generate_amf_components",
Expand Down
2 changes: 2 additions & 0 deletions opencolorio_config_aces/clf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
generate_clf_transforms_bmdfilm,
generate_clf_transforms_canon,
generate_clf_transforms_davinci,
generate_clf_transforms_dji,
generate_clf_transforms_itu,
generate_clf_transforms_ocio,
generate_clf_transforms_panasonic,
Expand All @@ -35,6 +36,7 @@
"generate_clf_transforms_bmdfilm",
"generate_clf_transforms_canon",
"generate_clf_transforms_davinci",
"generate_clf_transforms_dji",
"generate_clf_transforms_itu",
"generate_clf_transforms_ocio",
"generate_clf_transforms_panasonic",
Expand Down
6 changes: 6 additions & 0 deletions opencolorio_config_aces/clf/transforms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
from .canon import (
generate_clf_transforms_canon,
)
from .dji import (
generate_clf_transforms_dji,
)
from .itu import (
generate_clf_transforms_itu,
)
Expand Down Expand Up @@ -53,6 +56,9 @@
__all__ += [
"generate_clf_transforms_canon",
]
__all__ += [
"generate_clf_transforms_dji",
]
__all__ += [
"generate_clf_transforms_itu",
]
Expand Down
6 changes: 5 additions & 1 deletion opencolorio_config_aces/clf/transforms/arri/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,10 @@ def _generate_logc3_transforms(
# Generate ARRI LogC3 to ACES 2065-1 Transform
name = f"ARRI_LogC3_EI{ei}_to_ACES2065-1"
aces_id = f"urn:ampas:aces:transformId:v1.5:IDT.ARRI.Alexa-v3-logC-EI{ei}.a1.v2"

if ei == 800:
aces_id = "urn:ampas:aces:transformId:v2.0:CSC.Arri.LogC3_to_ACES.a2.v1"

input_descriptor = f"ARRI LogC3 (EI{ei})"
output_descriptor = "ACES2065-1"
clf_transform_id = format_clf_transform_id(FAMILY, GENUS, name, VERSION)
Expand Down Expand Up @@ -342,7 +346,7 @@ def _generate_logc4_transforms(

# Generate ARRI LogC4 to ACES 2065-1 Transform
name = "ARRI_LogC4_to_ACES2065-1"
aces_id = "urn:ampas:aces:transformId:v2.0:CSC.Arri.LogCv4_to_ACES.a2.v1"
aces_id = "urn:ampas:aces:transformId:v2.0:CSC.Arri.LogC4_to_ACES.a2.v1"
input_descriptor = "ARRI LogC4"
output_descriptor = "ACES2065-1"
clf_transform_id = format_clf_transform_id(FAMILY, GENUS, name, VERSION)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<InputDescriptor>ARRI LogC3 (EI800)</InputDescriptor>
<OutputDescriptor>ACES2065-1</OutputDescriptor>
<Info>
<ACEStransformID>urn:ampas:aces:transformId:v2.0:CSC.Arri.LogCv3_to_ACES.a2.v1</ACEStransformID>
<ACEStransformID>urn:ampas:aces:transformId:v2.0:CSC.Arri.LogC3_to_ACES.a2.v1</ACEStransformID>
</Info>
<Log inBitDepth="32f" outBitDepth="32f" style="cameraLogToLin">
<LogParams base="10" linSideSlope="5.55555555555556" linSideOffset="0.0522722750251688" logSideSlope="0.247189638318671" logSideOffset="0.385536998692443" linSideBreak="0.0105909904954696" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<InputDescriptor>ARRI LogC4</InputDescriptor>
<OutputDescriptor>ACES2065-1</OutputDescriptor>
<Info>
<ACEStransformID>urn:ampas:aces:transformId:v2.0:CSC.Arri.LogCv4_to_ACES.a2.v1</ACEStransformID>
<ACEStransformID>urn:ampas:aces:transformId:v2.0:CSC.Arri.LogC4_to_ACES.a2.v1</ACEStransformID>
</Info>
<Log inBitDepth="32f" outBitDepth="32f" style="cameraLogToLin">
<LogParams base="2" linSideSlope="2231.82630906769" linSideOffset="64" logSideSlope="0.0647954196341293" logSideOffset="-0.295908392682586" linSideBreak="-0.0180569961199113" />
Expand Down
10 changes: 10 additions & 0 deletions opencolorio_config_aces/clf/transforms/dji/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright Contributors to the OpenColorIO Project.

from .generate import (
generate_clf_transforms_dji,
)

__all__ = [
"generate_clf_transforms_dji",
]
173 changes: 173 additions & 0 deletions opencolorio_config_aces/clf/transforms/dji/generate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright Contributors to the OpenColorIO Project.
"""
*DJI* CLF Transforms Generation
================================

Defines procedures for generating DJI *Common LUT Format* (CLF)
transforms:

- :func:`opencolorio_config_aces.clf.generate_clf_transforms_dji`
"""

from __future__ import annotations

from pathlib import Path

import PyOpenColorIO as ocio

from opencolorio_config_aces.clf.transforms import (
clf_basename,
format_clf_transform_id,
generate_clf_transform,
matrix_RGB_to_RGB_transform,
)
from opencolorio_config_aces.config import transform_factory

__author__ = "OpenColorIO Contributors"
__copyright__ = "Copyright Contributors to the OpenColorIO Project."
__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause"
__maintainer__ = "OpenColorIO Contributors"
__email__ = "ocio-dev@lists.aswf.io"
__status__ = "Production"

__all__ = [
"FAMILY",
"GENUS",
"VERSION",
"generate_clf_transforms_dji",
]

FAMILY: str = "DJI"
"""
*CLF* transforms family.
"""

GENUS: str = "Input"
"""
*CLF* transforms genus.
"""

VERSION: str = "1.0"
"""
*CLF* transforms version.
"""


def generate_clf_transforms_dji(
output_directory: Path,
) -> dict[Path, ocio.GroupTransform]:
"""
Generate the *CLF* transforms for *D-Log - D-Gamut* plus matrix/curve.

Parameters
----------
output_directory
Directory to write the *CLF* transform(s) to.

Returns
-------
:class:`dict`
Dictionary of *CLF* transforms and *OpenColorIO* `GroupTransform`
instances.

References
----------
- Dji. (2017). White Paper on D-Log and D-Gamut of DJI Cinema Color
System (pp. 1-5). https://dl.djicdn.com/downloads/zenmuse+x7/20171010/\
D-Log_D-Gamut_Whitepaper.pdf
"""

output_directory.mkdir(parents=True, exist_ok=True)

clf_transforms = {}

base = 10.0

# Mathematically correct for transition at log = 0.14:
# lin_side_break = (0.14 - 0.0929) / 6.025 = 0.007817427385892119
# Optimized:
lin_side_break = 0.00758078675

log_side_slope = 1.0 / 3.89616
log_side_offset = 2.27752 / 3.89616
lin_side_slope = 0.9892
lin_side_offset = 0.0108
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was debating whether we should specify linearSlope or not? If we don't specify it, the slope of the extrapolated curve will be:
0.256662970719888 * 0.9892 / ( np.log(10.) * (0.9892 * 0.00758078675 + 0.0108) ) = 6.02568346

I don't object to going with what you have here, it will be quite close to the published value. Their intent was probably that the slope would be continuous.

I do like the way you used the log-to-lin as the definitive version and recalculated as needed rather than simply using the rounded values from the lin-to-log direction in their white paper!


lct = transform_factory(
transform_type="LogCameraTransform",
transform_factory="Constructor",
base=base,
linSideBreak=[lin_side_break] * 3,
logSideSlope=[log_side_slope] * 3,
logSideOffset=[log_side_offset] * 3,
linSideSlope=[lin_side_slope] * 3,
linSideOffset=[lin_side_offset] * 3,
direction=ocio.TRANSFORM_DIR_INVERSE,
)

mtx = matrix_RGB_to_RGB_transform("DJI D-Gamut", "ACES2065-1", "CAT02")

# ACES transform ID from the CTL file
aces_transform_id = (
"urn:ampas:aces:transformId:v2.0:CSC.DJI.DLog_DGamut_to_ACES.a1.v1"
)

# Generate full transform.
name = "DLog_DGamut_to_ACES2065-1"
input_descriptor = "DJI D-Log - D-Gamut"
output_descriptor = "ACES2065-1"
clf_transform_id = format_clf_transform_id(FAMILY, GENUS, name, VERSION)
filename = output_directory / clf_basename(clf_transform_id)
clf_transforms[filename] = generate_clf_transform(
filename,
[lct, mtx],
clf_transform_id,
f"{input_descriptor} to {output_descriptor}",
input_descriptor,
output_descriptor,
aces_transform_id,
)

# Generate transform for primaries only.
name = "Linear_DGamut_to_ACES2065-1"
input_descriptor = "Linear DJI D-Gamut"
output_descriptor = "ACES2065-1"
clf_transform_id = format_clf_transform_id(FAMILY, GENUS, name, VERSION)
filename = output_directory / clf_basename(clf_transform_id)
clf_transforms[filename] = generate_clf_transform(
filename,
[mtx],
clf_transform_id,
f"{input_descriptor} to {output_descriptor}",
input_descriptor,
output_descriptor,
)

# Generate `NamedTransform` for log curve only.
name = "DLog-Curve_to_Linear"
input_descriptor = "DJI D-Log Log (arbitrary primaries)"
output_descriptor = "DJI D-Log Linear (arbitrary primaries)"
clf_transform_id = format_clf_transform_id(FAMILY, GENUS, name, VERSION)
filename = output_directory / clf_basename(clf_transform_id)
clf_transforms[filename] = generate_clf_transform(
filename,
[lct],
clf_transform_id,
f'{input_descriptor.replace(" (arbitrary primaries)", "")} to Linear Curve',
input_descriptor,
output_descriptor,
)

return clf_transforms


if __name__ == "__main__":
import logging

logging.basicConfig()
logging.getLogger().setLevel(logging.INFO)

output_directory = Path(__file__).parent.resolve() / "input"

generate_clf_transforms_dji(output_directory)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<ProcessList compCLFversion="3" id="urn:aswf:ocio:transformId:1.0:DJI:Input:DLog-Curve_to_Linear:1.0" name="DJI D-Log Log to Linear Curve">
<InputDescriptor>DJI D-Log Log (arbitrary primaries)</InputDescriptor>
<OutputDescriptor>DJI D-Log Linear (arbitrary primaries)</OutputDescriptor>
<Log inBitDepth="32f" outBitDepth="32f" style="cameraLogToLin">
<LogParams base="10" linSideSlope="0.9892" linSideOffset="0.0108" logSideSlope="0.256662970719888" logSideOffset="0.58455504907396" linSideBreak="0.00758078675" />
</Log>
</ProcessList>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<ProcessList compCLFversion="3" id="urn:aswf:ocio:transformId:1.0:DJI:Input:DLog_DGamut_to_ACES2065-1:1.0" name="DJI D-Log - D-Gamut to ACES2065-1">
<InputDescriptor>DJI D-Log - D-Gamut</InputDescriptor>
<OutputDescriptor>ACES2065-1</OutputDescriptor>
<Info>
<ACEStransformID>urn:ampas:aces:transformId:v2.0:CSC.DJI.DLog_DGamut_to_ACES.a1.v1</ACEStransformID>
</Info>
<Log inBitDepth="32f" outBitDepth="32f" style="cameraLogToLin">
<LogParams base="10" linSideSlope="0.9892" linSideOffset="0.0108" logSideSlope="0.256662970719888" logSideOffset="0.58455504907396" linSideBreak="0.00758078675" />
</Log>
<Matrix inBitDepth="32f" outBitDepth="32f">
<Array dim="3 3">
0.691279245585754 0.214382527745956 0.0943382266682902
0.0662224037667752 1.0116160801876 -0.0778384839543733
-0.0172985410341745 -0.0773788501012682 1.09467739113544
</Array>
</Matrix>
</ProcessList>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<ProcessList compCLFversion="3" id="urn:aswf:ocio:transformId:1.0:DJI:Input:Linear_DGamut_to_ACES2065-1:1.0" name="Linear DJI D-Gamut to ACES2065-1">
<InputDescriptor>Linear DJI D-Gamut</InputDescriptor>
<OutputDescriptor>ACES2065-1</OutputDescriptor>
<Matrix inBitDepth="32f" outBitDepth="32f">
<Array dim="3 3">
0.691279245585754 0.214382527745956 0.0943382266682902
0.0662224037667752 1.0116160801876 -0.0778384839543733
-0.0172985410341745 -0.0773788501012682 1.09467739113544
</Array>
</Matrix>
</ProcessList>
2 changes: 2 additions & 0 deletions opencolorio_config_aces/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
conversion_path,
ctl_transform_to_node,
discover_aces_ctl_transforms,
filter_amf_components,
filter_ctl_transforms,
filter_nodes,
generate_amf_components,
Expand Down Expand Up @@ -75,6 +76,7 @@
"conversion_path",
"ctl_transform_to_node",
"discover_aces_ctl_transforms",
"filter_amf_components",
"filter_ctl_transforms",
"filter_nodes",
"generate_amf_components",
Expand Down
Loading