Aberration-Aware Depth-from-Focus

Xinge Yang, Qiang Fu, Mohamed Elhoseiny, Wolfgang Heidrich · OpenReview

Abstract

Computer vision methods for depth estimation usually use simple camera models with idealized optics. For modern machine learning approaches, this creates an issue when attempting to train deep networks with simulated data, especially for focus-sensitive tasks like Depth-from-Focus. In this work, we investigate the domain gap caused by off-axis aberrations that will affect the decision of the best-focused frame in a focal stack. We then explore bridging this domain gap through aberration-aware training (AAT). Our approach involves a lightweight network that models lens aberrations at different positions and focus distances, which is then integrated into the conventional network training pipeline. We evaluate the generality of pretrained models on both synthetic and real-world data. Our experimental results demonstrate that the proposed AAT scheme can improve depth estimation accuracy without fine-tuning the model or modifying the network architecture.

Introduction

Depth-from-Focus (DfF) is a technique that estimates the distance of objects by analyzing a "focal stack"—a series of images of the same scene taken at different focus distances. The core assumption is that the frame where a pixel is sharpest corresponds to its true depth. However, there is a significant domain gap between theory and reality. Most deep-learning models for DfF are trained on synthetic data generated using an idealized "thin lens" or pinhole model.

In reality, physical lenses suffer from optical aberrations like field curvature (where the plane of focus is curved rather than flat), coma, and astigmatism. These aberrations cause spatially-varying, asymmetric blurs that confuse models trained only on perfect, symmetric defocus patterns. Consequently, models often require painstaking fine-tuning for specific camera hardware to perform reliably in the field.

Methodology: Aberration-Aware Training (AAT)

The authors propose a two-stage approach to make DfF networks "aberration-aware" by integrating a realistic lens model directly into the training loop.

Overview of the Aberration-Aware Training (AAT) pipeline.

The PSF Network and Simulator

Instead of relying on computationally expensive ray-tracing during training, the authors train a lightweight Multilayer Perceptron (MLP) to represent the Point Spread Function (PSF) of a specific lens. This network acts as a differentiable lookup table, taking pixel position $(x, y)$, object depth $(z)$, and focus distance $(f_d)$ as input to predict the 2D blur kernel for that specific point.

During training, this PSF network is used to "re-render" all-in-focus images into realistic, aberrated focal stacks. Because the PSF varies across the image due to off-axis aberrations, the system performs local convolution for every pixel. This allows the depth-estimation network (such as AiFNet or DFVNet) to learn the specific "signature" of a lens's imperfections, effectively learning to "see through" the aberrations to find the true best-focused frame.

Experimental Results

The AAT scheme was evaluated using synthetic data from FlyingThings3D and Matterport3D, as well as real-world captures using a Canon EOS RF 50mm F/1.8 lens. For real-world indoor scenes, ground truth depth was captured using an iPhone 14 Pro's LiDAR sensor aligned with the camera's view.

Quantitative and Qualitative Gains

On simulated focal stacks, the AAT-trained AiFNet achieved a Mean Absolute Error (MAE) of 0.2095, a dramatic improvement over the 0.4706 MAE of the baseline model trained on idealized optics. On real-world indoor scenes, the AAT model maintained superior performance (MAE 0.1526 vs. 0.1775) and a significantly higher accuracy threshold.

Qualitative comparison of depth estimation results across different models and scenes.

Visually, AAT models produce much sharper depth boundaries and are better at suppressing artifacts. A striking finding is that non-AAT models often mistake high-frequency color textures for depth cues when aberrations are present; AAT models are much more robust, focusing on the actual geometry of the scene. This is particularly evident at the edges of images where field curvature typically causes the most distortion.

Conclusion

This research demonstrates that bridging the optical domain gap through Aberration-Aware Training significantly boosts the real-world accuracy of Depth-from-Focus models. By using a lightweight MLP to model complex lens PSFs, the approach remains computationally efficient while providing the depth network with the necessary context to handle physical lens imperfections. While currently lens-specific, this philosophy is architecture-agnostic and could be extended to other focus-sensitive tasks such as all-in-focus image synthesis or high-aperture object detection.

Summary updated

BibTeX
@article{yang2023aberration,
  author = {Xinge Yang and Qiang Fu and Mohamed Elhoseiny and Wolfgang Heidrich},
  title = {{Aberration-Aware Depth-from-Focus}},
  journal = {IEEE Transactions on Pattern Analysis and Machine Intelligence},
  year = {2023},
  doi = {10.1109/tpami.2023.3301931},
}
Figure