Inferensys

Glossary

Refocusing

Refocusing is a computational photography technique that synthetically adjusts the focal plane of an image after capture, typically using data from a light field or focal stack.
Data scientist building training data pipeline on laptop, data preprocessing visible, technical workspace.
COMPUTATIONAL PHOTOGRAPHY

What is Refocusing?

Refocusing, also known as digital refocusing, is a computational photography technique that synthetically adjusts the focal plane of an image after it has been captured.

Refocusing is a post-capture process that synthetically changes the focus distance and depth of field in a photograph. Unlike a traditional camera, which fixes focus at capture, this technique uses additional data—typically a light field from a plenoptic camera or a focal stack of images—to simulate the optical effects of different aperture settings and focus distances. This enables photographers to select the focal plane after the fact, a capability central to computational photography.

The technique relies on the plenoptic function, which models light rays in space. By capturing the direction of light, a system can project rays to a new synthetic focal plane. Advanced applications extend this to generating all-in-focus images or artistic bokeh effects. It is a foundational operation for view synthesis and is closely related to depth-from-defocus algorithms in computer vision and graphics.

COMPUTATIONAL PHOTOGRAPHY

Core Technical Mechanisms

Refocusing is a post-capture computational process that synthetically adjusts the focal plane of an image. It relies on specialized data capture and algorithmic processing to manipulate depth of field.

01

Light Field Refocusing

This method uses the full 4D light field captured by a plenoptic camera. Refocusing is achieved by integrating rays that converge at a synthetic focal plane in post-processing.

  • Shearing: The core operation is a 2D shear of the 4D light field data in ray space. This angular shift realigns rays to originate from a new virtual aperture center.
  • Reintegration: After shearing, rays are summed across angular dimensions, simulating the integration that would have occurred at the sensor if the scene had been focused at that plane.
  • Flexibility: Enables continuous, focus-free capture; any focal plane can be chosen after the fact, and depth of field can be adjusted arbitrarily.
02

Focal Stack Refocusing

This technique uses a focal stack—a sequence of images captured at different focus distances. Refocusing selects or blends from this pre-captured set.

  • Depth-from-Defocus: Algorithms analyze the relative blur (defocus) of each point in the stack to estimate a depth map.
  • Image Fusion: For synthetic refocusing, pixels are pulled from the image in the stack where they appear sharpest, based on the estimated depth map and the desired focal plane.
  • All-in-Focus Imaging: A related output is an extended depth of field image created by fusing the sharpest regions from all images in the stack.
03

The Shift-and-Add Algorithm

This is the foundational algorithm for digital refocusing from a light field. It mathematically replicates the function of a traditional lens.

  • Ray Re-projection: For a desired focal plane, each sub-aperture image (a view from a specific microlens) is shifted on the sensor plane.
  • Shift Amount: The shift is proportional to the disparity of the point, which is derived from its depth and the geometry between the main lens and microlens array.
  • Averaging: The shifted sub-aperture images are averaged, which integrates light as if it had passed through a lens focused at the new plane. This is equivalent to a shearing operation in the 4D light field representation.
04

Spatial-Angular Resolution Trade-off

A fundamental constraint in light field refocusing. A plenoptic camera's sensor has fixed pixels, which must be allocated to sample both spatial and angular information.

  • Spatial Resolution: The number of distinct pixels describing a single view of the scene.
  • Angular Resolution: The number of distinct ray directions sampled per spatial point (e.g., the number of microlenses behind a main lens pixel).
  • The Trade-off: Increasing angular resolution (for smoother refocusing and viewpoint interpolation) reduces the spatial resolution of the final rendered image. This is defined by the plenoptic sampling theorem.
05

Applications Beyond Photography

Refocusing principles enable advanced capabilities in robotics, microscopy, and computational displays.

  • Microscopy: In light field microscopy, refocusing allows 3D volumetric imaging from a single snapshot, enabling rapid observation of living samples.
  • Robotic Vision: Provides immediate depth cues and allows for post-capture focus on regions of interest for inspection or navigation.
  • 3D Displays: Drives holographic stereogram and integral imaging displays, where emitting the correct light field from a screen creates a glasses-free 3D image that viewers can focus on naturally.
06

Limitations & Artifacts

Practical refocusing systems face several technical challenges that can degrade output quality.

  • Angular Aliasing: Insufficient angular sampling causes ghosting or repeating artifacts in refocused regions, especially for out-of-focus highlights.
  • Occlusion Artifacts: Objects at the synthetic focal plane may reveal regions that were occluded in the captured light field, leading to disocclusion errors that require inpainting.
  • Noise Amplification: The shift-and-add process can amplify sensor noise, particularly in dark or heavily blurred regions.
  • Resolution Loss: As noted in the spatial-angular trade-off, the final refocused image has lower resolution than a conventional photo from a sensor of the same size.
COMPUTATIONAL PHOTOGRAPHY

How Digital Refocusing Works

Digital refocusing is a post-capture computational technique that synthetically adjusts an image's plane of sharp focus using data beyond a standard 2D photograph.

Digital refocusing synthetically adjusts the focal plane of an image after capture by computationally simulating the effects of a camera's aperture and lens. It requires data capturing more light information than a conventional photo, such as a light field from a plenoptic camera or a focal stack of images. This data encodes how light rays travel through space, allowing software to selectively integrate rays that would converge at a new synthetic focal plane, blurring others to mimic optical defocus. The core mechanism is a digital re-simulation of the thin lens equation applied to the captured ray data.

