Using OpenCV.
I have an RGB image, each value is a float.
I also have a standard color correction matrix 3×4.
What would be the fastest way to ‘apply’ this matrix over the image?
If you don’t know color correction… This is a simple matrix operation.
If the Image looks like this (each pixel is 3 floats):
R G B
R G B
R G B
R G B
R G B
.
.
.
Then I would like to perform the following:
1 R G B [ A1, A2, A3 ]
1 R G B [ R1, R2, R3 ]
1 R G B * [ G1, G2, G3 ]
1 R G B [ B1, B2, B3 ]
1 R G B
.
.
.
All the values in the 3×4 matrix are constants.
Thanks.
Multiply by the rgb parts of the color correction matrix:
Then add in the A channel correction:
Read about transform at opencv2refman
where it implies you could use
to get the same result in one step (it does dst(I) = mtx · [src(I);1], so helpful), avoiding having to add in the A components.
Your pardon, if that should be an M3X4. I am pretty dyslexic when it comes to matrix math, rows vs cols and which comes first.