3
$\begingroup$

I am making renders for research in computer vision, and need to know the CIE color space values from each render. Right now I am rendering a few different passes to an EXR Multilayer file.

I believe the combined pass in the EXR file is in the OpenColorIO scene-linear colorspace. Is there some linear transformation or operation I can make to get the CIE XYZ values from this pass?

$\endgroup$
  • 4
    $\begingroup$ Blender's reference space is linear using rec.709/sRGB primaries. As for your question. I don't think that is possible to do what you want using blender. Saving EXRs bypasses view transforms set in the color management section, so there is no way to transform the color space for them. Save your EXRs from blender and do the color transform in some other program like Resolve, Nuke, Natron, Fusion or similar using a simple matrix that converts to go from sRGB/709 to XYZ. $\endgroup$ – cegaton Mar 8 '18 at 19:34
  • $\begingroup$ Related: blender.stackexchange.com/questions/72793/… $\endgroup$ – cegaton Mar 8 '18 at 19:36
4
$\begingroup$

It isn't straightforwards as Cegaton notes.

You could abuse Blender's ridiculous OCIO integration to achieve this however. Save the file as an EXR, and add the following stanza to the OpenColorIO configuration in datafiles/colormanagement:

 - !<ColorSpace>
    name: One-Way XYZ
    family: Input Special
    equalitygroup: ""
    bitdepth: 32f
    description: |
      One way transform to save an XYZ EXR.
    isdata: false
    allocation: uniform
    allocationvars: [0, 1]
    to_reference: !<MatrixTransform> {matrix: 1.0,  0,  0,  0, 0,  1.0,  0,  0, 0,  0,  1.0,  0, 0, 0, 0, 1]}
    from_reference: !<MatrixTransform> {matrix: 0.4124564,  0.3575761,  0.1804375,  0, 0.2126729,  0.7151522,  0.0721750,  0, 0.0193339,  0.1191920,  0.9503041,  0, 0, 0, 0, 1]}

Note that this is a one way transform! Don't use it for anything else. It also assumes the file was saved as default scene referred linear in an EXR.

$\endgroup$
  • $\begingroup$ Forgive me if this should be a new question on its own, but can you clarify what you mean by "add a stanza"? If im using OpenEXR in python would I add this to the header dictionary? Also, I'm using an EXR multilayer, would this apply the transform to all passes/layers, and if so, how would I specify not to transform the depth pass and surface normal pass (which I need as well) $\endgroup$ – Philip Bayer Mar 12 '18 at 5:39
  • $\begingroup$ In the end the Multilayer EXR's are getting unpacked into python (numpy) arrays to feed into machine learning algorithms, so if it is easier, can I just multiply the transform matrix on the python end? and if so, how are the 'to_reference' and 'from_reference' matrices applied to the rec.709 linear RGB data? $\endgroup$ – Philip Bayer Mar 12 '18 at 5:47
  • 1
    $\begingroup$ The stanza would go into the OpenColorIO configuration in datafiles/colormanagement. The stanza is a hack, and would only be used for output. The other buffers would need to be tagged "Non-Color Data" for anything that doesn't represent a ratio of three coloured lights. $\endgroup$ – troy_s Mar 13 '18 at 4:31
  • $\begingroup$ The stanza should be edited into the config.ocio file in the colormanagement folder. $\endgroup$ – cegaton Mar 13 '18 at 4:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.