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 (DfF). In this work, we investigate the domain gap caused by off-axis aberrations that 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 network models on both synthetic and real-world data. The experimental results demonstrate that the proposed AAT scheme can improve depth estimation accuracy without fine-tuning the model for different datasets.
Introduction
Depth-from-Focus (DfF) is a passive depth estimation technique that utilizes a "focal stack"—a sequence of images captured at varying focus distances. By identifying the sharpest pixel across the stack, the system can determine the distance of objects in a scene. While theoretically straightforward, DfF faces significant challenges in real-world applications due to the "domain gap" between idealized simulations and physical hardware.
Standard machine learning models for DfF are typically trained on synthetic data generated using "thin lens" models. These models assume perfect optics, but physical lenses suffer from systematic off-axis aberrations, including field curvature, coma, and astigmatism. These imperfections cause the focal plane to curve and the point spread function (PSF) to vary across the sensor, leading to substantial depth errors, particularly at the image periphery. To address this, we propose Aberration-Aware Training (AAT), a method that incorporates realistic optical modeling into the training process to improve generalization.
Methodology
The proposed AAT framework bridges the gap between simulation and reality by replacing idealized blur with physically grounded lens simulations. The pipeline consists of three primary components:
1. The PSF Network
Instead of relying on simple Gaussian kernels to simulate defocus, we developed a lightweight Multilayer Perceptron (MLP) to represent the spatially-varying Point Spread Function (PSF) of a real lens. The network is trained using ground-truth data generated via ray tracing. It learns to map a point’s 3D coordinates $(x, y, z)$ and the camera's focus distance $(f_d)$ to a specific PSF kernel. This tiny MLP (0.28M parameters) provides a computationally efficient way to simulate complex optical behavior during training.
2. Aberration-Aware Training (AAT)
This PSF network is integrated directly into the training loop. During data generation, the system takes an all-in-focus image and its corresponding depth map, then applies the spatially-varying, aberrated PSFs predicted by the MLP to render a realistic focal stack. This exposes the depth-estimation network to real-world optical artifacts before it ever sees a physical camera.
3. Architecture Agnosticism
A key advantage of AAT is that it is architecture-agnostic. It improves the quality of the training data rather than requiring a more complex depth-estimation model. We validated this by applying AAT to existing state-of-the-art architectures like AiFNet and DFVNet.
Experimental Setup and Results
We evaluated our approach using a combination of large-scale synthetic datasets (FlyingThings3D, Matterport3D) and real-world benchmarks (Middlebury2014). To test zero-shot generalization, we captured 25 real-world scenes using a Canon EOS RF50mm F/1.8 lens.
PSF Modeling Accuracy
The PSF network successfully captures complex, non-Gaussian blur patterns that vary with both depth and off-axis angle. As shown in the comparison below, our network closely approximates ray-tracing ground truth, whereas standard Gaussian models fail to capture the directional stretching and asymmetry characteristic of real-world aberrations.
Depth Estimation Performance
The inclusion of AAT led to a significant quantitative boost in accuracy. On simulated focal stacks, the Mean Absolute Error (MAE) for the AiFNet model dropped from a baseline of 0.4706 to 0.2095. More importantly, the models demonstrated robust zero-shot generalization; they performed significantly better on real-world Canon lens data without any hardware-specific fine-tuning.
Qualitatively, the resulting depth maps exhibited sharper object boundaries and a marked reduction in "texture bleeding," where high-contrast image features mistakenly distort the estimated geometry. The method also improved the quality of synthesized all-in-focus images, achieving superior PSNR and SSIM scores.
Conclusion
Aberration-Aware Training effectively mitigates the domain gap in Depth-from-Focus by teaching networks to recognize and compensate for systematic lens imperfections. By modeling aberrations as predictable physical phenomena rather than random noise, we enable deep learning models to generalize to real-world hardware with minimal computational overhead. Future work will focus on incorporating chromatic aberrations and improving performance in texture-sparse scenes.
Summary updated