Question

I have used adaptive thresholding on an image to turn it from

enter image description here to this

enter image description here

with adaptiveThreshold(src, src, 255, ADAPTIVE_THRESH_GAUSSIAN_C, THRESH_BINARY, 11, 2);

Is there a way I could smooth out the characters, specifically with OCR in mind? Or am I better to adjust my adaptive threshold params?

Was it helpful?

Solution 3

With the assumption of clear text on a solid background, I found Otsu's binarization very good.

Here's some C++ Code.

cvtColor(src, src, COLOR_RGB2GRAY); //Make grayscale
threshold(src, src, 0, 255, THRESH_BINARY+THRESH_OTSU); 

OTHER TIPS

If the letter is always with specific colour you can use colour based segmentation,

For the above image you culd use some thing like

 Mat src=imread("l.jpg",1);
 Mat hsv,thr;
 cvtColor(src,hsv,CV_BGR2HSV);
 inRange(hsv,Scalar(76,84,86),Scalar(135,255,255),thr);
 imshow("thr",thr);

See the result,

enter image description here

Check out the morphological operations. Especially dilation followed by erosion.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top