将Lab转换为RGB

时间:2018-12-08 20:06:00

标签: android-studio opencv

我正在使用opencv 3.4.0和android-studio,我想在L通道上应用CLAHE,所以我使用了Lab色彩空间,但是在L通道i上应用了CLAHE之后,最后我将图像转换回了RGB颜色空间,但是在尝试显示图像时出现此错误。这是错误:

CvException [org.opencv.core.CvException:cv :: Exception:OpenCV(3.4.0-dev)../../modules/imgproc/src/color.cpp:11207:错误:(-215) scn == 3 &&(dcn == 3 || dcn == 4)&&

L = new Mat(newImage.rows(), newImage.cols(), CvType.CV_8UC(1));
a = new Mat(newImage.rows(), newImage.cols(), CvType.CV_8UC(1));
b = new Mat(newImage.rows(), newImage.cols(), CvType.CV_8UC(1));
newImage1 = new Mat(newImage.rows(), newImage.cols(), CvType.CV_8UC3);

BGR_RGB = Utils.loadResource(getApplicationContext(), R.drawable.retinalimage, CvType.CV_32FC3); 
Imgproc.cvtColor(BGR_RGB, newImage, Imgproc.COLOR_BGR2RGB);
Imgproc.cvtColor(newImage,newImage,Imgproc.COLOR_RGB2Lab);
split(newImage,Lab);
L = Lab.get(0);
a = Lab.get(1);
b = Lab.get(2);

CLAHE ce = Imgproc.createCLAHE();
ce.setClipLimit(2);
ce.setTilesGridSize(new Size(8, 8));
ce.apply(L, L);

Lab.add(0,L);
Core.merge(Lab,newImage);
                       Imgproc.cvtColor(newImage,newImage,Imgproc.COLOR_Lab2RGB);
showImage1(newImage);

0 个答案:

没有答案