---
title: Marigold-Based Defocus Blur Depth Estimation
url: https://www.emergentmind.com/topics/marigold-based-defocus-blur-approach
type: topic
---

# Marigold-Based Defocus Blur Depth Estimation

The Marigold-based Defocus Blur Approach is a zero-shot, training-free method for metric monocular depth estimation that augments a pre-trained diffusion model, Marigold, with defocus blur cues at inference time. By leveraging the optical physics of depth-dependent defocus and a differentiable blur forward model, this approach enables inference-time optimization for absolute depth, outperforming state-of-the-art monocular metric depth estimation (MMDE) systems in generalization to out-of-distribution scenes [2505.17358].

## 1. Defocus Blur Image-Formation Physics

The method operationalizes the thin-lens model, quantifying defocus using the Circle-of-Confusion (CoC), which models the diameter of the blur disk for a point at distance $d$:
$$
c(d) = \frac{f^2}{N} \frac{|d-F|}{d(F-f)s}
$$
where $f$ is focal length, $F$ is focus distance, $N$ is F-stop, and $s$ is the pixel size. The point-spread function (PSF) for defocus is parameterized as a spatially varying disc with linear rim fall-off, allowing differentiable rendering of the blurred image:
$$
x_{\mathrm{blur}}(i,j) = \iint x_{\text{AIF}}(u,v)\, h(i-u,j-v \mid \mathbf d^{\mathrm m}[u,v])\, du\, dv
$$
where $x_\text{AIF}$ is the all-in-focus radiance, $\mathbf d^{\mathrm m}$ is the metric depth map, and $h$ is the normalized disc-PSF at each location.

## 2. Dual-Aperture Image Acquisition and Preprocessing

Inference requires acquisition of two raw images from a fixed viewpoint with known optical parameters:
- A high-aperture ($N_\text{AIF}=22$) all-in-focus image ($x_{\text{AIF}}$)
- A lower-aperture ($N_\text{blur}<22$) defocused blurred image ($x_{\text{blur}}$)

An exposure compensation factor ensures energy constancy between images:
$$
x_{\mathrm{blur}} \leftarrow x_{\mathrm{blur}} \cdot \frac{t_\text{AIF}}{t_\text{blur}} \, \frac{N_\text{blur}^2}{N_\text{AIF}^2}
$$
where $t$ denotes exposure times. This preprocessing aligns the linear radiance scales of both images, necessary for accurate forward modeling.

## 3. Inference-Time Optimization Framework

The pipeline formulates metric depth estimation as a constrained optimization task over latent variables:
- Marigold-LCM denoiser $\hat x_{\phi}$ operates on a noise latent $z$ and AIF-encoded latent $z^{(x)}$, producing a depth latent $z_0^{(d)}$.
- The decoded depth $\mathbf d\in[0,1]$ is affinely mapped to metric depth:
$$
\mathbf d^{\mathrm m}[u,v] = \alpha\, \mathbf d[u,v] + \beta
$$
with affine scale $\alpha = s_{\max}\,\sigma(a)$ and offset $\beta=s_{\min}\,\sigma(b)$ determined through unconstrained optimization variables $a$, $b$, and scene bounds $s_{\min}$, $s_{\max}$.

The loss function penalizes the $\ell_2$ norm between the captured blurred image and the model-predicted blur given the current metric depth, all-in-focus image, and camera parameters:
$$
\mathcal{L}(a,b,z) = \left\| x_{\mathrm{blur}} - g(x_{\text{AIF}},\, y(a,b,z); f,F,N_\text{blur}) \right\|_2^2
$$
Optimization proceeds over $(a,b,z)$ subject to the norm constraint $\|z\|_2=\sqrt{M}$, consistent with the sampling from standard normal for $M$-dimensional latents.

## 4. Integration into the Marigold Pipeline

The inference-time algorithm is initialized by sampling $z^{(0)} \sim \mathcal N(0,I)$ with $a^{(0)}=b^{(0)}=0$ (implying $\alpha=\beta=s_{\max}/2$). For $T=200$ iterations:
1. Compute $z_0^{(d)} = \hat x_\phi(z^{(t-1)},z^{(x)})$
2. Decode $\mathbf d = \mathcal D(z_0^{(d)})$
3. Affinely convert to metric depth
4. Forward-blur image synthesis $x_{\text{blur,pred}}$
5. Evaluate loss and gradients
6. Update $(z,a,b)$ using Adam or SGD
7. Renormalize $z$ to maintain $\|z^{(t)}\|_2 = \sqrt{M}$

Convergence is by fixed iteration count or saturation of $\mathcal L$. All modules (Marigold-LCM inference, depth decoding, metric mapping, forward blur) are differentiable, enabling unified backpropagation.

## 5. Approximations and Regularization

The blur forward model utilizes a disc-PSF with linear rim fall-off, eschewing full diffraction simulation for computational efficiency. Single-step latent-consistency sampling is used for Marigold-LCM in place of typical diffusion with 20–50 steps. Sigmoid parameterization for mapping ensures well-behaved depth scales. Latent renormalization enforces a "Gaussian-annulus" prior, with known scene bounds $[s_{\min},s_{\max}]$ constraining metric depth range.

## 6. Experimental Evaluation and Results

Experiments are conducted on a custom real dataset acquired with a Canon 5D Mark II (50mm lens) and Intel RealSense D435 for depth ground truth, capturing seven indoor scenes across various F-stops (AIF at $f/22$, blur at $f/8$). Focus is fixed at 0.8m; RealSense provides depth in [0.3, 3.8] m. Standard metrics—RMSE, AbsRel, log10 error, and accuracy thresholds $\delta_n$—are employed [bhat2023zoedepth].

Comparison with zero-shot MMDE baselines (MLPro, UniDepth, Metric3D) demonstrates strong performance:

| Method      | RMSE (m) | Rel   | log10 | $\delta_1$ |
|-------------|----------|-------|-------|------------|
| Marigold+Disc-PSF | 0.273    | 0.125 | 0.052 | 0.879      |
| MLPro       | 0.468    | 0.246 | 0.105 | 0.597      |
| UniDepth    | 0.644    | 0.376 | 0.157 | 0.259      |
| Metric3D    | 0.459    | 0.295 | 0.106 | 0.650      |
| Gaussian-PSF ablation | 0.528 | —     | —     | —          |

Ablation studies indicate:
- Fixing the latent $z$ and optimizing only affine parameters yields degraded RMSE (0.297)
- The $f/8$ blur achieves best results; too little or too much blur is suboptimal
- Method displays low sensitivity to initialization (std. dev. $<$ 0.02)
- Single Marigold-LCM step is sufficient; additional steps yield marginal gains

Synthetic plane tests ("Texture-Plane" toy) verify that the approach robustly recovers flat depth in the presence of ambiguous texture seen to challenge conventional methods (RMSE $<$ 0.01).

## 7. Qualitative Outcomes and Broader Implications

Qualitative results on both synthetic and real scenes reveal accurate recovery of both relative and absolute metric scale, with sharper boundaries and correct geometric ordering where prior methods frequently fail on scale or relative depth. The integration of defocus cues at inference reliably disambiguates depth in repetitive or low-texture regions. A plausible implication is that depth-from-blur provides significant complementary signals to deep-learning-based priors when upgraded with physical-camera information.

By posing metric depth estimation as a differentiable inverse problem utilizing both the strong diffusion prior of Marigold and explicit depth-varying blur cues, the framework achieves state-of-the-art results in zero-shot depth estimation under out-of-distribution conditions [2505.17358].

Source: https://www.emergentmind.com/topics/marigold-based-defocus-blur-approach