how can I get better results for this

300 views
Skip to first unread message

Rick Leir

unread,
Oct 17, 2014, 11:05:35 AM10/17/14
to tesser...@googlegroups.com
I have been getting great results from Tesseract when the images are clear. However, many of my images are crummy.
How would you get the best results for this? Maybe improved training, maybe image pre-processing?

The original is like this:


I have done some GraphicsMagick work to get this:




I am using Ubuntu 14.04, and see this in the terminal:
   Tesseract Open Source OCR Engine v3.03 with Leptonica

The Tesseract output text is, as expected, poor:

uh it .0222? 1mm: (lenuimi 7.1: ft. tin“. Six'ori;v;sioxi ".nn’

;(rt. n of an; 103 an Lam tmtns;hn

RG 84;

37.14121 :13}: oven 1w ,4? 1 {2.2" “"D'ud<~‘1ii,xl,;l w ‘;’ tires LU.

not, I,» ana'asienbnd in 1.3 arm apartment. .. em; mummy no film rzltnow‘n tau” 1m. and. ruijoiv‘zim: (mean in thin bleak. :an {"311 .25 33:03:) in Line :‘djomum Monks 1m :1: r a; w 231:9C101l3nt13‘ 1 are u.» rerun «S :2, vngfiunxulw CHUHLVlfiafln. ~.1. was tun iHEHHELgN MC


ShreeDevi Kumar

unread,
Oct 17, 2014, 11:23:37 AM10/17/14
to tesser...@googlegroups.com

​try with image at 300dpi or higher. resize 300%​

ShreeDevi
____________________________________________________________
भजन - कीर्तन - आरती @ http://bhajans.ramparivar.com

--
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/8cf6020e-1dc3-499f-8de9-a09c8865939a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Rick Leir

unread,
Oct 17, 2014, 11:38:12 AM10/17/14
to tesser...@googlegroups.com
Thanks, ShreeDevi

I opened the jpg in Gimp, and you can see that it is about 100 pixels per text line:

ShreeDevi Kumar

unread,
Oct 17, 2014, 12:31:24 PM10/17/14
to tesser...@googlegroups.com
You have to experiment ..

I got better results after some image processing and vietocr ..

that it has bcln dooi

transfer of a portzon

which has been leased

an. M- nan-ant.‘ 0n Mu


Inline image 1

ShreeDevi
____________________________________________________________
भजन - कीर्तन - आरती @ http://bhajans.ramparivar.com

Robert Komar

unread,
Oct 17, 2014, 1:33:47 PM10/17/14
to tesser...@googlegroups.com
On Fri, 17 Oct 2014, Rick Leir wrote:

> I opened the jpg in Gimp, and you can see that it is about
> 100 pixels per text line:
>
> [gimpOriginal.png]

That image looks to be scanned at about 150 dpi. With
such faint characters, scanning at 300 or 600 dpi would
have been better. Anyway, try scaling the images up
by a factor of two. Also try an "adaptive binarization"
algorithm to convert to black and white. Google
"wolf binarization" for one example of such an
algorithm. I tried myself on your example image, and
although it still didn't look that great, I can image
how bad it would look if a threshold binarization
algorithm was used.

Rob Komar

Rick Leir

unread,
Oct 27, 2014, 8:37:56 AM10/27/14
to tesser...@googlegroups.com
Hi Rob
My preprocessing is mentioned in this post:
https://groups.google.com/forum/#!topic/tesseract-ocr/jONGSChLRv4

Maybe you would call it adaptive?

Thanks for mentioning Wolf. I tried to compile the latest version but my 14.04 config must be wrong and I get:

 ~/ocr/wolf/binarizewolfjolion-src$ PKG_CONFIG_PATH=/usr/lib/pkgconfig/ make
g++ -I/usr/include/opencv binarizewolfjolion.cpp -o binarizewolfjolion `pkg-config opencv --libs`-lstdc++
/usr/bin/ld: /tmp/ccwdIqAh.o: undefined reference to symbol '_ZN2cv11_InputArrayC1ERKNS_3MatE'
//usr/lib/x86_64-linux-gnu/libopencv_core.so.2.4: error adding symbols: DSO missing from command line

Robert Komar

unread,
Oct 28, 2014, 1:49:57 AM10/28/14
to tesser...@googlegroups.com
On Mon, 27 Oct 2014, Rick Leir wrote:

> Hi Rob
> My preprocessing is mentioned in this post:
> https://groups.google.com/forum/#!topic/tesseract-ocr/jON
> GSChLRv4
>
> Maybe you would call it adaptive?

Adaptive means that the threshold for choosing between
black and white changes over different parts of the image.
Generally, the background is studied in each area to
see what the threshold should be.

> Thanks for mentioning Wolf. I tried to compile the latest
> version but my 14.04 config must be wrong and I get:
>
> ~/ocr/wolf/binarizewolfjolion-src$
> PKG_CONFIG_PATH=/usr/lib/pkgconfig/ make
> g++ -I/usr/include/opencv binarizewolfjolion.cpp -o
> binarizewolfjolion `pkg-config opencv --libs`-lstdc++
> /usr/bin/ld: /tmp/ccwdIqAh.o: undefined reference to
> symbol '_ZN2cv11_InputArrayC1ERKNS_3MatE'
> //usr/lib/x86_64-linux-gnu/libopencv_core.so.2.4: error
> adding symbols: DSO missing from command line

Perhaps you need the development version of opencv
to compile the code. What do you see when you run
"pkg-config opencv --libs" in a terminal? It should
point to a library file that you can link to.
Unfortunately, I can't test the build myself in my
Ubuntu OS because I use a custom version of ruby,
and the binarize scripts are hard-coded to /usr/bin/ruby.

Rob

Rick Leir

unread,
Oct 28, 2014, 11:36:43 AM10/28/14
to tesser...@googlegroups.com
Ok, then my method is adaptive. It has a few controls that I should tweak a bit. Or maybe I am expecting too much, and these images are just not good enough.

Here is the config. As you say, maybe I need to get the development version of opencv.
$ pkg-config opencv --libs
-lopencv_calib3d -lopencv_imgproc -lopencv_contrib -lopencv_legacy
Reply all
Reply to author
Forward
0 new messages