行列の値が RGB で格納されていることが確実な場合 (デフォルトでは、OpenCV は BGR モードで値を読み取ります)、単純な行列の乗算に進むことができます。指定したとおりの RGB 値を含む適切なマトリックスを作成する必要があります。つまり、1,R,G,B 1,R,G,B, ... で、元の画像のピクセルあたり 1 行です。
これがあなたができる方法です(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 channel matrix prior to multiplication
cv::Mat reshaped = rgbOne.reshape(1, rgbOne.rows*rgbOne.cols);
// reshape is very fast as no allocation is required, check documentation
// now simply do the matrix multiplication
cv::Mat colorCorrectedImage = reshaped*transform;
// get back colorCorrectedImage to it's original dimensions
cv::Mat colorCoorectedReshaped = colorCorrectedImage.reshape(4, rgbOne.rows);
// note that you still have the extra channel of ones
// you can use split and merge functions as above to get rid of it and get your proper RGB image