Skip to content

Document Color Matrix Math Better #18

@reedbn

Description

@reedbn

In https://docs.microsoft.com/en-us/dotnet/api/system.drawing.imaging.colormatrix?view=netframework-4.8 (which is not exactly the API being used, but also appears to be functionally the same), we're given the image:
image
This shows a row-vector being multiplied by the matrix, and above it, there's an explanation for the vector components.

As such, I'd recommend adding something to the config to indicate this operation style, since many references online prefer column vector notation. A possible comment:

# Given color matrix M, and
# given an input pixel p = [r g b a w], where r is red, g is green, b is blue, a is alpha, w is offset,
# then to calculate output pixel color d, the following multiplication is performed:
#   p*M = d
# Many papers use column vector multiplication, which is written as M*p = d, so if you
# find that a color matrix doesn't seem to be behaving correctly, it could be that your
# matrix assumes a column vector instead of a row vector. Try transposing the matrix,
# and you may discover the problem is fixed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    approvedI agree in principle, and hope I will be able to do it in the future.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions