Document Image Rectification Bases on Self-Adaptive Multitask Fusion

Heng Li, Xiangping Wu, Qingcai ChenarXiv 2025

TL;DR

Smartphone-captured document images often suffer from geometric warping and folding, which severely degrades downstream OCR performance. This paper introduces SalmRec, a multi-task learning network that adaptively aggregates and gates global (3D shapes/UV maps) and local (horizontal/vertical text lines) geometric features. By intelligently managing task interactions rather than blindly concatenating them, SalmRec achieves state-of-the-art document flattening and significantly boosts text recognition accuracy.

What Problem Does This Paper Address?

When you snap a photo of a document with your phone, it is rarely perfectly flat. Folds, page curves, shadows, and awkward camera angles distort the text, making it highly challenging for Optical Character Recognition (OCR) systems to extract data accurately.

To fix this, recent deep learning methods have shifted toward multi-task learning—predicting auxiliary geometric information like 3D coordinates, background masks, or text lines to help guide the unwarping (rectification) process. However, current methods treat these auxiliary tasks independently or simply concatenate their features at the end. This naive approach ignores how different tasks can complement each other, and worse, it can introduce negative interference where conflicting task representations degrade the final output.

Methods

The authors present SalmRec (Self-Adaptive Learnable Multitask Fusion Rectification Network), which models the document flattening process through a highly coordinated multi-task pipeline:

Figure 1: Overview architecture of our proposed SalmRec. For a given distorted image, SalmRec learns to predict a 2D deformation field by multi-decoder segmentation module (𝐷𝑖), inter-task feature aggregation (𝐹𝐴), gating mechanisms (𝐺𝑖), and Transformer decoder. 𝑭represents the output feature map.
  1. Multi-decoder Segmentation: A shared UNet-based encoder (enhanced with self-attention layers to capture long-distance dependencies) feeds into four independent decoders. These decoders predict two global properties (3D coordinates and UV maps) and two local properties (horizontal and vertical text lines).
  2. Inter-task Feature Aggregation (FA) Module: To prevent tasks from clashing, the FA module uses a "leave-one-out" global attention strategy. For example, to refine the 3D coordinate features, the module computes an attention score from the other three tasks (UV maps, horizontal, and vertical lines) to filter out redundant noise and highlight complementary geometric cues.
  3. Gating Module: Inspired by routing mechanisms in multi-task learning, separate gating modules dynamically weight global and local features based on the universal features extracted by the encoder, ensuring the network selects the most reliable features for the final transformation.
  4. Transformer Decoder & Grid Sampling: The refined, gated features are concatenated and passed to a Transformer decoder to predict a 2D deformation field, which maps pixels from the distorted image back onto a flat plane.
Figure 2: Inter-task Feature Aggregation (FA) Module. The four tasks are divided into four groups, where 𝑭3𝐷is fused with the global attention score obtained from the other three tasks for feature interconnection aggregation.

Datasets

  • Training: The model is trained on DocDewarpHV, a synthetic dataset containing 110,000 distorted document images complete with precise ground-truth annotations for 3D coordinates, UV maps, and horizontal/vertical text lines.
  • Evaluation Benchmarks:
  • DIR300: A diverse English benchmark of 300 images captured in natural scenes with complex lighting, folds, and background interferences.
  • DocUNet: The standard benchmark in this field, consisting of 130 real-world distorted document images.
  • DocReal: A large Chinese benchmark containing 200 real-life document images (contracts, receipts, textbooks) captured in the wild.

Key Insights and Ideas

  • More Tasks $\neq$ Better Results (Without Smart Fusion): A key "aha moment" in the paper's ablation studies revealed that simply adding more auxiliary tasks can actually hurt performance. For instance, combining 3D coordinates and UV maps without the FA module caused OCR accuracy to drop significantly. Tasks can actively interfere with one another if not properly fused.
  • The Power of Leave-One-Out Attention: By using three tasks to contextualize and clean the fourth, the FA module successfully minimizes cross-task interference while maximizing feature complementarity.
  • Directional Constraints Matter: Splitting text line detection into explicit horizontal and vertical components provides rigid directional constraints. This mimics how humans scan a page and helps the model better map local page geometry than a single, undifferentiated text mask.

Key Results

SalmRec achieves state-of-the-art (SOTA) performance across all three benchmarks, balancing both global structural similarity and local text readability.

  • DIR300 Benchmark: SalmRec achieves a SOTA Multi-Scale Structural Similarity (MS-SSIM) of 0.67 and reduces Local Distortion (LD) to 5.14. Crucially, it drops the Character Error Rate (CER) from a distorted baseline of 0.5234 down to 0.1400.
  • DocReal Benchmark: On this challenging Chinese dataset, SalmRec leads with an MS-SSIM of 0.59 and an LD of 8.41, proving its robustness against complex real-world layouts and background clutter.
Figure 4: Qualitative visual comparison with existing methods on DIR300 benchmark [17]. The first column “Distorted” means the given distorted document image, and the last column “Ground-Truth” is the flattened reference image.

Limitations and Future Work

Despite its strong performance, SalmRec still faces a few limitations:

  • Extreme Folds: It struggles to perfectly reconstruct text that is physically blocked or completely collapsed inside deep, sharp folds.
  • Complex Background Interference: If a document is placed on a background with a dense grid pattern, or if the background color is nearly identical to the paper edge, the model can occasionally fail to cleanly segment the document boundaries.

The authors note that future work will focus on exploring more lightweight yet robust architectures capable of handling these highly complex background interferences.

Summary updated

BibTeX
@misc{li2025document,
  author = {Heng Li and Xiangping Wu and Qingcai Chen},
  title = {{Document Image Rectification Bases on Self-Adaptive Multitask Fusion}},
  year = {2025},
  eprint = {2505.06038},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2505.06038},
}
Figure