Skip to content

Add a function to convert from/to a known external color space #1541

@doug-walker

Description

@doug-walker

Some applications have functionality that generates synthetic objects that need to be integrated with a scene. These objects are sometimes in a specific color space. For example, a physical sky simulator might produce a blue gradient with known CIE XYZ coordinates. Another example would be simulation of human hair or skin. These synthetically generated objects must then be converted into RGB values for the current working space, defined by the OCIO config. In the past, many applications assumed the working space was linear Rec.709, but that is no longer a good assumption. Inserting linear Rec.709 RGB values for a physical sky simulation into a renderer that is using ACEScg as the working space gives obviously wrong looking results.

Another example is with applications that integrate an SDK for a digital cinema camera. These applications receive decoded frames from media files that are in a specific color space. It may then be necessary to convert these frames into a color space defined in the current OCIO config used by the application.

Historically, OCIO has intentionally avoided providing a formal connection from color spaces in a config to known external color spaces such as CIE XYZ. In OCIO v2, two new "interchange" roles (aces_interchange and cie_xyz_d65_interchange) were added to facilitate use-cases as described above. However, to respect the original design intentions of OCIO, these roles were left optional and may not be present in v2 configs, let alone v1 configs.

As discussed in a number of threads with Larry, Zach, and others on Slack, it would be very helpful for the API to include a function that could be used to convert between some well known external color space, such as CIE XYZ or linear Rec.709, and a color space in a given config. If the interchange roles are present, these would be used. If not, there would be a series of heuristics that would be used to identify a known color space. These might be inaccurate in some cases, but the reality today is that application developers are already creating heuristics to solve these types of issues and there is value in at least having a standard set of heuristics that are documented and which could be improved over time, if needed.

For convenience, the function should offer a small number of scene-referred and display-referred color spaces that could be accepted. These would certainly include the current two interchange roles, but other spaces could be added, if desired. For example, scene-linear Rec.709 might be something many developers would appreciate for integrating OCIO with existing code.

The goal of the heuristics is to identify a known linear color space in the config. The heuristics could include the following:

  1. Assume the scene-referred and display-referred reference spaces are linear. Define a set of candidate reference spaces including ACES2065-1, ACEScg, linear Rec.709, and CIE XYZ.
  2. Try to find a color space whose from/to_ref transform is linear (i.e., only a Matrix, or set of Matrices) and check if the overall matrix matches one of a set of known matrices based on a set of common color spaces. The matching would be within some tolerance (and perhaps a scale factor?).
  3. If the above fails, the reference space may be using an unknown set of primaries. Look for strings such as "sRGB", "ACEScg", and "Rec*709" to identify the primaries being used by a color space. Then check if it has a linear relationship to the reference space.
  4. If the above fails, assume the rendering role (if present) is linear Rec.709. Otherwise assume the scene_linear role is linear Rec.709. Note that this may not be the most common value for those roles, but I'm thinking that the expected last fallback should be linear Rec.709. Any thoughts?

Once the heuristic has identified a color space in the config that is a known color space, the conversion process is basically the same as if the interchange roles are defined. The function could build a simple config with the defined conversion spaces, add the known color space from the other config, and then use one of the existing GetProcessorFromConfigs calls to create a Processor for the conversion.

Regarding the sub-problem of identifying a linear color space, see also issue #1399.

A more formal specification of the API and heuristics is TBD.

Suggestions are welcome, as is feedback and discussion on the proposed functionality.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Feature RequestNew addition to OCIO functionality.Needs DiscussionNeeds discussion before implmentation, which could result in changes, or a decision not to proceed.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions