Imagte OCR workbench

How OCR Works: Accuracy Tips for Clean Text

By Nora Quinn · Published · Updated

Optical character recognition looks like magic when it works and like a prank when it doesn’t. Knowing what happens between “drop an image” and “here is your text” makes both outcomes predictable. This guide walks through the stages an engine like Tesseract goes through, then turns each stage into something you can control before you press the button.

Imagte runs tesseract.js v5, a WebAssembly build of the open-source Tesseract engine, entirely inside your browser. The stages below describe that engine, but the same ideas apply to most OCR software.

The four stages of OCR

1. Binarization: deciding what is ink

The engine first converts your image to pure black and white. Every pixel gets classified as either “ink” or “paper.” Tesseract does this with a global thresholding method (Otsu’s method by default), which looks at the brightness histogram of the whole image and picks the cut-off that best separates two groups.

That works well on an evenly lit scan. It works badly on a phone photo where the top of the page is bright and the bottom sits in your hand’s shadow. A single threshold can’t serve both halves, so the shadowed lines turn into solid black blobs or the bright lines wash out to nothing. Most “OCR returned garbage” complaints start here.

2. Layout analysis: finding lines and blocks

Next, the engine looks for structure. It groups connected ink into characters, characters into words, words into text lines, and lines into blocks or columns. This page segmentation step decides reading order. If a two-column article gets read straight across, you’ll see sentences from the left column spliced into the right one.

Layout analysis also decides what isn’t text. Photos, logos, rules and stains should be ignored, but a heavy table border or a coffee ring can get mistaken for a line of characters and produce a row of punctuation noise.

3. Line recognition with an LSTM

Since version 4, Tesseract recognizes text one whole line at a time using a neural network called an LSTM (long short-term memory). Rather than matching isolated letter shapes against templates, the network reads the line image as a sequence, left to right, and outputs the most likely string of characters. Because it sees context, it can tell that a shape between “c” and “t” in “fact” is probably an “a” even if the ink is broken.

Each language you select loads its own trained model. That’s why picking the right language matters so much: an English model has never learned “ß” or “ñ,” and a Latin-script model can’t read Japanese at all.

4. Confidence scores

For every word, the engine reports a confidence value from 0 to 100. It’s the engine’s own estimate of how sure it is, not a guarantee. A crisp word in a common font will usually score in the 90s. Smudged digits, unusual fonts, or words the model rarely saw in training score lower.

Imagte uses that number directly. Any word below the threshold (70 by default, adjustable) gets an amber underline in the output, and the Next suspect button jumps from one flagged word to the next. In the split proofreading view you see the original image with each word’s bounding box beside the text, so you can compare the two without hunting. You can learn more about that workflow on the image to text tool page.

Two caveats: a high score can still be wrong (a confident “rn” that should be “m”), and a low score can still be right. Treat amber as “look here first,” not “this is an error.”

Practical tips for better accuracy

Every tip below targets one of the four stages. The single most useful habit is to fix the image, not the output. Ten seconds spent retaking a photo usually beats ten minutes of correcting text.

Get the resolution right

For a flatbed scan, 300 dpi is the usual target for normal body text. Going much higher mostly makes files bigger; going lower starts to merge thin strokes.

A more universal rule is to look at the x-height, the height of a lowercase “x,” in pixels. Aim for an x-height of at least 20 px. To check, open the image, zoom to 100%, and compare a lowercase letter against a known size. If tiny print falls below that, rescan at a higher dpi or move the phone closer, rather than upscaling afterward. Upscaling invents smooth edges but no new detail.

The Tesseract project’s own notes on improving output quality go deeper on resolution, borders and preprocessing if you want the engine-level detail.

Maximize contrast, evenly

Binarization wants dark ink on light paper with nothing in between.

  • Light the page from two sides, or use diffuse daylight, to avoid one-sided shadows.
  • Turn off the flash for glossy paper; it creates a hot spot that erases text.
  • For faded originals, a scanner’s “grayscale” or “text” mode often gives a cleaner result than color.
  • Avoid colored highlighter over the text if you can use a clean copy instead. Yellow is usually fine; darker colors can merge with the ink.

Straighten skew and perspective

The line recognizer expects horizontal lines. A page rotated by a few degrees is usually handled, but heavy skew or keystone distortion (the page is wider at the bottom than the top because the phone was tilted) breaks lines into fragments. Hold the camera parallel to the page, or use a scanner app that corrects perspective before you export. Our guide to scanning documents with your phone covers this step by step.

Watch the fonts

Standard printed fonts at normal sizes are the easy case. Accuracy drops with:

  • Decorative, script or condensed display fonts.
  • Very light weights (hairline fonts) that disappear during binarization.
  • Dot-matrix and faded thermal printing, where characters are made of separate dots.
  • Handwriting. Tesseract’s models are trained on printed text; expect poor results on handwritten notes.

For these, plan on more proofreading, and lean on the amber underlines.

Pick the correct language

Choose every language actually present on the page. Imagte supports English, Spanish, French, German, Portuguese, Italian, Chinese (Simplified and Traditional), Japanese and Korean. Selecting the wrong one forces the model to map accented or non-Latin characters onto letters it knows, which produces confident nonsense. Selecting extra languages you don’t need can slow things down and occasionally swap similar-looking characters, so keep the list tight.

Crop out the noise

Remove anything that isn’t the text you want: the desk around the page, a thumb, the neighbouring page in a book. Less clutter gives layout analysis fewer chances to invent text blocks or read in the wrong order.

Handle scanned PDFs as pages

A scanned PDF is just images wrapped in a PDF file. Imagte renders each page with pdf.js and runs OCR on it, up to 50 pages per file. The same rules apply: if the scan was made at a low resolution, no setting will recover the missing detail. Try the scanned PDF to text tool with one page first to check quality before running a long document.

A quick workflow for proofreading

  1. Run OCR and switch to the split view.
  2. Press Next suspect to walk through amber words; fix each against the image.
  3. Skim numbers, names and dates even if they aren’t flagged, because these are the costly errors.
  4. If one area is full of suspects, it’s usually an image problem. Retake or rescan that part instead of correcting it word by word.
  5. Export to the format you need: copy, TXT, DOCX or Markdown.

Checklist before you run OCR

  • Text x-height is at least 20 px (or the scan is about 300 dpi).
  • Lighting is even; no shadow bands or flash glare.
  • Page is flat and parallel to the camera; lines look horizontal.
  • Background clutter is cropped away.
  • Every language on the page is selected, and no extras.
  • You plan to check numbers, names and amber-underlined words against the original.

OCR is a pipeline, and each stage inherits the mistakes of the one before. Give binarization a clean, evenly lit image, give layout analysis a straight page, and give the recognizer the right language, and most of the output will need only a light proofread.

Try it: Image to text — Photos, screenshots and scans to editable text. Up to 50 images per batch.

Written by Nora Quinn (a pen name) with AI-assisted drafting, then edited and checked by hand against the workbench as built.