Sari la conținut

OCR Preprocessing Pipeline Testing Results

Overview

This document presents empirical testing results of various image preprocessing pipelines optimized for Romanian medical text OCR using Tesseract. The goal is to maximize OCR accuracy while minimizing processing complexity and LLM token usage.

Test Images

  • medinterna1.jpeg: Romanian medical textbook page (rotated input)
  • medinterna2.jpeg: Romanian medical textbook page (rotated input)
  • Both images were scanned documents with 300+ DPI resolution and visible text content in Romanian

Preprocessing Pipelines Tested

Pipeline Descriptions

  1. basic: Grayscale conversion + Gaussian blur + adaptive thresholding
  2. enhanced: CLAHE contrast enhancement + bilateral filtering + morphological operations
  3. sharpening: Sharpening kernel + median blur + adaptive thresholding
  4. morphological: Otsu thresholding + morphological opening/closing + dilation
  5. deep_clean: Background subtraction + contrast normalization + morphological cleaning
  6. optimal_backprop: Bilateral filtering + CLAHE + optimal parameters + light morphology

Common Steps Applied to All Pipelines

  • Automatic rotation correction (>2 degrees threshold)
  • Additional deskewing (<0.5 degree threshold)
  • Romanian language OCR with pytesseract

Test Results

medinterna1.jpeg Results

Pipeline Characters Extracted Performance Score
basic 200 ⭐⭐⭐
enhanced 0 ❌
sharpening 0 ❌
morphological 0 ❌
deep_clean 56 ⭐
optimal_backprop 139 ⭐⭐

medinterna2.jpeg Results

Pipeline Characters Extracted Performance Score
basic 664 ⭐⭐⭐
enhanced 83 ⭐
sharpening 117 ⭐⭐
morphological 27 ⭐
deep_clean 41 ⭐
optimal_backprop 702 ⭐⭐⭐⭐

Analysis and Conclusions

Best Performing Pipeline: optimal_backprop

  • Average Performance: 420.5 characters extracted across test images
  • Consistency: Performed well on both test images
  • Features:
  • Bilateral filtering (preserves edges while reducing noise)
  • CLAHE (Contrast Limited Adaptive Histogram Equalization)
  • Adaptive thresholding with optimized parameters
  • Light morphological cleaning

Key Findings

  1. Over-processing degrades performance: Enhanced, sharpening, morphological, and deep_clean pipelines extracted significantly fewer characters, suggesting over-aggressive noise removal or contrast adjustments damage text readability.

  2. Balance is key: The optimal_backprop pipeline strikes the right balance between noise reduction and text preservation.

  3. CLAHE works well: Contrast enhancement improves text visibility without over-saturation.

  4. Light morphology preferred: Heavy morphological operations can destroy fine text details.

Recommendations

  1. Use optimal_backprop pipeline for Romanian medical text OCR
  2. Avoid over-processing: Simpler pipelines often perform better than complex ones
  3. Test on target domain: Results may vary for different document types (printed vs handwritten, font sizes, etc.)
  4. Monitor for degradation: Some pipelines that fail completely may indicate issues with parameters or processing logic

Technical Parameters (optimal_backprop)

# Bilateral filter: d=9, sigmaColor=75, sigmaSpace=75
# CLAHE: clipLimit=3.0, tileGridSize=(8,8)
# Adaptive threshold: blockSize=15, C=3
# Morphology: Opening with 1x1 kernel

Future Testing Recommendations

  1. Test on additional Romanian medical documents
  2. Evaluate accuracy metrics beyond character count (word accuracy, contextual accuracy)
  3. Test computational performance impact
  4. Validate with different scan qualities (lower DPI, different scanners)
  5. Compare with Visio OCR baseline performance

Visio OCR Integration Planning

Based on these results, the optimal_backprop preprocessing should be applied before attempting Visio OCR to maximize comparison accuracy and minimize token usage.