Preprocessing - detailed cropping

230 views
Skip to first unread message

Mirko P

unread,
Apr 8, 2015, 10:58:53 AM4/8/15
to tesser...@googlegroups.com

Hello,

I'm trying to recognize the machine readable part of a passport. (see the last line in this picture: http://s.hswstatic.com/gif/passport-11.jpg )

I'm using Tesseract on Android (tess-two) and take the picture with a 5 Mpix mobile camera. Unfortunately, the accuracy is not satisfyingly high. What I have tried to improve recognition was cropping the picture and retraining Tesseract for the font used in a passport (ocr-b). Both raises accuracy but still not to an acceptable level.
Here is a typical cropped picture I hand to Tesseract to perform ocr:


The binarized picture created by Tess for the actual recognition looks like this:


This is what Tesseract recognizes:

  09 1 M 1 907 1 8  F8 F857<4 < W<B<O <UME
  QVWBBENO W JMGHJ <RBP6W9BQR ED



I figured that the thin line at the bottom is extremely distracting to Tesseract. If I cut off the line manually and perform ocr, results are perfectly fine and all characters are recognized.
My question is, how can I find and get rid of that line automatically if it is in the cropped picture? This has to be done on an Android phone.

Any help will be appreciated!
Mirko

Mirko P

unread,
Apr 10, 2015, 4:50:06 AM4/10/15
to tesser...@googlegroups.com
Anybody any idea? Is blob detection the way to go? Unfortunately I don't know too much about image processing and its possibilities.

Dmitri Silaev

unread,
Apr 10, 2015, 5:20:32 AM4/10/15
to tesser...@googlegroups.com
Connected component (CC) analysis in the binary image is the way to go. See this for theoretical introduction: http://en.wikipedia.org/wiki/Connected-component_labeling . Then you have two approaches (can be used simultaneously):
  - Filter only good CCs, i.e. having size above minimum defined width and height, or
  - Discard bad CCs, i.e. having pixel count less than defined, or with longest principal axis wrongly directed or too lengthy (look for best-fitting ellipse, ellipse of inertia and so on), Y centroid's coordinate, etc.

In principle, there are tons of possible CC properties that could be used to filter or discard good or bad CCs, and their combinations. Much room for experimentation in you specific problem. I know Leptonica has a few routines to work with CCs. You can also try OpenCV (blobs in their terminology). I suppose, however, some code you would need to write yourself.

HTH

Best regards,
Dmitri Silaev
www.CustomOCR.com





On Fri, Apr 10, 2015 at 11:50 AM, Mirko P <mirko.p...@gmail.com> wrote:
Anybody any idea? Is blob detection the way to go? Unfortunately I don't know too much about image processing and its possibilities.

--
You received this message because you are subscribed to the Google Groups "tesseract-ocr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tesseract-oc...@googlegroups.com.
To post to this group, send email to tesser...@googlegroups.com.
Visit this group at http://groups.google.com/group/tesseract-ocr.
To view this discussion on the web visit https://groups.google.com/d/msgid/tesseract-ocr/e7c0bdf9-f546-438a-b536-b748968104c5%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Mirko P

unread,
Apr 13, 2015, 11:27:49 AM4/13/15
to tesser...@googlegroups.com
Thanks a lot! I'll try that.
Reply all
Reply to author
Forward
0 new messages