I have a problem understanding how i correctly use my matrices types for a color conversion from rgb to lms color space with opencv. The paper I've found is here. What I want to do is simply calculate the lms color triples as following:
Mat actRGBVec = new Mat(1,3,Imgproc.COLOR_RGB2BGR);
Mat lmsResVec = new Mat(1,3,CvType.CV_64FC3);
lmsMat = new Mat(inputImg.rows(),inputImg.cols(),CvType.CV_64FC3);
// iterate through all pixels and multiply rgb values with the lms transformation matrix
try {
for (int x = 0; x < inputImg.rows(); x++) {
for (int y = 0; y < inputImg.cols(); y++) {
actRGBVal = inputImg.get(x, y);
// vector holding rgb info
actRGBVec.put(0, 0, actRGBVal);
Core.gemm(lmsTransformMat, actRGBVec, 1, null, 0, lmsResVec, 0);
lmsMat.put(x, y, lmsResVec.get(0, 0));
}
}
}
catch (Exception e) {
Log.d("ImageHandler","Error rgb to lms conversion! " + e.getMessage());
}
lmsMat is of type CV_64FC3. inputImg is of type Imgproc.COLOR_RGB2BGR. lmsTransformMat is of type CV_64FC1 (since it contains only scalar values this should be the right type?).
The Exception says: Error rgb to lms conversion! null What am I doing wrong here?