Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8317887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:45:38+00:00 2026-06-08T21:45:38+00:00

I’m working on a project that involves extracting text scientific papers stored in PDF

  • 0

I’m working on a project that involves extracting text scientific papers stored in PDF format. For most papers, this is accomplished quite easily using PDFMiner, but some older papers store their text as large images. In essence, a paper is scanned and that image file (typically PNG or JPEG) comprises the entire page.

I tried using the Tesseract engine through it’s python-tesseract bindings, but the results are quite disappointing.

Before diving into the questions I have with this library, I would like to mention that I’m open to suggestions for OCR libraries. There seem to be few native python solutions.

Here is one such image (JPEG) on which I am trying to extract text. I the exact code provided in the example snippets on the python-tesseract google code page I linked to above. I should mention that the documentation is a bit sparse, so it’s quite possible that one of the many options in my code is misconfigured. Any advice (or links to in-depth tutorials) would be much appreciated.

Here is the output from my attempt at OCR.

My questions are as follows:

  1. Is there anything suboptimal in the code I’m using? Is there a better way of doing this? A different library perhaps?
  2. What kind of preprocessing can I perform to improve detection? The images are all B&W, but should I perhaps set a threshold and set anything above it to a single-value black color and everything below it to a null-value white color? Anything else?
  3. A more specific question: can performance be improved by performing OCR on single words? If so, can anyone suggest a way of delimiting single words in an image file (e.g.: the one linked above) and extracting them into separate images which can be treated independently?
  4. Can the presence of graphs and other images embedded in the PDF page image interfere with OCR? Should I remove these? If so, can anyone suggest a method for removing them automatically?

EDIT:
For simplicity, here is the code I used.

import tesseract
api = tesseract.TessBaseAPI()
api.Init(".","eng",tesseract.OEM_DEFAULT)
api.SetPageSegMode(tesseract.PSM_AUTO)

mImgFile = "eurotext.jpg"
mBuffer=open(mImgFile,"rb").read()
result = tesseract.ProcessPagesBuffer(mBuffer,len(mBuffer),api)
print "result(ProcessPagesBuffer)=",result

And here is the alterative code (whose results are not shown in this question, although the performance appears to be quite similar).

import cv2.cv as cv
import tesseract

api = tesseract.TessBaseAPI()
api.Init(".","eng",tesseract.OEM_DEFAULT)
api.SetPageSegMode(tesseract.PSM_AUTO)

image=cv.LoadImage("eurotext.jpg", cv.CV_LOAD_IMAGE_GRAYSCALE)
tesseract.SetCvImage(image,api)
text=api.GetUTF8Text()
conf=api.MeanTextConf()

Could anyone explain the differences between these two snippets?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T21:45:40+00:00Added an answer on June 8, 2026 at 9:45 pm

    Tesseract is very good on clean input text (like your example) if you tinker a bit. some suggestions:

    • Before automating, start with tesseract at the command line
    • Restrict your character set if possible (e.g. take a look in /usr/local/share/tessdata/configs at ./digits – configure it for English characters upper/lower case etc) and provide it as a command line argument
    • Only use PNG or TIFF images (TIFF for older versions) as JPG introduces artefacts
    • Upsample the image so your text is larger than the current tiny font. Tesseract lines >10 pixel high characters (if memory serves), it certainly performs worse with tiny characters
    • No need to do thresholding if you’re bi-level already but it won’t hurt if you do and you can see exactly the same image that tesseract will see

    I’ll check back here to see if I can help more but do join the tesseract mailing list, they’re really helpful.

    Sidenote – I have some patches for pytesseract which I ought to publish for getting characters & confidences & words via the API (which wasn’t possible a couple of months back). Shout if they might be useful.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am doing a simple coin flipping experiment for class that involves flipping a
I have a bunch of posts stored in text files formatted in yaml/textile (from
I know there's a lot of other questions out there that deal with this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.