Threshold image using OpenCV (Java)

I'm working on a project with OpenCV I need to convert the following image to a threshold image

I tried this function:

Imgproc.threshold(imgGray,imgThreshold,255,Imgproc.THRESH_BINARY + Imgproc.THRESH_OTSU);

But the result is not very good, as shown below

So I tried the adaptive threshold function:

Imgproc.adaptiveThreshold(imgGray,Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY,11,2);

The result is:

I just expect a binary image with white background and black text, no black areas or noise (I don't like to use photo. Fastnlmeansdenoising because it takes a lot of time) Please help me solve this problem

In addition, I am using Tesseract for Japanese recognition, but the accuracy is poor Do you have any suggestions to provide better Japanese OCR or any method to improve the quality of Tesseract?

Solution

Adaptive threshold is the right choice here Just a little adjustment

Mat1b gray= imread("path_to_image",IMREAD_GRAYSCALE);
Mat1b result;
adaptiveThreshold(gray,result,ADAPTIVE_THRESH_MEAN_C,THRESH_BINARY,15,40);

The resulting image is:

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>