Introduction
Digitizing physical documents using mobile devices has become a standard practice. However, images captured in uncontrolled environments frequently suffer from geometric distortions, such as folds, curves, and perspective shifts. These distortions significantly degrade the performance of downstream tasks, most notably Optical Character Recognition (OCR).
Existing approaches to document rectification generally fall into two categories: traditional 3D reconstruction, which often requires specialized hardware like laser scanners, and supervised deep learning, which relies on massive amounts of labeled data. Supervised methods often struggle to generalize to complex, real-world deformations due to the difficulty of obtaining ground-truth labels for physical documents. DocMAE addresses this gap by introducing a self-supervised framework that learns effective representations of distorted documents by capturing their intrinsic structural cues—such as text lines and page boundaries—without the need for heavy initial supervision.
The DocMAE Framework
DocMAE utilizes a two-stage pipeline designed to first understand the geometry of a document and then apply that understanding to rectify it.
1. Self-supervised Pre-training
The core innovation lies in adapting the Masked Autoencoder (MAE) paradigm for document images. The process begins with background removal, ensuring the model focuses exclusively on the document's geometry rather than irrelevant environmental noise.
Following the Vision Transformer (ViT) architecture, the model masks a high percentage (75%) of random patches from the document image. A Transformer-based encoder-decoder is then tasked with reconstructing the missing pixels. Because document images possess high spatial redundancy, the model cannot simply interpolate from adjacent pixels; it must learn the global "logic" of the page. To successfully fill in the blanks, the network internalizes the "flow" of text lines and the continuity of page edges, effectively learning a structural prior of how documents deform.
2. Fine-tuning for Rectification
Once the encoder has learned these robust geometric representations, it is paired with a dedicated rectification decoder. In this stage, the model shifts from pixel reconstruction to predicting a dense flow field. This field acts as a coordinate mapping, indicating where each pixel in the distorted image should be moved to achieve a flat, rectified state. The final output is produced by warping the original distorted image according to this predicted flow.
Datasets and Evaluation
The authors evaluated DocMAE using a combination of synthetic and real-world data:
- LDIR (Large-scale Document Image Rectification): A new synthetic dataset featuring 200,000 images. It utilizes 3D rendering to simulate realistic textures, lighting, and complex deformations.
- Doc3D: A standard large-scale synthetic dataset containing 100,000 images used for further fine-tuning.
- DocUNet Benchmark: The primary evaluation set, consisting of 130 real-world distorted document images and their scanned ground truths.
Key Results
DocMAE achieved state-of-the-art (SOTA) performance on the DocUNet benchmark, outperforming previous models in both geometric accuracy and OCR utility.
Geometric Accuracy
The model achieved a Local Distortion (LD) score of 7.63, surpassing previous leading models like DewarpNet (8.39) and FCN-based methods (7.84). Qualitatively, DocMAE produces straighter text lines and more accurate rectangular boundaries, avoiding the "wavy" artifacts common in earlier architectures like PWUNet.
OCR Performance
The practical utility of the rectification was confirmed through significantly improved OCR metrics. The Edit Distance (ED) dropped to 801.52 (an improvement over FDRNet’s 829.78), and the Character Error Rate (CER) reached a low of 0.20. These results indicate that the structural priors learned during the self-supervised phase translate directly into more readable documents for automated systems.
Discussion and Future Work
DocMAE demonstrates that self-supervised pre-training is a powerful tool for capturing the redundant structural information inherent in documents. By treating text lines as implicit geometric priors, the model learns to "unfold" documents with high precision.
Despite its success, some limitations remain. The current framework focuses primarily on geometric rectification and does not explicitly model complex illumination artifacts like shadows or glare. Additionally, while the model performs well on real-world data, it is still primarily trained on synthetic datasets. Future research may explore self-supervision directly on massive, unlabeled "in-the-wild" document photos to further bridge the synthetic-to-real gap. Finally, as a Transformer-based model, optimizing computational efficiency remains an area for ongoing development.
Summary updated