OpenCV | opencv color correction
IfyouaresurethatthevaluesinyourmatrixarestoredinRGB(bydefaultOpenCVreadstheminBGRmode),youcanproceedwithsimplematrixmultiplacation.YoujusthavetocreatetherightmatrixcontainingtheRGBvaluesasyouspecified,i.e.1,R,G,B1,R,G,B,...,with1lineperpixelintheoriginalimageHereishowyoucando(inC++)//sayimgisyouroriginalRGBmatrix,transformisyourtransformationmatrixstd::vector
If you are sure that the values in your matrix are stored in RGB (by default OpenCV reads them in BGR mode), you can proceed with simple matrix multiplacation. You just have to create the right matrix containing the RGB values as you specified, i.e. 1,R,G,B 1,R,G,B, ..., with 1 line per pixel in the original image
Here is how you can do (in C++)
// say img is your original RGB matrix, transform is your transformation matrix std::vector<cv::Mat> channels; // this extracts the R,G and B channels in single matrices cv::split(img, channels); // create a matrix on ones in floating point cv::Mat oneMat = cv::Mat::ones(img.size(), CV_32F); oneMat.push_front(channels); // now channels is a vector containing 4 matrices of the same dimension as img // you want to group those matrix into 1 single matrix of same dimension and 4 channels // 1, R, G, B cv::Mat rgbOne; cv::merge(channels, rgbOne); // Transform the row by col, 4 channel matrix rgbOne into a row*col, 4, single c...