The process involves two key computational steps: ray tracing and integration. For a desired focal plane, the algorithm traces paths from each sensor pixel back through the virtual aperture to the scene. It then samples the corresponding light rays from the captured data—either from different microlens views in a light field or from appropriate slices in a focal stack. These samples are integrated (averaged) per output pixel, with rays converging at the new focus plane contributing sharp details and diverging rays creating synthetic bokeh. This enables focus adjustments impossible in traditional photography, such as focusing on objects behind glass or creating extreme shallow depth-of-field effects from a single capture.

COMPUTATIONAL PHOTOGRAPHY

Primary Applications and Use Cases

Refocusing is not merely a post-processing effect; it is a fundamental computational technique that enables new capabilities in imaging, vision, and display systems by manipulating the captured light field.

01

Post-Capture Focus Control

The most direct application of refocusing is allowing photographers to synthetically adjust the focal plane after an image is captured. This is achieved by computationally integrating rays from the desired focal plane within the captured light field. Key implementations include:

  • Lytro cameras which popularized consumer light field photography.
  • Focal stack fusion, where a stack of images at different focus distances is captured and the in-focus regions are blended to create an image with extended depth of field.
  • Software tools that allow selective focus and bokeh adjustment from a single light field capture, effectively simulating different aperture sizes.
02

Depth Estimation & 3D Sensing

Refocusing algorithms are intrinsically linked to depth. By analyzing which synthetic focus setting brings different image regions into sharpness, a depth map can be inferred. This technique, known as depth-from-defocus, uses the focal stack as input. Applications include:

  • Microscopy: Determining the 3D structure of biological samples.
  • Industrial inspection: Measuring the height and topography of manufactured components.
  • Computational imaging for robotics: Providing dense depth information from passive sensors, complementing active systems like LiDAR.
03

All-in-Focus Imaging & Focus Stacking

Refocusing enables the creation of images where the entire scene is in sharp focus, beyond the physical limits of a camera lens. This is critical in fields where maximum detail is required across a deep scene. The process involves:

  1. Capturing a focal stack.
  2. Using a focus measure (e.g., variance of Laplacian) to identify the sharpest pixels at each spatial location across the stack.
  3. Fusing these pixels into a single all-in-focus composite. This is essential for:
  • Macro and microphotography where depth of field is extremely shallow.
  • Document digitization to ensure text is legible across curled pages.
  • Landscape astrophotography to keep both foreground and stars sharp.
04

Synthetic Aperture & Bokeh Rendering

By selectively integrating rays from the light field, refocusing can simulate the effect of using a lens with a different aperture size. This allows for:

  • Synthetic shallow depth of field: Creating professional-looking bokeh from images captured with small-aperture smartphone cameras. The quality depends on the angular resolution of the light field.
  • Synthetic wide aperture: Simulating a faster lens for low-light performance by integrating more light rays.
  • Bokeh editing: Altering the shape and character of out-of-focus highlights after capture, a feature found in advanced computational photography modes on modern phones.
05

Autostereoscopic 3D Displays

Refocusing is the core computational backend for light field displays and holographic stereograms. These displays emit different light rays in different directions, allowing viewers to see a 3D scene without glasses. The process requires:

  • Rendering dozens to hundreds of sub-aperture images (different viewpoints) from the captured or synthesized light field.
  • These images are then fed to the display's optical system (e.g., lenticular lens array, parallax barrier, or directional backlight).
  • The display hardware acts as the inverse of a light field camera, reconstructing the light field in space. This technology is used in experimental volumetric displays and emerging 3D monitors for design and medical imaging.
06

Computational Microscopy & Tomography

In scientific imaging, refocusing enables techniques that overcome physical limitations of optical systems. Key methods include:

  • Fourier ptychographic microscopy: Captures multiple low-resolution images with varied illumination angles, then uses iterative phase retrieval and synthetic refocusing to reconstruct a high-resolution, large field-of-view, and depth-resolved image.
  • Light field microscopy: Uses a microlens array to capture 4D light field data from a microscope, enabling rapid 3D imaging of dynamic biological processes (e.g., neural activity in zebrafish) without mechanical scanning.
  • Optical coherence tomography (OCT): While not light-field-based, it shares the mathematical concept of synthesizing focus from interferometric data to create depth-resolved cross-sectional images of tissue.
PLENOPTIC FUNCTION MODELING

Frequently Asked Questions

Essential questions about refocusing, a core computational photography technique for synthetically adjusting focus after image capture.

Refocusing, or digital refocusing, is a computational photography technique that synthetically adjusts the focal plane of an image after it has been captured, enabling photographers to change what is in sharp focus without physically altering the camera's lens settings. This is fundamentally different from optical focusing, which occurs at the moment of exposure. The technique relies on capturing additional data beyond a standard 2D photograph, most commonly a light field (which records the direction of light rays) or a focal stack (a series of images taken at different focus distances). By processing this data, algorithms can simulate the optical effects of a different aperture size and focus distance, allowing for post-capture creative control and applications like extended depth of field.

Key technical components include:

  • Light Field Refocusing: Using the 4D radiance data from a plenoptic camera, rays are selectively integrated to simulate a virtual camera aperture, shifting the plane of sharpness.
  • Focal Stack Fusion: Algorithms analyze the stack to identify the sharpest regions at each depth, then blend them or allow user-selective focus from any image in the stack.
  • Depth-from-Defocus: The amount of blur in different parts of the image is used to estimate a depth map, which then guides the synthetic re-blurring of the image to a new focal plane.
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.