Abstract
Depth-from-Defocus (DFD) is a classic computer vision task that leverages defocus blur as a depth cue. However, training deep learning models for DFD typically requires large-scale datasets with ground-truth depth or all-in-focus (AIF) images, both of which are difficult to acquire in real-world settings. We present a fully self-supervised framework that overcomes these limitations. Our approach, DAIF-Net, predicts depth and AIF images from a focal stack and validates these predictions through a differentiable, physics-based optical model. By minimizing the reconstruction error between the original and re-rendered focal stacks, the model learns to estimate depth without any external supervision.
Introduction
Estimating the 3D structure of a scene from 2D images is fundamental to robotics and augmented reality. Defocus blur provides a powerful monocular depth cue: as objects move away from the camera's focal plane, they become increasingly blurred. Traditional DFD methods often rely on supervised learning, which is bottlenecked by the scarcity of high-quality depth ground truth. While some self-supervised methods use AIF images as a proxy, capturing true AIF images requires small apertures that introduce noise and diffraction. This paper introduces a framework that treats both depth and AIF images as unknowns, solving for them simultaneously through a self-supervised feedback loop.
Methodology
The proposed framework consists of two primary components: the DAIF-Net architecture and a Differentiable Optical Model.
DAIF-Net utilizes a shared encoder to process a "sparse focal stack"—a set of images captured at different focus distances. A global max-pooling mechanism identifies the sharpest features across the stack, allowing the network to handle an arbitrary number of input images. The network outputs a predicted depth map and a predicted AIF image.
The self-supervision is driven by a physics-based optical model derived from the thin-lens equation. This model takes the predicted depth and AIF image to "re-render" the input focal stack. Because the optical model is deterministic and differentiable, the entire system can be trained end-to-end using a reconstruction loss ($L_{recon}$) that compares the rendered stack to the original input. This "physics-as-a-teacher" approach ensures the network learns representations that are physically meaningful rather than just statistically convenient.
Experimental Results
The model was evaluated on synthetic (DefocusNet, NYUv2) and real-world (Mobile Depth) datasets. On the NYUv2 dataset, the self-supervised approach achieved a $\delta1$ accuracy of 0.950, nearly matching the performance of state-of-the-art supervised models (0.967).
Qualitative evaluations on real-world data from the Mobile Depth dataset demonstrate the model's robustness. Unlike optimization-based methods that often produce noisy depth maps, our framework generates smooth, edge-aware depth estimates and high-quality AIF reconstructions even in the presence of complex real-world blur. The model successfully generalizes to different camera parameters, such as focal length and f-number, without requiring specific fine-tuning for each hardware configuration.
Conclusion
By grounding neural network predictions in the laws of optics, we have developed a robust, self-supervised framework for depth estimation. The use of a differentiable thin-lens model eliminates the need for ground-truth data, making DFD more accessible for real-world applications. While the model still faces challenges in textureless regions where blur patterns are difficult to discern, it represents a significant step toward practical, unsupervised depth sensing from standard camera hardware.
Summary updated