AcademySoftwareFoundation / OpenColorIO

A color management framework for visual effects and animation.
https://opencolorio.org
BSD 3-Clause "New" or "Revised" License
1.8k stars 460 forks source link

XYZ to RGB matrix constructor #231

Closed dbr closed 6 months ago

dbr commented 12 years ago

http://opencolorio.org/FAQ.html#can-you-convert-xyz-named-color-space-rgb-values

But there is no convenience function to compute this matrix for you. (We do include other Matrix convenience functions though, so it already has a place to be added. See MatrixTransform in export/OpenColorTransforms.h)

Is this something people have asked for? I have the XYZ->RGB matrix calculation implemented in Python somewhere, and converting it to C++ should be easy enough

If so, my only initial question would be: how would it be used in the config? E.g the current matrix usage looks like:

- !<MatrixTransform>
  matrix: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]
  offset: [0, 0, 0, 0]

Should it be coerced into the above transform, or made into a new one? Something like this seems tidiest to me:

- !<XYZtoRGBTransform>
  red_primary_xy: [0.64, 0.33]
  green_primary_xy: [0.3, 0.6]
  blue_primary_xy: [0.15, 0.06]
  whitepoint_xy: [0.3127, 0.3290]
  direction: inverse # RGB to XYZ
dbr commented 12 years ago

Oh, this post is a good reference for the calculation. There's also this one but I had problems following the maths (can't remember specifically, but either I was doing something wrong, it the page contains an error)

jeremyselan commented 12 years ago

My preference is in the short term to just add this as a static to MatrixTransform, alongside Fit, Scale, Sat, etc.

    static void MatrixTransform::RGB_to_XYZ(float * m44, float * offset4,
                    const float * chromaticityR, const float * chromaticityG, const float * chromaticityB, const float * chromaticityW);

This isnt quite as convenient as making it it's own transform type, but I'd prefer to avoid that route until transforms become less heavy-weight. (I.e., we support dynamic transform typing / introspection).

zachlewis commented 9 years ago

This would be nice. It would be great if there were a function for computing chromatic adaptation transforms too, when converting from one whitepoint to another. I know Nuke uses Bradford in its ColorSpace node (optionally). (I know this ticket is 3 years old, but I thought I'd chime in)

scoopxyz commented 7 years ago

4 years now :)

This seems like it would be a bit of a philosophical turn for OCIO would it not? Having to this point taken the stance of being a "vehicle for color transformations" rather than offering implementation of the actual color science.

zachlewis commented 6 years ago

5 years. Happy belated. (I know, i know, OCIO 2.0...)