Apply transformation matrix to pixels in OpenCV image

asked 2014-02-27 16:08:20 -0500

wennho gravatar image

updated 2014-02-28 00:37:50 -0500

berak gravatar image

I want to change the color basis of an image from RGB to something else. I have a matrix M that I want to apply to each pixel's RGB, which we can define as xij.

I am currently iterating over each pixel of the NumPy image and calculating Mxij manually. I can't even vectorize it over the rows, because the RGB is a 1x3 instead of a 3x1 array.

Is there a better way to do this? Maybe a function in OpenCV or NumPy?

edit retag flag offensive close merge delete