User-Instructed Disparity-aware Defocus Control

Yudong Han, Yan Yang, Hao Yang, Liyuan PanNeurIPS 2025

Introduction

In professional photography, manipulating Depth of Field (DoF) is a powerful storytelling tool—blurring the background to make a portrait pop or using deep focus for landscapes. However, for general users with smartphones or basic DSLRs, achieving the perfect focus post-capture is notoriously difficult.

Existing software-based refocusing faces two major hurdles:

  1. Depth Estimation: Realistic background blur requires an incredibly accurate depth map. Single-lens cameras struggle to distinguish between a flat object and a 3D scene.
  2. Consistency: Most methods treat "deblurring" (fixing a blurry photo) and "reblurring" (adding artistic bokeh) as two unrelated tasks. This often leads to visual artifacts where the transition between sharp and blurry regions looks physically impossible.

To address this, researchers introduce UiD (User-Instructed Defocus), a new framework that allows anyone to "refocus" a photo after it’s taken using simple text, box, or point prompts. By leveraging Dual-Pixel (DP) sensors and a novel invertible neural network, the system can deblur an image into an "all-in-focus" version and then realistically re-apply blur to everything except the user's chosen subject.

How UiD Works

1. Dual-Pixel (DP) Disparity

Most modern smartphone sensors are "Dual-Pixel," meaning every pixel is split into two photodiodes (left and right). This creates a tiny stereo pair for every single shot. UiD uses this subtle "micro-stereo" data to calculate a high-fidelity disparity map, which serves as a reliable proxy for depth.

2. Invertible Deblurring and Reblurring

Instead of two separate models, UiD uses a single invertible network.

  • The Forward Pass: It learns spatially varying defocus kernels to turn a blurry DP image into a sharp, All-in-Focus (AiF) image.
  • The Backward Pass: Because the network is mathematically invertible, it can use the inverse of those same kernels to turn the sharp image back into a blurry one.

When a user selects a new focus area, the system calculates a "target disparity." It shifts the disparity map so the chosen object sits at the zero-blur plane and then runs the "reblurring" pass. Because the kernels are shared and invertible, the resulting blur is physically consistent with the camera's actual optics.

3. Instructed Segmentation (SAM)

To make the system user-friendly, the researchers integrated the Segment Anything Model (SAM). Using an "early-fusion" strategy, SAM looks at the restored sharp image and the user's prompt (e.g., "the red hat") to create a precise mask of the object that should stay in focus.

Key Results and Insights

Demonstration of UiD refocusing capabilities, shifting focus between the foreground panda and background moon lamp.
  • Superior Deblurring: On the standard DPD-blur benchmark, UiD achieved a PSNR of 26.89 dB, outperforming heavyweights like Restormer and K3DN.
  • Efficiency: Despite its power, the model is remarkably lightweight. It uses only 3.12 million parameters, compared to 26M+ in competing models like Restormer, making it highly viable for mobile deployment (495 GFlops vs. 4458 GFlops).
  • Realistic Refocusing: In qualitative tests, UiD produced much cleaner "bokeh" (background blur) than previous methods, which often leave "halos" or blurry edges around the sharp subject. The system successfully handles complex prompts to generate accurate focus masks.
  • Invertibility as a Regularizer: By forcing the model to be able to "undo" its own deblurring, the researchers ensured the model truly understands the relationship between depth and blur, rather than just "hallucinating" sharp details.

Datasets

The model was rigorously trained and evaluated on:

  • DPD-blur: A standard benchmark for dual-pixel defocus deblurring.
  • DP5K: A large-scale dataset containing 5,000 dual-pixel images.
  • Self-Collected DP Dataset: The authors captured 10 high-resolution (6720 × 4480) image pairs using a Canon EOS 5D Mark IV to specifically test refocusing quality in real-world, high-detail scenarios.

Limitations and Future Work

  • Parallax and Misalignment: When shifting focus between objects that are very far apart, the "micro-stereo" nature of DP sensors can cause slight misalignment or "ghosting" at the edges of objects. The authors currently use manual cropping or classical matching to mitigate this.
  • Generative Refinement: While the current model is physically grounded, integrating Diffusion Models could help synthesize even more aesthetically pleasing, "dreamy" bokeh that goes beyond simple optical simulation.
  • Video Extension: The current framework is designed for static images; extending this invertible logic to video would require handling temporal consistency.

Summary updated

BibTeX
@inproceedings{han2025user,
  author = {Yudong Han and Yan Yang and Hao Yang and Liyuan Pan},
  title = {{User-Instructed Disparity-aware Defocus Control}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=j38Cb5LlaY},
}
Figure