2

To get some better results with the OCR library tesseract I would do some preprocessing, but haven't got the right idea what steps could help me.

enter image description here enter image description here

I have tried to resize the image with the factor 15 and applied an adapted threshold (see images) but this results in "wavy" characters, which can't be detected with the tesseract OCR library. At the bottom you can find my Link to the images via Dropbox. The original image size is 115x18px, with an character height of 10px.

I would like to extract the characters from the background. What steps could lead to a better result? Should I use another OCR library instead of tesseract for the OCR part? What experiences in general have you made when using tesseract for text detection? Or can you prefer another library, or a commercial one?

Dropbox Link to example image

Update 19.6.15:

Original Image OTSU Thresholded image

OTSU threshold delivers better results as adaptive threshold. Will give an update about the other answers in the next days!

Update 01.07.2015 Have another example image, where the serialnumber should be recognized with using tesseract. Since the font size is very small the recognition result is not very good. Any ideas what kind of methods could help here?

Another example image

2

4 Answers 4

2

Otsu threshold gives me better results here. Combining with distance transform and another threshold I even get something almost recognizable by tesseract.

enter image description here

This is the result I get:

6ANFK9PC)100'0-GT

3
  • Could you provide me the used properties for the openCV function "distanceTransform¶" that you used?
    – Mr.Sheep
    Commented Apr 11, 2015 at 12:53
  • I didn't actually use opencv here, but I guess it should not be very parameter-critical. My implementation was in python/numpy/skimage. The important part after distance transform was that I did another otsu treshold of only white pixels, not the whole transformed image. But you can try other skeletonizing techniques or simply erosion/minimum filter
    – vzaguskin
    Commented Apr 11, 2015 at 13:24
  • After I have tried your suggestion, I can say, that due to computation time I cannot use a complex distance transform. Unfortunately applying a OTSU treshold and using the binary images as input for tesseract don't result in better recognitions in my case.
    – Mr.Sheep
    Commented Jun 26, 2015 at 12:30
0

You may try to find all contours and remove contours with small area.
Dealing with "wevy" characters might be more complicated. The only idea i have right now is using distance transform and thresholding (using binary threshold) the result (finding good threshold value might not be simple - i would try using maxValue*0.25 of normalized distance transform).

1
  • Ok, Thanks for your comment. Just as information, the second picture (thresholded picture) is just an suggestion myself to process the original image, but as you can see results in "wevy" characters. So I am also interested, if if there are processing steps to extract the characters in a better way out of the original image, although the original image isn't in that good quality.
    – Mr.Sheep
    Commented Apr 10, 2015 at 8:22
0

You may want to try a small amount of erosion and dilation on the second image, this might even out some of the waves in the characters, a mixture of both erosion/dilation will also remove the little white dots of noise surrounding them, which is always going to help OCR.

Check out this OpenCV documentation, which will provide you with some example code to get you started and an explanation of how it all works.

Hope this helps.

1
  • Ok, Thank you, I will have a look at this and report my results afterwards.
    – Mr.Sheep
    Commented Apr 10, 2015 at 9:42
0

Why not just "sharpen" (which will remove the white borders and thin the white lines) and then simply reverse the black and white?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.