How Does OCR Work? Six Steps, and What Breaks Each One

OCR captures an image, cleans it, finds the text regions, recognizes characters, checks the result and outputs text with confidence scores. In our tests accuracy stayed near perfect until a defect crossed a threshold, then collapsed: a 5 degree tilt cost almost nothing, an 8 degree tilt cost almost everything.
OCR (optical character recognition) works in six steps: capture an image of the page, clean it up, find where the text is, recognize the characters, check the result against rules, and write out text with a confidence score for each word. Most explanations stop there. We went further and broke each step on purpose, running more than 2,500 OCR passes on pages whose correct text we knew exactly, to see where it fails.
The result changes how you should think about bad OCR output. OCR does not degrade gradually. It stays almost perfect until a defect crosses a threshold, then collapses. A 5 degree tilt cost about 3 percent of words. An 8 degree tilt cost 90 percent. A blur of 2 pixels cost nothing, and 3 pixels cost a quarter of the words. Below, each step comes with the measured threshold, so you can tell how much margin your own scans have.
One caveat before the numbers. These are tests of Tesseract 5.5.2, a free engine, on clean synthetic pages, not tests of DocsAPI. We used a free engine so that anyone can repeat every figure. Real scans fail earlier than synthetic ones, so read the shape of each curve and treat the exact cutoffs as best-case.
What are the six steps of OCR?
- Capture: a scanner, camera or PDF export produces an image.
- Clean-up (preprocessing): straighten the page, remove noise, even out the lighting.
- Layout analysis: find text regions, columns, tables and the reading order.
- Recognition: turn each line or word image into characters, with a probability for each guess.
- Post-processing: catch likely mistakes with dictionaries, field formats and cross-field arithmetic.
- Output: write plain text, a searchable PDF, or structured data with positions and confidence.
How we tested
- Pages: synthetic pages, 8.5 by 5.5 inches, 20 lines of 10 point Arial, rendered at 600 DPI so we could downsample cleanly. The text is random business wording with invoice numbers, dates and dollar amounts mixed in, so the correct answer is known exactly.
- Sample: 20 different pages for every condition, more than 2,500 OCR runs in total across all our experiments, on a 10-core Apple M5 Mac with 16 GB of memory.
- Scores: words wrong is word error rate: the edit distance between the correct words and the OCR words, divided by the number of correct words. Numbers read right is the share of tokens containing a digit that came back exactly correct, because a wrong digit is the error that costs money.
- Limits: one engine, one font, English, one defect at a time. With 20 pages per condition, differences of a point or two are noise.
Step 1, capture: how small is too small?
Nothing later can recover detail that was never captured, so the first question is how many pixels each character gets. We rendered the same 10 point page at different resolutions and measured what happened.
| Resolution | Character size (em height) | Words wrong | Numbers read right |
|---|---|---|---|
| 72 DPI | 10 px | 17.4% | 76.1% |
| 100 DPI | 14 px | 0.8% | 98.5% |
| 150 DPI | 21 px | 0.0% | 100% |
| 200 DPI | 28 px | 0.0% | 100% |
| 300 DPI | 42 px | 0.0% | 100% |
| 600 DPI | 83 px | 0.1% | 99.8% |
The cliff sits between 72 and 100 DPI, and going above 150 bought nothing. Resolution is only a proxy, though. What the engine sees is how many pixels tall each character is. To find that threshold directly, we rendered the same page at different character sizes.
| Character size (em height) | Words wrong | Numbers read right |
|---|---|---|
| 6 px | 100% | 0.0% |
| 7 px | 99.6% | 2.0% |
| 8 px | 91.5% | 19.4% |
| 9 px | 48.4% | 49.9% |
| 10 px | 17.4% | 76.1% |
| 11 px | 4.7% | 90.8% |
| 12 px | 2.3% | 95.8% |
| 14 px | 0.3% | 99.1% |
| 16 px | 0.1% | 99.8% |
| 20 px | 0.0% | 99.9% |
Text went from unreadable at 8 px to nearly clean at 14 px. Beyond 16 px nothing improved (one 24 px run came out noisier at 3.2% words wrong, which we did not investigate). The formula to remember is character size in pixels = font size in points x DPI / 72. Keep that at 14 or more and you are on the safe side of the cliff. For 8 point print that means at least 126 DPI. For a 6 point footnote it means 168 DPI.
This is also why 300 DPI is the standard advice, including Tesseract's own guidance. It is not that 300 is a cliff edge. For 10 point text it puts you at 42 px, roughly three times above the point where our test started failing, and that spare room is what absorbs the other defects below. If you photograph pages with a phone instead of scanning them, a 12 megapixel photo of an A4 page works out to roughly 250 to 340 DPI, depending on how much of the frame the page fills, so resolution is rarely the problem. Tilt, shadow and blur are.
If you do not know whether a PDF was scanned in the first place, readable PDF vs image PDF shows how to tell in under a minute.
Step 2, clean-up: what straightening, blur, noise and shadow cost
Preprocessing is where most fixable errors live. We tested each defect on its own, at 300 DPI.
Tilt: harmless until it suddenly is not
| Tilt | Words wrong | Numbers read right | After deskewing: words wrong | After deskewing: numbers right |
|---|---|---|---|---|
| 0 degrees | 0.0% | 100% | not needed | not needed |
| 1 degree | 0.3% | 99.1% | 0.0% | 100% |
| 2 degrees | 1.0% | 97.2% | 0.0% | 99.9% |
| 3 degrees | 1.4% | 95.8% | 0.0% | 99.9% |
| 5 degrees | 2.8% | 91.0% | 0.0% | 99.9% |
| 8 degrees | 89.8% | 7.6% | 0.0% | 100% |
| 12 degrees | 98.1% | 3.2% | 0.0% | 99.9% |
Two things stand out. First, the cliff: the engine shrugged off 5 degrees, then lost nearly everything at 8. Second, on tilt, numbers fail before words. At 5 degrees, 2.8 percent of words were wrong but 9 percent of number tokens were. A damaged word can often be rescued by what the engine knows about language, and a damaged digit has nothing to be rescued by. We did not test that explanation, but a wrong digit is also the error a spell check never flags.
The fix is cheap. Straightening the page before recognition took every tilt from 1 to 12 degrees back to essentially perfect. This is the version we used: it rotates a shrunken copy of the page through a range of angles and keeps the angle at which the text lines pile up into the sharpest horizontal bands.
import cv2
import numpy as np
def deskew(gray):
small = cv2.resize(gray, None, fx=0.25, fy=0.25, interpolation=cv2.INTER_AREA)
ink = (small < 160).astype(np.float32)
h, w = ink.shape
def score(angle):
m = cv2.getRotationMatrix2D((w / 2, h / 2), angle, 1.0)
return cv2.warpAffine(ink, m, (w, h)).sum(axis=1).var()
coarse = max(np.arange(-15, 15.01, 0.5), key=score)
best = max(np.arange(coarse - 0.5, coarse + 0.51, 0.1), key=score)
m = cv2.getRotationMatrix2D((gray.shape[1] / 2, gray.shape[0] / 2), best, 1.0)
return cv2.warpAffine(gray, m, (gray.shape[1], gray.shape[0]), borderValue=255), best
It searches plus or minus 15 degrees. On a 20 degree tilt it left about 5 degrees of error, which the engine tolerated at 2.7 percent words wrong. Tilt beyond 15 degrees needs a wider search, or an orientation check first, as described in document detection before OCR.
Blur and noise: specks hurt more than grain
| Defect | Level | Words wrong | Numbers read right |
|---|---|---|---|
| Blur | 2 px | 0.0% | 99.8% |
| Blur | 3 px | 27.1% | 78.5% |
| Blur | 4 px | 48.0% | 52.5% |
| Grain (Gaussian noise) | 40 of 255 | 0.0% | 100% |
| Grain (Gaussian noise) | 60 of 255 | 44.6% | 61.4% |
| Specks (black and white dots) | 1% of pixels | 6.9% | 92.0% |
| Specks | 3% of pixels | 21.7% | 71.8% |
| Specks | 6% of pixels | 48.6% | 56.2% |
| Specks | 12% of pixels | 100% | 0.0% |
Smooth grain was tolerated until it got severe, while a light dusting of isolated dots, only 1 percent of pixels, already cost 7 percent of words. Isolated dots resemble full stops and ink strokes, which may be why they confuse the engine more than an even haze does. If your scans come from dusty glass or a fax, a median filter is worth testing before anything else.
Two results surprised us. JPEG compression alone did nothing: quality 95, 75, 50, 30, 15 and even 8 all scored 0.0 percent words wrong on a clean 300 DPI page. And fading barely mattered: squeezing the contrast down to 15 percent of the original still read perfectly. We tested defects one at a time, and real photos stack them, so do not read these as permission to compress aggressively. The stacked case is in our layout analysis tests, where a tilted, blurred, noisy, compressed bank statement fell to 69 percent of rows correct, and straightening it first brought that back to 93 percent.
Uneven light: the cleaning step that made things worse
Clean-up has a trap. The usual advice is to convert the page to pure black and white first. We shaded the page so brightness fell from full at the left edge to a fraction of that at the right, then compared three versions of each page: untouched, thresholded with one global cutoff (Otsu), and thresholded per neighborhood (adaptive).
| Right edge brightness | Untouched | One global threshold | Adaptive threshold |
|---|---|---|---|
| 60% of left edge | 0.0% wrong | 0.0% wrong | 0.1% wrong |
| 45% of left edge | 0.2% wrong | 27.9% wrong | 0.0% wrong |
| 30% of left edge | 36.2% wrong | 38.7% wrong | 0.0% wrong |
At 45 percent shading the untouched page read fine, and the global threshold turned it into a failing page, because the dim side went solid black. Preprocessing made a working page unusable. At the extreme the adaptive threshold was the only version that survived, and on a well-lit page it cost a hair (0.3 percent words wrong at no shading). So clean-up is not free. Test it on your worst page, with and without, before you add it to a pipeline.
import cv2
gray = cv2.imread("page.png", cv2.IMREAD_GRAYSCALE)
gray = cv2.GaussianBlur(gray, (3, 3), 0)
# One cutoff for the whole page: fails on shadows
_, global_bw = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)
# A cutoff per 31 pixel neighborhood: survives uneven light
local_bw = cv2.adaptiveThreshold(
gray, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY, 31, 15
)
Step 3, layout: right words, wrong order
Layout analysis decides which regions to read and in what order, and its failures are invisible to a character score. On a two-column page, one wrong setting made 88 percent of words wrong while every word was still present in the output. The measured detail, plus tables and the field-finding step that follows, is in OCR layout analysis, tested. We kept it out of this guide so the two do not repeat each other.
Step 4, recognition: the same engine on different kinds of text
Recognition is where neural networks come in. Tesseract 5 reads a whole line image with an LSTM network and outputs the likeliest character sequence, and each choice carries a probability. How well it does depends on what the text is. These figures come from our 1,700-document benchmark, which DocsAPI ran itself, so cite it as DocsAPI's own result.
| Document type | Tesseract | PaddleOCR | DocsAPI |
|---|---|---|---|
| Clean typed English | 97 to 99% | 97 to 99% | 97 to 99% |
| Multi-page bank statement tables | 64% | 79% | 91% |
| Phone-photographed receipts | 58% | 82% | 76% |
| Multilingual pages | 71% | 89% | 81% |
| Handwritten forms | 61% | 73% | 78% |
The point of the table is the first row against the others: every engine ties on clean print, and the gaps open up on everything else. That is why a score on clean text tells you almost nothing about your handwritten forms. For a head-to-head on the two free engines with code, see PaddleOCR vs Tesseract vs DocsAPI.
Step 5, post-processing: how far to trust a confidence score
Recognition reads one line at a time and does not know what the line means. Post-processing adds meaning: dictionary checks, field formats such as a valid date, and cross-field arithmetic such as line items adding up to the total. The most practical output of the whole process is the confidence score on each word, so we measured how trustworthy it is.
We pooled 276,564 words from the tilt, blur, noise, speck, resolution and shading runs above, scored each word as right or wrong against the truth, and grouped them by the confidence Tesseract reported. The pool includes badly damaged pages, so 5.6 percent of words were wrong overall. The absolute rates are a property of our mix. The pattern is the lesson.
| Reported confidence | Words | Actually wrong | Share of all errors |
|---|---|---|---|
| Under 50 | 6,734 | 74.5% | 32.6% |
| 50 to 69 | 4,969 | 45.4% | 14.6% |
| 70 to 79 | 3,745 | 42.2% | 10.2% |
| 80 to 89 | 6,972 | 29.8% | 13.5% |
| 90 to 94 | 36,442 | 6.3% | 14.8% |
| 95 to 97 | 217,702 | 1.0% | 14.2% |
Three findings. Confidence ranks risk well: error rates fall steadily as the score rises. It is not a probability: words scored 80 to 89 were wrong 30 percent of the time, not 15. And it has a blind spot: 14 percent of all errors sat in the top band, with scores of 95 or more. Those are confident mistakes, and no threshold on the score will find them.
What a person should review follows from that:
| Send to review | Share of words reviewed | Share of errors caught |
|---|---|---|
| Confidence below 70 | 4.2% | 47.2% |
| Confidence below 80 | 5.6% | 57.4% |
| Confidence below 90 | 8.1% | 70.9% |
| Confidence below 95 | 21.3% | 85.8% |
Reviewing the lowest 8 percent of words catches 71 percent of the errors. Pushing to 95 gets you 86 percent but sends 21 percent of words to a person, more than two and a half times the work, and still leaves the confident mistakes. Closing that last gap takes a second signal that does not depend on the engine's own certainty, which is arithmetic. On the bank statement tests, a running-balance check flagged every statement that had an OCR error at 150 DPI, with no false alarms on clean ones. The numbers are in the layout post.
Where you draw the line should come from your own data, not ours. Run 200 real documents, compare against the correct values, and count errors per confidence band. How to measure OCR accuracy has the script, and OCR accuracy metrics and improvement strategies explains why 99 percent per character can still mean wrong fields. Other engines calibrate their scores differently, so repeat the exercise for any engine you evaluate.
Step 6, output: three forms, three uses
- Plain text: good for search and copy-paste, and the layout is gone.
- Searchable PDF: the original image with an invisible text layer. It looks identical but can be searched. See how to make a PDF searchable and making a scanned PDF searchable.
- Structured data: fields, tables, positions and confidence as JSON or CSV. This is what a business system needs, and it depends on steps 3 and 5, not only recognition.
To see steps 3 to 6 on your own file in one call, run Tesseract and print each word with its position and confidence. Sort by confidence and the first rows are where a person should look first.
tesseract invoice.png stdout --psm 3 -l eng tsv
Which step failed? A diagnosis table with measured limits
| What you see | Likely step | What to check, with our measured limit |
|---|---|---|
| Whole page garbled | 1 Capture | Character height under about 12 px. Compute points x DPI / 72 |
| Fine at a glance, collapses on some pages | 2 Clean-up | Tilt past 5 degrees, blur past 2 px, speckle at 1% or more. Deskew first |
| Left side reads, right side does not | 2 Clean-up | Uneven light plus a global threshold. Try an adaptive threshold |
| Every word right, sentences scrambled | 3 Layout | Wrong page segmentation setting, or columns read across |
| Table values in the wrong columns | 3 Layout | Use table extraction, not plain text |
| One digit swapped | 4 Recognition | Look at the confidence. Add a format rule for the field |
| Confident but wrong | 5 Post-processing | 14% of our errors scored 95 or higher. Add arithmetic checks |
| Looks right, cannot be searched | 6 Output | Export a searchable PDF or structured data |
What these tests do not show
We want to be plain about the limits. The pages were synthetic: a clean sans-serif font on white. Real documents have stamps, folds, show-through and unusual fonts, so they fail at milder defect levels than ours. We tested one engine, one language, and one defect at a time. We did not test handwriting here, and we did not run DocsAPI on these synthetic sweeps. For how DocsAPI does on real documents, use the benchmark figures above, and test any engine on your own worst pages before you rely on a number from anyone, including us.
Where AI extraction fits in
The six steps describe classic OCR. Vision language models read the page image directly and blur steps 3 to 5 together. They cope well with messy layouts and can also return confident wrong numbers, which is a serious problem for finance. We compare the approaches in VLM vs OCR. If you only need clean text from a file or two, free OCR tools are enough. For tables and fields at volume, see best OCR software in 2026, and for running it across thousands of files, bulk OCR processing. For a plain-language overview of the technology itself, start with what an optical character reader is.
Frequently asked questions
OCR takes a picture of a page, cleans it up, finds where the text and tables are, recognizes each word with a probability, checks the result against rules such as valid dates and totals that add up, and outputs text with a confidence score for each word.
Six steps: capture the image, clean it up (deskew, denoise, fix lighting), analyze the layout, recognize the characters, post-process with dictionaries and field rules, and output text, a searchable PDF or structured data.
What matters is character height in pixels, which is font size in points times DPI divided by 72. In our tests with Tesseract, 10 point text was unreadable at 8 pixels, nearly clean at 14, and perfect from 21. 300 DPI is the usual advice because it leaves about three times the margin for 10 point text.
In our tests Tesseract coped with up to 5 degrees, losing about 3 percent of words, and failed almost completely at 8 degrees, with 90 percent of words wrong. Straightening the page first fixed every tilt from 1 to 12 degrees.
Most mistakes come from the early steps: too few pixels per character, a tilted or blurred page, uneven lighting, or a layout read in the wrong order. In our tests accuracy stayed near perfect until a defect crossed a threshold and then collapsed, so a page can look fine and still fail.
They rank risk well but are not probabilities. In our test of 276,564 words, words scored 80 to 89 were wrong 30 percent of the time, and 14 percent of all errors had a score of 95 or higher. Review the low scores and add arithmetic checks for the confident mistakes.
Modern OCR engines use neural networks for recognition. Tesseract 5 uses an LSTM network, and PaddleOCR uses its own detection and recognition models. Newer document AI systems read the whole page with vision language models.
OCR is the process of reading the text. A searchable PDF is one possible output: the original page image with an invisible text layer added so you can search and copy from it.
Related Blog Posts

Convert Fax, TIFF, JPG and PNG to Text, Tested
We ran 3,360 reads across 14 image formats, 7 DPI tags and three fax modes. Format barely matters. A wrong DPI tag, a sideways EXIF photo and an uncleaned fax do.

OCR on Upside-Down and Sideways Pages: What Fixes It
We turned 680 pages to four orientations and read them four ways. One sideways direction reads fine, the other returns about 92% errors, and the orientation detector was silent rather than wrong.

OCR With Stamps, Watermarks and Highlighter: Tested
We added stamps, watermarks, highlighter, grids and tinted backgrounds to 24 invoice pages and read them 4,900 times. Tints were harmless; highlighter, dark watermarks and grids were not.
Want to see it on your own documents?
Try our free OCR tool in your browser, or book a demo to see how DocsAPI reads the document types covered in this guide.
