OpenImageIO icon indicating copy to clipboard operation
OpenImageIO copied to clipboard

feat!: implement support for OCIO NamedTransforms

Open zachlewis opened this issue 1 year ago • 2 comments
trafficstars

  • ColorProcCacheKey: Update definition, signature, and usage to support caching NamedTransform processor handles. (Note: ABI-breaking)

  • ColorConfig: add NamedTransform convenience functions: getNumNamedTransforms, getNamedTransformNameByIndex, getNamedTransformNames, getNamedTransformAliases

  • ColorConfig: add createNamedTransform function returning new ColorProcessorHandle

  • Add ImageBufAlgo::ocionamedtransform functions

  • oiiotool: add --ocionamedtransform operator

  • python: add NamedTransform convenience function bindings

  • python: add ImageBufAlgo.ocionamedtransform(...) bindings

  • Update oiiotool and python documentation with examples

Description

OCIO-2 config authors may define a set of stand-alone "source-agnostic" NamedTransforms. Unlike the colorconvert, ociodisplay, and ociolook IBAs, which explicitly convert from a color space to something else, the ocionamedtransform IBA behaves more like the ociofiletransform IBA, where the transform itself can be applied either in the forwards or inverse direction, and does not take into consideration the input encoding or image state.

Quoting from the OCIO NamedTransform documentation:

Sometimes it is helpful to include one or more transforms in a config that are essentially stand-alone transforms that do not have a fixed relationship to a reference space or a process space. An example would be a “utility curve” transform where the intent is to simply apply a LUT1D without any conversion to a reference space. In these cases, a named_transforms section may be added to the config with one or more named transforms. [...] This feature may be used to emulate older methods of color management that ignored the RGB primaries and simply applied one-dimensional transformations.

Notably, the built-in OCIO-2 Studio config (ocio://studio-config-latest) contains NamedTransforms "sRGB - Curve" and "Rec709 - Curve", which we could implement as drop-in replacements for the existing linear_to_sRGB, sRGB_to_linear, linear_to_Rec709, and Rec709_to_linear functions in color.h (unless those functions are deprecated...).

There are several other applications for NamedTransforms as well. They can be extremely useful as workflow-oriented transforms implemented at various points in facility pipelines (e.g., for applying shot-specific conversions, grades, gamut-compression, etc.); they can be used to provide diagnostic transforms for visualizing "exposure zones", clipped areas, NaNs, etc; for visually "tagging" problematic clips; for applying parts of ACES Metadata Files parsed by OCIO's forthcoming AMF parser; for conversion to non-RGB color models... all sorts of things.

Tests

Tests are forthcoming. I've tested everything locally, but have not yet implemented proper tests in the testsuite.

Checklist:

  • [x] I have read the contribution guidelines.
  • [x] I have updated the documentation, if applicable.
  • [ ] I have ensured that the change is tested somewhere in the testsuite (adding new test cases if necessary).
  • [x] If I added or modified a C++ API call, I have also amended the corresponding Python bindings (and if altering ImageBufAlgo functions, also exposed the new functionality as oiiotool options).
  • [x] My code follows the prevailing code style of this project. If I haven't already run clang-format before submitting, I definitely will look at the CI test that runs clang-format and fix anything that it highlights as being nonconforming.

zachlewis avatar Aug 26 '24 15:08 zachlewis