Prompt
How do I extract data from poor-quality scans and skewed photos?
Latest observation
Oct 11, 2026
OpenAI APIWeb search: off
To extract data from poor-quality scans and skewed photos, use a pipeline that fixes geometry first, then improves image quality, then runs OCR or table extraction.
Practical workflow
1) Correct the perspective and rotation
If the page is tilted, warped, or photographed at an angle:
- Deskew: rotate the image so text lines are horizontal.
- Perspective correction: fix trapezoid distortion from angled photos.
- Crop: remove borders/background.
Common tools:
- OpenCV for deskew/perspective correction
- ScanTailor, Adobe Scan, Microsoft Lens for quick document cleanup
2) Improve image quality
For low-quality scans:
- Convert to grayscale
- Increase contrast
- Reduce noise
- Apply sharpening if needed
- Use adaptive thresholding to make text clearer on uneven backgrounds
- Upscale low-resolution images before OCR if text is tiny
3) Use OCR
Run OCR on the cleaned image.
Good OCR engines:
- Tesseract: free, widely used
- PaddleOCR: often better on difficult images
- EasyOCR: simple to use
- Cloud OCR: Google Vision, Azure OCR, AWS Textract
4) Post-process the text
OCR on bad images often has errors, so:
- Spell-check or use a domain dictionary
- Use regex to extract structured fields
- Normalize dates, amounts, IDs, etc.
- Compare multiple OCR passes if needed
5) If it’s a table or form
For tabular data:
- Detect table structure first
- Use tools like Camelot, Tabula for PDFs
- For scanned forms/photos, use AWS Textract, Google Document AI, or PaddleOCR + table structure models
OpenCV example: deskew + OCR
import cv2
import numpy as np
import pytesseract
img = cv2.imread("scan.jpg")
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# Denoise
gray = cv2.GaussianBlur(gray, (3,3), 0)
# Threshold
thresh = cv2.adaptiveThreshold(
gray, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C,
cv2.THRESH_BINARY, 31, 11
)
# Find angle for deskew
coords = np.column_stack(np.where(thresh > 0))
angle = cv2.minAreaRect(coords)[-1]
if angle < -45:
angle = -(90 + angle)
else:
angle = -angle
(h, w) = thresh.shape[:2]
center = (w // 2, h // 2)
M = cv2.getRotationMatrix2D(center, angle, 1.0)
deskewed = cv2.warpAffine(thresh, M, (w, h), flags=cv2.INTER_CUBIC, borderMode=cv2.BORDER_REPLICATE)
text = pytesseract.image_to_string(deskewed, config="--oem 3 --psm 6")
print(text)
Tips for better results
- Take photos in good lighting
- Keep the camera parallel to the page
- Use high resolution
- Avoid shadows and reflections
- Capture the entire document
- If possible, scan at 300 DPI or higher
If you want the best accuracy
A strong combination is:
- Perspective correction
- Contrast enhancement
- OCR with PaddleOCR or a cloud OCR API
- Domain-specific cleanup rules
If you want, I can give you:
- a Python script for skew correction and OCR,
- a pipeline for tables/forms, or
- recommendations for the best OCR tool for your type of document.