Fastest way to apply color matrix to RGB image using OpenCV 3.0? -
i have color image represented opencv mat object (c++, image type cv_32fc3). have color correction matrix want apply each pixel of rgb color image (or bgr using opencv convention, doesn't matter here). color correction matrix 3x3.
i iterate on pixels , create vector v (3x1) representing rgb, , compute m*v, slow real-time video application.
the cv::cvtcolor function fast, not seem allow custom color transformations. http://docs.opencv.org/2.4/modules/imgproc/doc/miscellaneous_transformations.html#cvtcolor
similar following, using opencv c++, not python. apply transformation matrix pixels in opencv image
basically linked answer uses reshape
convert cv_32fc3
mat of size m x n
cv_32f
mat of size (mn) x 3
. after that, each row of matrix contains color channels of 1 pixel. can apply usual matrix multiplication obtain new mat , reshape
original shape 3 channels.
note: may worth noticing default color space of opencv bgr, not rgb.
Comments
Post a Comment