Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ApplyRGB should honor Numpy internal matrix storage order #2075

Open
doug-walker opened this issue Oct 9, 2024 · 2 comments
Open

ApplyRGB should honor Numpy internal matrix storage order #2075

doug-walker opened this issue Oct 9, 2024 · 2 comments
Labels
Bug Unwanted or incorrect behavior in currently available functionality. good first issue Standard label for new developers to locate good issues to tackle to learn about OCIO development. help wanted Issues that the TSC has decided are worth implementing, but don't currently have the dev resources. Python Issues that involve majority python development (vs C++).

Comments

@doug-walker
Copy link
Collaborator

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 doug-walker added good first issue Standard label for new developers to locate good issues to tackle to learn about OCIO development. help wanted Issues that the TSC has decided are worth implementing, but don't currently have the dev resources. Python Issues that involve majority python development (vs C++). Bug Unwanted or incorrect behavior in currently available functionality. labels Oct 9, 2024
@nick-shaw
Copy link

nick-shaw commented Oct 9, 2024

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.

KelSolaar added a commit to colour-science/colour that referenced this issue Oct 10, 2024
@KelSolaar
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Unwanted or incorrect behavior in currently available functionality. good first issue Standard label for new developers to locate good issues to tackle to learn about OCIO development. help wanted Issues that the TSC has decided are worth implementing, but don't currently have the dev resources. Python Issues that involve majority python development (vs C++).
Projects
None yet
Development

No branches or pull requests

3 participants