Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

your src image must be CV_8UC1 || CV_16UC1, a single channel grayscale image, but is not. please check grayscale.type() or grayscale.channels()

also, your dst image will have the same type (and size), not CV_8UC4, you should not try to pre-allocate it at all (and later get confused, because it's not like you expected), but just pass a new Mat()

your src image must be CV_8UC1 || CV_16UC1, a single channel grayscale image, but is not. please check grayscale.type() or grayscale.channels()

also, your dst image will have the same type (and size), not CV_8UC4, you should not try to pre-allocate it at all (and later get confused, because it's not like you expected), but just pass a new Mat() . really, it's simple as this:

Mat gray = Imgcodecs.imread("4621239.jpg", Imgcodecs.IMREAD_GRAYSCALE);
CLAHE clahe = Imgproc.createCLAHE();
Mat res = new Mat();
clahe.apply(gray,res);
Imgcodecs.imwrite("clahe.jpg", res);