SETS

Historical Document Processing: From non-professional photographs taken in the archive to digital text

Complete Workflow Overview

Our research combines multiple image processing techniques with LLMs to transform historical handwritten documents into searchable digital text. The complete pipeline consists of four main stages:

┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐    ┌─────────────────┐
│   Photographed  │───▶│     Image       │───▶│  Enhanced       │───▶│    LLM OCR      │
│   Historical    │    │  Processing     │    │   Output        │    │   Pipeline      │
│   Document      │    │                 │    │   Images        │    │                 │
└─────────────────┘    └─────────────────┘    └─────────────────┘    └─────────────────┘
                                ↓                        ↓                        ↓
                       Multiple Methods:           Ready for AI:            📝 Digital Text:
                       • Adaptive                 • Clean, enhanced        • Automatic transcription
                       • Graph Analysis           • High contrast          • Structured output
                       • Color Filtering          • Noise-free             • Searchable content
                       • Edge Detection           • Optimized format       

The Challenges

Archives of handwritten documents are vast, measuring in the millions of shelving kilometers worldwide. And yet, many have not been professionally scanned and digitized. Instead, scholars will often take photographs of the documents while visiting the archive. The quality of the resulting images can be poor:

As a result, computational research with these materials is limited because:

Our goal: Automated enhancement and transcription of non-professionally photographed handwritten archival documents.


Image Processing Methods

We experimented with and evaluated multiple computer vision image preprocessing techniques to reduce noise, and improve machine readability. This approach follows preprocessing methods from prior work 1.

Processing Methods Overview

Input Document ──┬── Edge Detection ────────── Enhanced Output
                 ├── Color Filtering ──────── Enhanced Output  
                 ├── Adaptive Thresholding (3 types) ── Enhanced Output
                 ├── Graph Analysis ──── Enhanced Output
                 └── CLAHE Enhancement ──────────────── Enhanced Output

Method Details and Applications

Edge Detection Approach

Technique: Canny Edge Detection + Morphological Closing

Color-Based Ink Isolation

Technique: HSV Color Space Filtering

CLAHE Enhancement

Technique: Contrast Limited Adaptive Histogram Equalization

Adaptive Thresholding (Primary Method)

Our most reliable and versatile approach with three variants:

Standard

Stronger

Mean

Graph Analysis (Advanced Structural Method)

Our most effective though costly approach Technique: Connected Component Analysis + Graph Theory

Sample Images

Original Graph Analysis Adaptive Thresholding Standard Adaptive Thresholding Strong Adaptive Thresholding Mean
Original Graph Standard Strong Mean

Processing Methods Comparison

Method Core Technique Best For Complexity
Edge Detection Canny Edge Detection Edge-heavy documents Low
Color Filtering HSV Color Space Brown/sepia ink Low
Adaptive Threshold Gaussian Thresholding General enhancement Medium
Contrast Enhancement Histogram Equalization Severely faded text Medium
CLAHE Enhancement Contrast Limited Adaptive Histogram Equalization Uneven lighting, localized contrast issues Medium
Graph Analysis Connected Components Structural understanding High

Performance Notes

LLM OCR Experimental Framework

After image enhancement, we employ an AI-powered transcription pipeline. The LLM-powered OCR pipeline is a step-by-step process that turns messy scans, photos, or PDFs into clear, usable text. It begins by cleaning up the image to fix issues like skew, noise, or uneven lighting. Next, it identifies different parts of the page—such as paragraphs or tables—and then uses OCR or large language models to read the text. The output is polished to correct mistakes, improve readability, and extract important details like names, dates, or numbers. Finally, the results can be saved as plain text, structured data, or even a searchable PDF, with an option for human review when extra accuracy is needed.

Complete LLM Pipeline Architecture

   Enhanced Images (from above) ──┬── Preprocessing Pipeline ────┬── Model Processing
                                  │                              │
┌─────────────────────────────────┴──────────────────────────────┴────────────────────┐
│                              MODULAR OCR PIPELINE                                   │
│                                                                                     │
│     PREPROCESSING              AI PROCESSING                POSTPROCESSING          │ 
│  ┌─────────────────┐       ┌─────────────────────┐       ┌─────────────────────┐    │
│  │ • Contrast      │──────▶│  API Models:        │──────▶│ • Text Cleaning     │    │
│  │   Enhancement   │       │  • GPT-4o/4o-mini   │       │ • Entity Extraction │    │
│  │ • Image Resize  │       │  • Claude 3 Sonnet  │       │ • Format Validation │    │
│  │ • Sharpening    │       │  • Gemini 1.5/2.5   │       │ • Quality Scoring   │    │
│  │ • Noise Removal │       │                     │       │                     │    │
│  └─────────────────┘       │  Local Models:      │       └─────────────────────┘    │
│                            │  • TrOCR Handwritten│                                  │
│                            │  • LLaVA-1.5        │                                  │
│                            │  • Moondream2       │                                  │
│                            │  • InstructBLIP     │                                  │
│                            └─────────────────────┘                                  │
└────────────────────────────────────────────────────────────────────────────────────┘
                                           ↓
                            BATCH PROCESSING & ANALYSIS
                        ┌──────────────────────────────────┐
                        │ • Multi-image processing         │
                        │ • Model comparison analysis      │
                        │ • Parameter sensitivity testing  │
                        │ • Ground truth evaluation        │
                        │ • Performance benchmarking       │
                        └──────────────────────────────────┘

Processing Options and Capabilities

Preprocessing Stage

Purpose: Optimize images specifically for LLM vision models

Multi-Model AI Processing

Three categories of models tested:

API-Based Models (Cloud)

Local HuggingFace Models (Self-hosted)

Traditional OCR (Baseline comparison)

Postprocessing and Analysis

Systematic Evaluation Approach

Historical Document ─┬─ Adaptive Threshold Processing ─┬─ GPT-4o (temp=0.1) ─┬─ Compare vs
                     │                                 ├─ GPT-4o (temp=0.7) ─┤  Ground Truth
                     │                                 └─ Claude 3 Sonnet ───┤
                     │                                             
                     └─ Graph Analysis ─────┬─ GPT-4o (temp=0.1) ─┤
                                            ├─ GPT-4o (temp=0.7) ─┤
                                            └─ Claude 3 Sonnet ───┘

Experimental Dataset Structure

Data/
├── document_1/
│   ├── original.jpg                      # Source document
│   ├── adaptive_threshold.jpg            # Standard processing
│   ├── graph_analysis.jpg                # Advanced processing
│   ├── {model}_{method}_{temp}.txt       # LLM transcriptions (multiple per document)
│   └── ground_truth.txt                  # Reference transcription
└── [more document folders]

Implementation and Impact

These efforts address the specific needs of non-professional handwritten document photographs taken in archives by visiting scholars. These unprofessional photographs present a number of challenges that are not widely addressed in the computer vision community. They are at the intersection of two problem types: 1. handwriting recognition; 2. non-uniform illumnination. Methods that address one or the other of these issues do not provide a a comprehensive solution. Our research will contribute to ongoing work on this compound CV problem.

  1. A. A. Shihotov and T. M. Tatarnikova, “Methods for Preprocessing Images of Handwritten Documents in Computer Vision Tasks,” WECONF 2025, doi: 10.1109/WECONF65186.2025.11017244. ↩