OCR engines are only as good as the picture you feed them. A few seconds of preprocessing — cropping out clutter, fixing contrast, straightening a tilted page — often turns a garbled mess of characters into clean, copy-ready text. This guide walks through the prep steps that make the biggest difference, in roughly the order you should apply them.
Why preprocessing matters
An OCR engine works by isolating each character shape and matching it against patterns it has learned. Anything that confuses that step — shadows, skew, noise, low contrast — lowers accuracy. The Tesseract-based engine behind our image to text converter already does some cleanup internally, but it can only do so much with a dark, crooked phone photo. The cleaner and flatter the input, the fewer mistakes come out the other end.
Think of preprocessing as removing everything that isn't text so the engine can focus on what is.
Crop to the text you actually need
The single fastest win is cropping. Trim away desk backgrounds, neighbouring columns, page edges and anything else that isn't the passage you want. This does two things: it stops the engine wasting effort on irrelevant marks, and it prevents stray shapes from being misread as characters.
If you only need one paragraph from a full page, crop to that paragraph. If you are pulling a table out of a screenshot, crop tightly to the grid so the layout logic in a tool like image to excel has a clean rectangle to work with.
Straighten and deskew
Photos taken by hand are almost never perfectly square to the page. Even a few degrees of rotation smears the baseline that OCR uses to line up characters, and badly skewed text can drop accuracy off a cliff.
- Rotate the image so lines of text run horizontally.
- Correct perspective if the page was shot at an angle, so the top and bottom edges are parallel.
- Re-check that columns are vertical, not leaning.
Many phone scanner apps deskew automatically; if yours doesn't, a quick manual rotate in any photo editor is enough. For more on capture habits that avoid skew in the first place, see our guide on the best image format and resolution for OCR.
Fix contrast and lighting
OCR wants dark text on a light background with a clear boundary between them. Real photos give you grey text, uneven lighting, and shadows from your own hand.
- Increase contrast so the letters pull away from the page.
- Even out lighting by avoiding glare and harsh side-shadows when you capture, or by using a shadow-removal filter afterward.
- Convert to grayscale before thresholding; colour rarely helps OCR and sometimes hurts.
When to invert
If your source is light text on a dark background — a dark-mode screenshot, a slide, a neon sign — the engine can struggle because it expects the opposite. Flip the colours first with our invert image tool so you end up with dark characters on a light field, then run OCR. This one trick rescues a surprising number of failed extractions.
Thresholding: turning grey into black and white
Thresholding (also called binarisation) converts a grayscale image into pure black and white by deciding, pixel by pixel, what counts as ink and what counts as paper. Done well, it removes faint background texture and sharpens character edges.
A simple global threshold works for evenly lit scans. For photos with uneven lighting, an adaptive threshold — which sets the cutoff locally rather than for the whole image — handles shadows far better. If you don't want to do this manually, just feed a clean grayscale image to our image to text tool and let the engine handle binarisation; the point is mainly that good lighting upstream makes any threshold work.
Remove noise and clean speckles
Scans of old paper, fax-quality documents and compressed JPGs often carry speckle noise — tiny dots that OCR may read as stray punctuation. A light denoise or median filter smooths these away without blurring the letters. Don't overdo it: aggressive blurring erases thin strokes and serifs, which hurts more than the noise did.
Get the resolution right
Resolution is part of preprocessing too. Text that's too small for the engine to resolve produces nonsense no matter how clean the contrast is. Aim for characters that are clearly legible at 100% zoom; for scanned documents, 300 DPI is the standard sweet spot. Upscaling a tiny image rarely adds real detail, so it's better to recapture at higher resolution than to enlarge afterward. Our deep dive on rescuing blurry or low-quality images covers what to do when recapturing isn't an option.
A quick preprocessing checklist
- Crop tightly to the text you need.
- Rotate and deskew so lines are level.
- Convert to grayscale.
- Boost contrast and even out lighting.
- Invert if the text is light-on-dark.
- Apply a clean threshold if the engine isn't already doing it.
- Lightly denoise speckles only if present.
- Confirm the text is large and sharp enough to read.
Run through that list and most documents will OCR cleanly. For the broader picture beyond preprocessing, our roundup of ways to improve OCR accuracy ties these prep steps together with capture and output tips.
Frequently asked questions
Do I need special software to preprocess images?
No. The high-impact steps — cropping, rotating, adjusting contrast and inverting — are available in your phone's built-in photo editor and every desktop image tool. Our online invert image converter covers the light-on-dark case in one click, and our OCR engine handles binarisation for you.
Does preprocessing matter if my scan is already clean?
Less so. A flat, well-lit 300 DPI scan often needs nothing more than a tight crop. Preprocessing pays off most with phone photos, dark-mode screenshots and low-quality or aged documents where lighting and skew are uneven.
Will increasing contrast too much cause problems?
Yes. Pushing contrast past the point where thin strokes disappear will erase parts of letters and create new errors. Aim for crisp, fully-formed characters rather than the most extreme black-and-white possible.
Should I sharpen a blurry image before OCR?
Mild sharpening can help recover slightly soft edges, but it amplifies noise and can't recreate detail that isn't there. Recapturing at higher resolution beats sharpening; see our guide on low-quality images for the full approach.
Ready to put it into practice? Clean up your image with the steps above, then drop it into our free image to text converter and copy out the result.