TL; DR :如何在没有太多噪音的情况下提高OpenCV中图像的亮度/对比度?
我有点迷失了。我想增加暗图像的对比度和/或亮度,以便稍后我可以使用OpenCV的精确边缘检测来正确解析它。问题是,我不知道如何做到这一点,而不必太多的噪音。我的设备的相机应用程序似乎非常有能力提高亮度/对比度,OpenCV' JavaCameraView
遗憾地没有。我尝试过几件事。
这样可以增加对比度:
// Built in equalizeHist function.
Imgproc.equalizeHist(image, image); // Causes a lot of noise in darker images.
// Built in Contrast Limited Adaptive Histogram Equalization.
CLAHE mClahe = Imgproc.createCLAHE(cliping, new Size(8,8));
mClahe.apply(image, image); // Seems not to work in (fairly) dark images.
mClahe.collectGarbage();
作为最后的手段,我还尝试了几个方面,比如试图提高"锐度"图像(似乎没有帮助),增加亮度(导致粉饰)并将图像阈值化为二进制(太多噪音或粉饰使其无法使用)。不管这是我用来实现锐化,亮化和阈值处理的代码:
/* Thresholding */
// Seemed somewhat promising, but too much noise.
Imgproc.threshold(processed.clone(), processed, threshold, 255, Imgproc.THRESH_BINARY);
// I could not figure out what the last two params were supposed to do.
Imgproc.adaptiveThreshold(processed, processed, threshold, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C, Imgproc.THRESH_BINARY_INV, 9, 19);
/* Increasing brightness */
// Beta is added to the value of every pixel.
image.convertTo(image, image.type(), alpha, beta);
/* Increasing sharpness */
Mat blurred = new Mat();
Imgproc.GaussianBlur(image.clone, blurred, kernel, 0);
Core.addWeighted(image, 1.5, blurred, -1, 0, image); // Does seem to fail when the image gets too noisy.
blurred.release();
如何在不过多噪音的情况下提高亮度/对比度(或如何在不丢失太多细节的情况下减少噪音)的方向表示赞赏。