Abstract
Not everybody can be equipped with professional photography skills and sufficient shooting time, and there can be some tilts in the captured images occasionally. In this paper, we propose a new and practical task, named Rotation Correction, to automatically correct the tilt with high content fidelity in the condition that the rotated angle is unknown. This task can be easily integrated into image editing applications, allowing users to correct the rotated images without any manual operations. To this end, we leverage a neural network to predict the optical flows that can warp the tilted images to be perceptually horizontal. Nevertheless, the pixel-wise optical flow estimation from a single image is severely unstable, especially in large-angle tilted images. To enhance its robustness, we propose a simple but effective prediction strategy to form a robust elastic warp. Particularly, we first regress the mesh deformation that can be transformed into robust initial optical flows. Then we estimate residual optical flows to facilitate our network the flexibility of pixel-wise deformation, further correcting the details of the tilted images. To establish an evaluation benchmark and train the learning framework, a comprehensive rotation correction dataset is presented with a large diversity in scenes and rotated angles. Extensive experiments demonstrate that even in the absence of the angle prior, our algorithm can outperform other state-of-the-art solutions requiring this prior.
Introduction
Capturing a perfectly level photo is a common challenge for amateur photographers. Traditional solutions for correcting a crooked horizon involve a rigid rotation, which inevitably creates empty triangular gaps at the corners. To resolve these, users must either crop the image—losing valuable content—or use image completion techniques that may introduce artificial artifacts.
Existing "content-aware" solutions attempt to warp the image into a rectangular frame while leveling the content. However, these methods typically suffer from two major drawbacks: they require the exact rotation angle as an input prior, and they often rely on detecting straight lines, making them brittle in natural scenes like forests or cloudscapes. This paper introduces a "no-angle-prior" solution that automatically corrects tilted images in a single step while preserving 100% of the original content.
Methodology: Robust Elastic Warp
Predicting pixel-wise optical flow from a single image is inherently unstable for large tilts. To address this, the proposed framework employs a progressive prediction strategy:
- Mesh Prediction: The network first predicts the deformation of a coarse $8 \times 6$ mesh. This low-resolution approach provides a stable foundation for the overall rotation.
- Mesh-to-Flow Conversion: The mesh movement is interpolated into an initial, smooth optical flow field.
- Residual Flow Prediction: A secondary encoder-decoder network predicts fine-grained, pixel-level adjustments. This "residual flow" adds the necessary elasticity to correct local details missed by the coarse mesh.
The model is optimized using Perceptual Loss to focus on semantic shapes and a Symmetry-Equivariant Term to ensure consistent results regardless of image orientation (e.g., horizontal flips).
The Deep Rotation Correction Dataset (DRC-D)
To facilitate training and evaluation, the authors curated the DRC-D dataset. They sourced thousands of high-quality horizontal images from ImageNet and synthesized tilted versions using random rotations (±10°) and state-of-the-art warping. The dataset underwent three rounds of manual filtering, with 20% of the ground truth labels manually fine-tuned to ensure perfect horizontal alignment. The final dataset comprises 5,537 training and 665 testing samples.
Results and Discussion
The proposed method demonstrates significant improvements over state-of-the-art (SOTA) techniques in both quantitative and qualitative metrics.
- Perceptual Quality: The model achieved a Frechet Inception Distance (FID) of 7.12, outperforming the previous best of 8.51. It also ranked first in no-reference quality tests (BRISQUE and PIQUE).
- Efficiency: Processing a high-resolution image takes approximately 0.2 seconds on a standard GPU, making it suitable for real-time mobile applications.
- Content Fidelity: Unlike cropping, this method retains all original pixels. Feature visualization reveals that the encoder naturally learns to identify tilted semantic regions, applying stronger "pushes" to features like tower tops to achieve leveling.
Conclusion
This work presents a robust, single-step solution for automatic rotation correction without requiring an angle prior. By combining stable mesh deformation with flexible optical flow, the model achieves high content fidelity and perceptual accuracy. While currently limited to tilts within 10 degrees and dependent on recognizable semantic features, future work aims to incorporate more complex geometric priors and explore weakly-supervised learning to expand the system's versatility.
Summary updated