NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

DiffCamera: Arbitrary Refocusing on Images

Yiyang Wang, Xi Chen, Xiaogang Xu, Yu Liu, Hengshuang Zhao

TL;DR

This paper introduces DiffCamera, a diffusion-transformer model that allows users to arbitrarily change the focus point and blur level of an existing image. By leveraging a novel stacking constraint and a depth dropout mechanism, DiffCamera achieves high-quality, consistent refocusing results, even with imperfect depth information.

What Problem Does This Paper Address?

Depth-of-field (DoF) effects, like bokeh, are crucial for photographic aesthetics, guiding the viewer's eye and enhancing image quality. However, the DoF is fixed once an image is captured, making it difficult to modify. This is problematic when the original DoF is undesirable (e.g., the subject is out of focus) or when generating images with AI, where precise control over focus and blur is challenging to achieve through text prompts alone. Existing methods either require specialized hardware, struggle with single images, or lack fine-grained control over focus and blur.

Methods

DiffCamera employs a diffusion transformer architecture to learn refocusing. The core innovation lies in its training methodology:

  • Simulated DoF Pairs: To overcome the scarcity of real-world data with varying focus and blur, the authors create a large-scale dataset by simulating bokeh effects on all-in-focus images using the BokehMe simulator and depth maps predicted by Depth Anything V2.
  • Stacking Constraint: A novel regularization term, inspired by the photographic technique of focus stacking, is introduced. This constraint enforces that refocused images from different focus planes can be linearly blended into a multi-focus image, ensuring physically grounded refocusing behavior and consistency.
  • Depth Dropout: To mitigate the model's over-reliance on potentially inaccurate depth maps, a depth dropout mechanism is used during training. This randomly drops depth map information, forcing the model to learn refocusing independently of precise depth, thus improving robustness.
  • Diffusion Transformer Backbone: The model utilizes a diffusion transformer architecture, with image and camera conditions encoded into tokens for processing.

Datasets

  • Training Data: The authors generated a dataset of simulated bokeh image pairs from all-in-focus images. This dataset includes real-world photographs, phone-captured images, and AI-generated images.
  • Evaluation Benchmark: A new benchmark of 150 scenes is introduced, comprising 60 camera-captured photos, 30 phone-captured photos, and 60 AI-generated images. For each scene, multiple refocus, bokeh, and deblur samples are generated.

Key Insights and Ideas

  • Focus Stacking as a Training Signal: The insight that refocused images from different planes should be linearly blendable into a multi-focus image provides a powerful, physically grounded constraint for training. This goes beyond simple pixel-wise loss and enforces a deeper understanding of DoF.
  • Depth Dropout for Robustness: The realization that models can become overly dependent on depth maps, which are often imperfect, led to the depth dropout mechanism. This simple yet effective technique significantly improves robustness to depth inaccuracies.
  • Diffusion Transformers for Refocusing: Applying diffusion transformers, known for their generative capabilities, to the task of image editing like refocusing proves highly effective, allowing for complex scene manipulation.

Key Results

  • Quantitative Performance: DiffCamera achieves state-of-the-art results across various sub-tasks, including refocusing, adding bokeh, and removing bokeh. For instance, it achieves a CLIP-I score of 0.954 for refocusing, significantly outperforming GPT-40 (0.859). For adding bokeh, it achieves an LVCorr of 0.834, also surpassing GPT-40 (0.724).
  • Qualitative Results: Visualizations demonstrate DiffCamera's ability to produce sharp, consistent, and aesthetically pleasing refocused images with arbitrary focus points and blur levels, even on challenging real-world photos. The stacking constraint is shown to prevent incorrect DoF behaviors observed in its absence. Depth dropout also demonstrates improved robustness to inaccurate depth maps.

Limitations and Future Work

  • Resolution and Aspect Ratio: DiffCamera is currently limited to processing images at resolutions of 512x512 or 1024x1024, and struggles with different aspect ratios. Future work could involve scaling up training for higher resolutions and diverse aspect ratios.
  • Ill-Posed Problem of Deblurring: Generating sharp content from heavily blurred images is inherently ill-posed. While DiffCamera produces reasonable results, they may not perfectly match user expectations or avoid artifacts in complex cases. Future work could involve using reference images or more powerful backbones.
  • Finer Bokeh Control: The current model allows control over bokeh level and focus point but not finer aspects like bokeh shape. The authors suggest integrating this by generating data with various bokeh shapes and encoding shape information as a condition.

Summary updated

BibTeX
@inproceedings{wang2025diffcamera,
  author = {Yiyang Wang and Xi Chen and Xiaogang Xu and Yu Liu and Hengshuang Zhao},
  title = {{DiffCamera: Arbitrary Refocusing on Images}},
  booktitle = {SIGGRAPH Asia},
  year = {2025},
}
Figure