Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

CvType.CV_32FC3 is the wrong type to load it, you don't need the RGB conversion, and you should not add a new channel at the end. try like this:

Mat bgr = Utils.loadResource(getApplicationContext(), R.drawable.retinalimage, CvType.CV_8UC3); 
Mat newImage = new Mat();
Imgproc.cvtColor(bgr, newImage, Imgproc.COLOR_BGR2Lab,3);

java.util.List<Mat> Lab = new ArrayList<Mat>();
Core.split(newImage,Lab);
Mat L = Lab.get(0); // L,a,b are references, not copies
Mat a = Lab.get(1);
Mat b = Lab.get(2);

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

Core.merge(Lab,newImage);
Imgproc.cvtColor(newImage,bgr,Imgproc.COLOR_Lab2RGB);

CvType.CV_32FC3 is the wrong type to load it, you don't need the RGB conversion, and you should not add a new channel at the end. try like this:

Mat bgr = Utils.loadResource(getApplicationContext(), R.drawable.retinalimage, CvType.CV_8UC3); 
Mat newImage = new Mat();
Imgproc.cvtColor(bgr, newImage, Imgproc.COLOR_BGR2Lab,3);

java.util.List<Mat> Lab = new ArrayList<Mat>();
Core.split(newImage,Lab);
Mat L = Lab.get(0); // L,a,b are references, not copies
Mat a = Lab.get(1);
Mat b = Lab.get(2);

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

Core.merge(Lab,newImage);
Imgproc.cvtColor(newImage,bgr,Imgproc.COLOR_Lab2RGB);
Imgproc.cvtColor(newImage,bgr,Imgproc.COLOR_Lab2RGB); // maybe it needs bgr here, too.