Deep Rectangling for Image Stitching: A Learning Baseline

Lang Nie, Chunyu Lin, Kang Liao, Shuaicheng Liu, Yao Zhao · DOI

Abstract: Stitched images provide a wide field-of-view (FoV) but suffer from unpleasant irregular boundaries. To deal with this problem, existing image rectangling methods devote to searching an initial mesh and optimizing a target mesh to form the mesh deformation in two stages. Then rectangular images can be generated by warping stitched images. However, these solutions only work for images with rich linear structures, leading to noticeable distortions for portraits and landscapes with non-linear objects. In this paper, we address these issues by proposing the first deep learning solution to image rectangling. Concretely, we predefine a rigid target mesh and only estimate an initial mesh to form the mesh deformation, contributing to a compact one-stage solution. The initial mesh is predicted using a fully convolutional network with a residual progressive regression strategy. To obtain results with high content fidelity, a comprehensive objective function is proposed to simultaneously encourage the boundary rectangular, mesh shape-preserving, and content perceptually natural. Besides, we build the first image stitching rectangling dataset with a large diversity in irregular boundaries and scenes. Experiments demonstrate our superiority over traditional methods both quantitatively and qualitatively.

TL;DR

Stitched images often have messy, irregular boundaries that are usually fixed by aggressive cropping or "faking" pixels with AI inpainting. This paper introduces the first deep learning-based "rectangling" method that warps the stitched image into a perfect rectangle in a single step, preserving both straight lines and complex organic shapes like faces and landscapes far better than traditional optimization-based techniques.

What Problem Does This Paper Address?

When you stitch multiple photos together to create a panorama, the resulting image never has a clean rectangular border; it looks like a jagged collage. To get a standard rectangular photo, users typically have two choices:

  1. Cropping: This throws away a significant portion of the wide Field-of-View (FoV) you worked so hard to capture.
  2. Image Completion (Inpainting): This uses AI to "guess" what should be in the missing boundary areas. However, this can create hallucinations that aren't true to reality—a major issue for applications like autonomous driving or forensic photography.
Comparison of standard image stitching solutions: (a) input images, (b) raw stitched result, (c) cropping, (d) completion/inpainting, (e) traditional rectangling, and (f) the proposed deep learning method.

A third option is Image Rectangling, which warps the image to fill a rectangular shape. Traditional methods for this are "two-stage" processes that search for an initial mesh and then optimize a target mesh. These methods are slow and frequently fail on "non-linear" structures—meaning they might keep a building straight but will hilariously distort a person's face or a curved tree branch.

Methods

The authors propose a one-stage deep learning baseline. Unlike traditional methods that optimize two meshes, this approach predefines a rigid, rectangular target mesh and uses a neural network to predict the initial mesh required to warp the content into that target.

Key technical components include:

  • Residual Progressive Regression: Instead of predicting the entire mesh deformation in one go, the network uses a primary regressor to get a coarse shape and a residual regressor to refine the details. This "coarse-to-fine" approach makes the warping much more accurate.
  • Comprehensive Loss Function: To ensure the result looks natural, the authors use a three-part objective function:
  • Boundary Term: Forces the edges to align with the rectangle.
  • Mesh Term: Includes "intra-grid" and "inter-grid" constraints to prevent the mesh from folding over itself or distorting too sharply.
  • Content Term: Combines standard pixel-wise similarity with a Perceptual Loss (using a VGG19 backbone). This allows the model to understand semantic shapes (like faces) and keep them looking natural during the warp.

Datasets

Because no dataset existed for this specific task, the authors created the DIR-D (Deep Image Rectangling Dataset). It contains 6,358 samples with a wide variety of irregular boundaries and scenes (portraits, landscapes, architecture). They took real stitched images, applied traditional rectangling to create "labels," and then used inverse transformations to create synthetic-but-realistic training pairs, manually filtering them to ensure high-quality ground truth.

Key Insights and Ideas

  • Warping > Inpainting for Fidelity: For high-security or reality-based applications, warping existing pixels is safer than synthesizing new ones, as it preserves the actual content of the scene.
  • The Power of Semantic Perception: Traditional geometry-based rectangling fails on humans because it only looks for lines. By using a perceptual loss, the deep learning model "recognizes" objects and learns that certain distortions are visually unacceptable to humans.
  • Efficiency through One-Stage Design: By fixing the target mesh and only predicting the source, the process becomes highly parallelizable and significantly faster than iterative optimization.

Key Results

  • Quantitative Superiority: On the DIR-D dataset, the proposed method achieved an FID of 21.77, significantly better than the 38.19 achieved by the state-of-the-art traditional method (He et al.). It also nearly doubled the SSIM (Structural Similarity Index).
  • Qualitative Performance: In user studies, participants preferred the deep learning results, particularly in scenes containing people or complex textures where traditional methods created "wavy" distortions.
Traditional rectangling methods (He et al.) often introduce "wavy" distortions (indicated by red arrows) in non-linear structures, which the proposed deep learning baseline avoids.
  • Speed: The model can process a 10-megapixel image in less than 0.4 seconds on a standard GPU, making it practical for real-time photo editing suites.
  • Downstream Benefits: Rectangling improves the accuracy of object detection and semantic segmentation models, which often struggle with the "black void" areas of raw stitched images.

Limitations and Future Work

While the paper presents a robust baseline, a few areas remain for exploration. The current model uses a fixed mesh resolution (e.g., $16 \times 12$), which might not capture extremely complex distortions. Additionally, while the model fixes boundaries, it cannot correct "ghosting" or alignment errors present in the initial stitch. Future work may expand the DIR-D dataset to include more extreme wide-angle or fisheye distortions to further improve generalization.

Summary updated

BibTeX
@misc{nie2022deep,
  author = {Lang Nie and Chunyu Lin and Kang Liao and Shuaicheng Liu and Yao Zhao},
  title = {{Deep Rectangling for Image Stitching: A Learning Baseline}},
  year = {2022},
  eprint = {2203.03831},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2203.03831},
}
Figure