我有一个相当模糊的432x432的数独游戏图像,它不能很好地自适应阈值(取5x5像素的块大小的平均值,然后减去2):

如你所见,数字略有扭曲,其中有很多破损,一些5融合成6,6融合成8。此外,还有大量的噪音。为了修复噪声,我必须使用高斯模糊使图像更加模糊。然而,即使是相当大的高斯核和自适应阈值blockSize (21x21,减去2)也无法消除所有的破坏,并将数字融合在一起:

我还尝试了在阈值处理后放大图像,这与增加blockSize的效果相似;还有sharpening the image,它不会做太多这样或那样的事情。我还应该尝试什么?
发布于 2012-12-09 06:41:46
一个很好的解决方案是使用形态闭合来使亮度均匀,然后使用常规(非自适应) Otsu阈值:
// Divide the image by its morphologically closed counterpart
Mat kernel = Imgproc.getStructuringElement(Imgproc.MORPH_ELLIPSE, new Size(19,19));
Mat closed = new Mat();
Imgproc.morphologyEx(image, closed, Imgproc.MORPH_CLOSE, kernel);
image.convertTo(image, CvType.CV_32F); // divide requires floating-point
Core.divide(image, closed, image, 1, CvType.CV_32F);
Core.normalize(image, image, 0, 255, Core.NORM_MINMAX);
image.convertTo(image, CvType.CV_8UC1); // convert back to unsigned int
// Threshold each block (3x3 grid) of the image separately to
// correct for minor differences in contrast across the image.
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
Mat block = image.rowRange(144*i, 144*(i+1)).colRange(144*j, 144*(j+1));
Imgproc.threshold(block, block, -1, 255, Imgproc.THRESH_BINARY_INV+Imgproc.THRESH_OTSU);
}
}结果:

发布于 2012-11-15 18:08:16
看看Smoothing Images OpenCV tutorial吧。除了GaussianBlur,还有medianBlur和bilateralFilter,你也可以用它们来减少噪音。我从你的源图中得到了这个图(右上角):

更新:和下面的图片是我删除小轮廓后得到的:

更新:还可以锐化图像(例如,使用Laplacian)。看看this discussion吧。
发布于 2014-08-01 02:09:15
始终应用高斯以获得更好的结果。
cvAdaptiveThreshold(original_image, thresh_image, 255,
CV_ADAPTIVE_THRESH_GAUSSIAN_C, CV_THRESH_BINARY, 11, 2);https://stackoverflow.com/questions/13391073
复制相似问题