图像处理:消除已处理图像OPENCV的噪点-JAVA

时间:2018-08-28 03:07:03

标签: android opencv

我已经为OCR处理图像,我遇到了一个问题,即处理后的图像噪声太大。我是这类编程的初学者,我只是想知道你们是否可以帮助我进行降噪?

这是我到目前为止的代码

File newFile = new File(mFile);

        orig = Imgcodecs.imread(newFile.getAbsolutePath(),Imgcodecs.CV_LOAD_IMAGE_GRAYSCALE);
        Mat small = new Mat();
        Imgproc.pyrDown(orig,small);
        final Size kernelSize = new Size(3, 3);
        final Point anchor = new Point(-1, -1);
        final int iterations = 3;

        Mat kernel = Imgproc.getStructuringElement(Imgproc.MORPH_ELLIPSE, kernelSize);

        Imgproc.GaussianBlur(small,small, new Size(3,3),0);
        Imgproc.erode(small, small,kernel,anchor,iterations);
        Imgproc.dilate(small,small,kernel);

        Imgproc.adaptiveThreshold(small,small,255,Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY,45,2);

        Mat kernel2 = Imgproc.getGaussianKernel(6,2);

        Imgproc.dilate(small,small,kernel2);
        Imgproc.erode(small,small,kernel);

        Bitmap bm = Bitmap.createBitmap(small.cols(), small.rows(),Bitmap.Config.ARGB_8888);
        Utils.matToBitmap(small, bm);

这是输出

示例1

enter image description here

示例2

enter image description here

1 个答案:

答案 0 :(得分:0)

您为什么不尝试使用fastNlMeansDenoising方法?

我认为GaussianBlur也是去噪的好方法。(在您的代码之后)

enter image description here enter image description here

相关问题