Handling low-quality scans and skewed images in OCR starts with a preprocessing stage that corrects the image before any text recognition runs, since OCR accuracy drops sharply on rotated, noisy or low-contrast pages. Standard preprocessing steps include deskewing to straighten rotated pages using detected text line angles, denoising to remove speckle and scanner artifacts, binarization or contrast enhancement to separate text from background on faded or yellowed documents, and upscaling for images captured at low resolution from a phone camera rather than a flatbed scanner. Modern OCR engines and vision-language models are increasingly robust to moderate skew and noise on their own, reducing but not eliminating the need for manual preprocessing tuning, particularly for severely degraded historical documents or carbon-copy forms. A practical pipeline runs automated quality checks on each incoming page, flags images below a resolution or contrast threshold for rescanning or manual review, and applies preprocessing adaptively rather than a single fixed filter chain across all documents. Measuring OCR confidence scores per page, not just per document, helps identify which specific pages need attention rather than reprocessing an entire batch. Nanobase AI tunes preprocessing pipelines to the actual scan quality and equipment a customer uses rather than assuming clean input.
Preprocessing as a visual inspection gate, not a blanket filter
Every incoming scan should pass through an automated quality check before OCR even runs, functioning as a visual inspection step that catches a page too degraded to process reliably before it wastes downstream extraction effort on unreadable input. Running the same fixed preprocessing chain on every page regardless of its actual condition wastes processing time on already-clean pages and under-corrects severely degraded ones, so the more effective pattern inspects each page's resolution, contrast and skew angle first and applies only the corrections that specific page actually needs. A page below a defined resolution or contrast threshold is often better flagged for rescanning than pushed through aggressive correction that cannot fully recover missing detail.
Common defect types and their fixes
| Defect | Detection signal | Standard fix |
|---|---|---|
| Skew (rotated page) | Text line angle deviates from horizontal | Deskew using detected line angle (Hough transform) |
| Low contrast / faded ink | Narrow pixel intensity histogram | Contrast enhancement, adaptive binarization |
| Speckle noise, scanner artifacts | High-frequency pixel noise | Denoising filter (median or Gaussian) |
| Low resolution (phone photo) | DPI below threshold, blurry edges | Upscaling, sharpening, or reject for rescan |
| Uneven lighting or shadow | Gradient across page background | Adaptive thresholding rather than global binarization |
A deskew and binarization example
import cv2
import numpy as np
image = cv2.imread("scan.png", cv2.IMREAD_GRAYSCALE)
coords = np.column_stack(np.where(image < 128))
angle = cv2.minAreaRect(coords)[-1]
(h, w) = image.shape
matrix = cv2.getRotationMatrix2D((w // 2, h // 2), angle, 1.0)
deskewed = cv2.warpAffine(image, matrix, (w, h), flags=cv2.INTER_CUBIC)
_, binarized = cv2.threshold(deskewed, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)
This kind of pipeline, angle detection followed by rotation correction and Otsu-based binarization, handles the majority of moderate skew and contrast issues automatically before a document reaches the OCR engine.
Adaptive preprocessing versus a fixed filter chain
Modern OCR engines and vision-language models are increasingly robust to moderate skew and noise on their own, which reduces but does not eliminate the value of preprocessing, particularly for severely degraded historical documents, carbon-copy forms, or thermal-paper receipts that fade over time. Measuring OCR confidence scores per page rather than per document identifies exactly which pages need attention, so a batch is not uniformly reprocessed when only a handful of pages actually caused the problem. Building preprocessing as a set of independent, composable steps, each triggered by its own detection signal, rather than one fixed sequential filter applied to every image, keeps processing efficient while still catching the genuine edge cases that would otherwise silently degrade extraction accuracy downstream.
Frequently asked questions
Do vision-language models still need image preprocessing?
Less than traditional OCR engines, since they tend to be more robust to moderate noise and skew, but severely degraded scans, extreme rotation or very low resolution still measurably reduce their accuracy, so basic preprocessing remains worthwhile rather than optional.
How is a page automatically flagged for rescanning instead of processed?
A resolution, contrast or skew-angle threshold defined ahead of time can auto-reject pages below quality standards before OCR runs, routing them to a rescan or manual review queue rather than letting a low-confidence extraction pass through silently downstream into a target system.
Does preprocessing risk removing genuine content from a scan?
Aggressive binarization or denoising can occasionally remove faint but genuine content, particularly light pencil marks or very faded stamps, which is why preprocessing parameters should be tuned and tested against real degraded samples rather than applied at maximum strength by default.
How Nanobase AI helps
Nanobase AI tunes preprocessing pipelines, including automated quality inspection thresholds, to the actual scan quality and equipment a customer uses, rather than assuming clean input and discovering the gap in production. This fits into a broader document AI deployment. Related: best OCR for handwritten documents.
Ready to discuss your project? Contact Nanobase AI or email hello@bumu.tech.