OpenColorIO icon indicating copy to clipboard operation
OpenColorIO copied to clipboard

ApplyRGB should honor Numpy internal matrix storage order

Open doug-walker opened this issue 1 year ago • 4 comments

Numpy matrices may be stored in either row-major or column-major order. The user is typically not aware of the order being used, especially since some Numpy operators swap the order if it is more efficient for them. For example, transpose simply swaps the ordering flag rather than moving numeric values.

The applyRGB function in OCIO essentially just flattens the input and expects channel-interleaved ordering. Ideally, applyRGB would check the storage order and transpose values, if needed. At a minimum, it should issue a warning if the storage order is not as expected.

doug-walker avatar Oct 09 '24 16:10 doug-walker

The flags property of a NumPy array shows the storage order.

  C_CONTIGUOUS : True
  F_CONTIGUOUS : False
  OWNDATA : False
  WRITEABLE : True
  ALIGNED : True
  WRITEBACKIFCOPY : False

Currently applyRGB() will only work correctly if C_CONTIGUOUS is True.

nick-shaw avatar Oct 09 '24 17:10 nick-shaw

Easiest is wrapping the array with np.ascontiguousarray before using ApplyRGB. I modified Colour for now with this.

KelSolaar avatar Oct 10 '24 03:10 KelSolaar

Hi, could I work on this for ASWF Dev days?

Asheikhm avatar Sep 24 '25 20:09 Asheikhm

Thank you @Asheikhm , I've assigned this one to you!

doug-walker avatar Sep 24 '25 21:09 doug-walker