BokehDiff: Neural Lens Blur with One-Step Diffusion

Chengxuan Zhu, Qingnan Fan, Qi Zhang, Jinwei Chen, Huaqi Zhang, Chao Xu, Boxin Shi · DOI

Abstract

Digital bokeh synthesis remains a significant challenge in computational photography, particularly when dealing with complex object boundaries and imperfect depth maps. This paper presents BokehDiff, a novel framework that leverages the generative power of Latent Diffusion Models (LDMs) for high-fidelity lens blur rendering. By introducing a one-step diffusion inference scheme and a Physics-Inspired Self-Attention (PISA) module, BokehDiff achieves photorealistic results that respect optical laws while remaining robust to depth estimation errors. Experimental results demonstrate that BokehDiff outperforms existing state-of-the-art methods in both quantitative metrics and human perception studies.

Introduction

In photography, "bokeh" refers to the aesthetic quality of the blur produced in out-of-focus parts of an image. Recreating this effect digitally typically requires an accurate depth map to determine the appropriate blur radius for each pixel. However, precise depth estimation is notoriously difficult, especially around intricate structures such as hair, fur, or whiskers.

Existing approaches generally fall into two categories: classical renderers, which are physically grounded but sensitive to depth inaccuracies, and neural renderers, which produce realistic textures but often lack physical consistency. While modern diffusion models excel at generating blurry backgrounds, their iterative nature and tendency to "hallucinate" new content make them difficult to use for precise image-to-image rendering tasks. BokehDiff addresses these issues by adapting a pretrained Stable Diffusion XL (SDXL) backbone into a deterministic, physics-constrained rendering engine.

Methodology

BokehDiff introduces several key innovations to transform a generative diffusion model into a robust rendering tool.

One-Step Diffusion Mapping

To maintain the structural integrity of the input image and avoid the computational cost of iterative sampling, BokehDiff employs a one-step inference scheme. Instead of starting from pure Gaussian noise, the model treats the all-in-focus input image ($I_f$) as a "noisy" representation of the target bokeh image ($I_b$). By fixing the diffusion timestep (e.g., $T=499$) and performing a single denoising step, the model harnesses its internal knowledge of blur textures to transform pixels rather than generating them from scratch. This approach eliminates the stochastic randomness that typically leads to content hallucinations.

Physics-Inspired Self-Attention (PISA)

Standard self-attention mechanisms in LDMs are global, allowing any pixel to influence any other regardless of physical distance or depth. BokehDiff replaces these with the PISA module, which enforces three optical constraints:

  1. Energy Conservation: Ensures that the total light energy is preserved as it spreads across the Circle of Confusion (CoC).
  2. CoC Constraints: Mathematically limits a pixel's influence to its specific blur radius based on the provided depth/defocus map.
  3. Self-Occlusion Masking: Prevents background light from incorrectly "bleeding" through foreground objects, a common artifact in digital bokeh.
Overview of the BokehDiff architecture featuring the one-step diffusion process and the PISA module.

LoRA Finetuning

The framework utilizes Low-Rank Adaptation (LoRA) to finetune the SDXL U-Net. This allows the model to retain the high-quality priors of the large-scale pretrained model while specializing its weights for the specific task of lens blur synthesis.

Datasets and Training

The authors trained and evaluated BokehDiff using a combination of real-world and synthetic datasets:

  • EBB Val294: A real-world dataset featuring paired wide and shallow depth-of-field images.
  • BLB (Level 5): A synthetic benchmark rendered using Blender.
  • SYNBOKEH300: A new benchmark introduced by the authors. To overcome the scarcity of high-quality training data for complex edges, they used a text-to-image model to generate photorealistic foregrounds with transparency (e.g., intricate hair). These were ray-traced onto real backgrounds to create a diverse, perfectly aligned dataset.

Results and Discussion

BokehDiff achieves state-of-the-art performance across multiple benchmarks. On the EBB dataset, it reached a PSNR of 24.652 and an LPIPS of 0.3737, indicating superior perceptual similarity to ground-truth photographs compared to methods like BokehMe, MPIB, and Dr. Bokeh.

Qualitative comparison of BokehDiff against state-of-the-art methods on challenging hair and whisker details.

Robustness to Depth Errors

A critical advantage of BokehDiff is its resilience to imperfect depth maps. In stress tests where depth maps were intentionally distorted (eroded or dilated), BokehDiff maintained significantly higher image quality than its competitors. This robustness stems from the model's ability to use its generative priors to "fill in" or correct areas where the depth guidance is ambiguous.

User Evaluation

In a blind study involving 50 volunteers, BokehDiff was consistently ranked as the most authentic and accurate method, receiving an overall preference score of 4.56/5.0.

Conclusion

BokehDiff represents a significant step forward in neural lens blur rendering. By combining the strengths of diffusion models with physical optical constraints, it provides a fast, robust, and photorealistic solution for digital bokeh. Future work will focus on addressing VAE-induced texture artifacts and extending the framework to maintain temporal consistency in video sequences.

Summary updated

BibTeX
@inproceedings{zhu2025bokehdiff,
  author = {Chengxuan Zhu and Qingnan Fan and Qi Zhang and Jinwei Chen and Huaqi Zhang and Chao Xu and Boxin Shi},
  title = {{BokehDiff: Neural Lens Blur with One-Step Diffusion}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2025},
}
Figure