NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Document Image Rectification using Stable Diffusion Transformer

Pooja Kumari, Sukhendu DasWorkshops @ CVPR 2025

Abstract

Document image rectification is a critical preprocessing step for digitizing physical documents, which often suffer from geometric distortions like folds and perspective shifts. Traditional methods often struggle with global structural consistency. This paper introduces a novel approach using a Conditional Stable Diffusion Transformer Module (CSDTM). By replacing the standard UNet in diffusion models with a Vision Transformer (ViT), the framework effectively captures long-range dependencies and global context. Experimental results on benchmark datasets like DocUNet and DIR300 demonstrate state-of-the-art performance in both geometric fidelity and OCR accuracy.

Introduction

Capturing documents via mobile devices frequently introduces geometric distortions—warping from book spines, perspective skew, and lens aberrations. These artifacts significantly degrade the performance of downstream tasks such as Optical Character Recognition (OCR). While Convolutional Neural Networks (CNNs) have advanced the field, their local receptive fields often fail to maintain global alignment across the entire document. This work addresses these limitations by leveraging the global attention mechanisms of Transformers within a generative diffusion framework.

Methodology

The proposed system employs a multi-stage pipeline designed to progressively refine the document image.

Coarse Rectification and Feature Extraction

The process begins with document segmentation and boundary control point detection. A Thin Plate Spline (TPS) transformation provides an initial coarse flattening. This intermediate result is then processed through a CLIP-based encoder-decoder to extract multi-scale structural features that serve as priors for the generative stage.

Conditional Stable Diffusion Transformer Module (CSDTM)

The core of the architecture is the CSDTM, which replaces the traditional UNet denoising engine with a Transformer-based model.

The multi-stage pipeline architecture, including segmentation, TPS warping, and the CSDTM.

The CSDTM utilizes self-attention to maintain a global receptive field, ensuring that structural elements like text lines remain straight across the entire page. Cross-attention mechanisms integrate the structural priors from the coarse stage, guiding the diffusion process to ensure the output remains faithful to the original content while removing distortions.

Experimental Results

The model was evaluated against industry-standard benchmarks, including Doc3D, DocUNet, and DIR300.

Quantitative Performance

On the DocUNet benchmark, the framework achieved a Character Error Rate (CER) of 0.1439, surpassing previous state-of-the-art models like DocTr++ (0.1695). It also reached a Multi-Scale Structural Similarity (MS-SSIM) of 0.52, indicating high perceptual and geometric fidelity. Despite the complexity of the Transformer architecture, the model maintains a competitive inference speed of 9.83 FPS on high-end hardware.

Qualitative Comparison

The superiority of the Transformer-based diffusion approach is evident when compared to existing methods.

Qualitative comparison of the proposed method against baselines like DewarpNet and DocTr++.

As shown in the comparison, the proposed method produces significantly flatter results with fewer local artifacts, particularly in challenging cases involving heavy folds or complex layouts.

Conclusion

By integrating Vision Transformers into a conditional diffusion framework, this research sets a new benchmark for document image rectification. The ability to capture global structural context allows for superior flattening and improved OCR readability. Future work will focus on optimizing the computational efficiency of the Transformer modules for real-time mobile deployment.

Summary updated

BibTeX
@inproceedings{kumari2025document,
  author = {Pooja Kumari and Sukhendu Das},
  title = {{Document Image Rectification using Stable Diffusion Transformer}},
  booktitle = {Workshops @ CVPR},
  year = {2025},
}
Figure