Revisiting Document Image Dewarping by Grid Regularization

Xiangwei Jiang, Rujiao Long, Nan Xue, Zhibo Yang, Cong Yao, Gui-Song XiaCVPR 2022

Abstract

Document image dewarping is essential for high-quality document digitization, yet current deep learning approaches often prioritize visual "flatness" over actual readability. This paper introduces a novel approach that moves away from pure black-box neural networks. Instead, we use deep learning to extract geometric priors—specifically text lines and document boundaries—and incorporate them into a constrained optimization framework. By enforcing that text lines remain horizontal and boundaries remain straight through a novel grid regularization scheme, our method significantly improves OCR performance. Experimental results on the DocUNet benchmark show that our approach outperforms existing state-of-the-art methods in both Character Error Rate (CER) and image quality.

Introduction

Capturing documents with mobile cameras often introduces geometric distortions due to page curvature and folds. While modern dewarping models like DocUNet and DewarpNet have made strides in rectifying these images, they frequently introduce local artifacts or "wavy" text lines. These subtle distortions, though sometimes visually acceptable to humans, significantly degrade the performance of Optical Character Recognition (OCR) systems. The fundamental issue is that these models often lack an explicit understanding of the document's underlying geometry, relying instead on predicted pixel-wise flow fields.

Methodology: A Hybrid Optimization Framework

To bridge the gap between visual quality and readability, we propose a framework that combines the perceptual power of deep learning with the structural precision of classical optimization.

1. Geometric Element Detection

The process begins by identifying the document's structural "skeleton." We employ two neural networks: one to detect the four page boundaries and another (a semantic segmentation UNet) to identify individual text lines. To handle cases where text does not span the entire page width, we implement a specific algorithm to estimate the vertical start and end points of text blocks, ensuring a complete geometric representation.

2. Grid Regularization and Energy Minimization

Instead of directly regressing the dewarped image, we define a 2D deformation grid. We formulate the dewarping task as an energy minimization problem. The "best" grid is one that satisfies three primary constraints:

  • Boundary Matching: The grid edges must align with the detected document boundaries.
  • Text Line Alignment: Text lines must be transformed to be perfectly horizontal in the output.
  • Grid Regularization: The grid itself must maintain a smooth, uniform structure to prevent local warping.
Visualization of the grid regularization scheme applied to a warped document.

The optimization problem is solved using the Alternating Direction Method of Multipliers (ADMM). This ensures that the resulting forward mapping is mathematically consistent and geometrically sound, effectively eliminating the "waviness" common in end-to-end models.

Experimental Results

We evaluated our method on the DocUNet Benchmark, a standard dataset of 130 real-world distorted document images. Our training utilized the Doc3D dataset for boundary detection and PubLayNet for text-line segmentation.

Readability and OCR Performance

The primary metric for our evaluation was readability. On a subset of 50 images with manual text labels, our method achieved a Character Error Rate (CER) of 0.2068, a substantial improvement over previous state-of-the-art models like DewarpNet (~0.30). Similarly, the Edit Distance (ED) was reduced by approximately 30%.

Qualitative comparison of dewarping results across different methods.

Structural Similarity

Beyond OCR, our method also achieved the highest Multi-Scale Structural Similarity (MS-SSIM) score of 0.4922. This indicates that the overall global structure of the dewarped document is more faithful to the original flat version than results produced by competing methods.

Conclusion

By revisiting document dewarping through the lens of grid regularization, we demonstrate that explicit geometric priors are more effective for document digitization than pure end-to-end learning. While our optimization-based approach is computationally more intensive than a single neural network pass, the gains in OCR accuracy and structural integrity are significant. Future work will focus on making the system end-to-end trainable by learning the energy term weights automatically, further improving both speed and robustness.

Summary updated

BibTeX
@inproceedings{jiang2022revisiting,
  author = {Xiangwei Jiang and Rujiao Long and Nan Xue and Zhibo Yang and Cong Yao and Gui-Song Xia},
  title = {{Revisiting Document Image Dewarping by Grid Regularization}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2022},
  url = {https://openreview.net/forum?id=1FVQ9ob3I0A},
}
Figure