Inferensys

Glossary

Focal Stack

A focal stack is a sequence of images of the same scene captured at incrementally different focus distances, used for extended depth of field or depth-from-defocus algorithms.
Developer demonstrating multi-agent tool use, agent tool selection interface on laptop, casual tech demo moment.
COMPUTATIONAL PHOTOGRAPHY

What is a Focal Stack?

A focal stack is a foundational data structure in computational photography and computer vision, enabling advanced image processing and 3D scene analysis.

A focal stack is a sequence of images of the same static scene captured at incrementally different focus distances, systematically sampling the depth of field. This collection is a discrete, focal-plane-specific sampling of the continuous plenoptic function. Its primary technical utility lies in enabling extended depth of field (EDOF) synthesis via focus stacking and providing the input data for depth-from-defocus (DFD) algorithms, which infer scene geometry by analyzing the variation of blur across the stack.

Acquiring a focal stack requires precise control over the camera's focus motor, with each image capturing a different focal plane. In post-processing, algorithms like Laplacian pyramid blending select the sharpest regions from each image to construct a single, fully focused composite. For 3D reconstruction, DFD methods model the point spread function (PSF) to estimate per-pixel depth, offering an alternative to multiview stereo when camera motion is constrained. This makes focal stacks crucial for macrophotography, microscopy, and computational imaging systems.

COMPUTATIONAL PHOTOGRAPHY

Key Applications of Focal Stacks

A focal stack is a sequence of images captured at different focus distances. This data structure enables a range of computational photography and computer vision algorithms by providing explicit control over depth-dependent blur.

01

Extended Depth of Field (Focus Stacking)

The primary application is synthesizing a single all-in-focus image from a focal stack. Algorithms analyze each image to select the sharpest pixels at each spatial location, combining them into a final composite with a depth of field extending from the nearest to the farthest captured plane. This is critical in macro photography and microscopy, where lens physics severely limits the depth of field in a single shot. The process involves:

  • Multi-scale pyramid analysis to assess local sharpness (e.g., using Laplacian variance).
  • Weight map generation to blend pixels seamlessly.
  • Advanced fusion to avoid artifacts like haloing at depth discontinuities.
02

Depth-from-Defocus (DFD)

Focal stacks provide the core data for Depth-from-Defocus algorithms, which estimate a dense depth map by modeling how blur (defocus) changes with focus distance. Unlike stereo matching, DFD uses a single camera and does not require textured surfaces, making it effective for smooth, untextured objects. The process involves:

  • Modeling the Circle of Confusion (CoC) as a function of depth and lens parameters.
  • Fitting the observed blur kernel at each pixel across the stack.
  • Solving an inverse problem to recover the per-pixel depth. This technique is used in industrial inspection and some smartphone portrait modes for depth estimation.
03

Digital Refocusing (Post-Capture Focus)

By simulating the integration of rays from the captured focal stack, one can synthetically re-focus an image after capture. This is a simplified form of light field rendering. The algorithm effectively shifts and blends slices of the stack to bring any depth plane into sharp focus while blurring others, emulating a shallow depth of field effect. Key implementations include:

  • Shift-and-add algorithms for fast, approximate refocusing.
  • More sophisticated integration using estimated depth maps for higher quality.
  • Applications in computational microscopy and consumer photography apps.
04

3D Microscopy & Focal Series Reconstruction

In scientific imaging, particularly transmission electron microscopy (TEM) and confocal microscopy, a focal stack (termed a 'through-focus series') is used to reconstruct high-resolution 3D structure. The changing blur contains phase information. Algorithms like:

  • Tomographic reconstruction from a tilt series, where focus change provides complementary data.
  • Wavefront reconstruction techniques (e.g., ptychography) that use defocus diversity to solve for the complex optical field of a specimen. This enables nanoscale 3D imaging of materials and biological samples.
05

Defocus Deblurring & Image Restoration

A focal stack can be used to deblur a single, defocused image by leveraging the information present in other slices of the stack. By identifying the in-focus regions across the stack, the algorithm can construct a point spread function (PSF) model for out-of-focus areas and perform non-blind deconvolution. This is valuable for:

  • Astronomical imaging, where atmospheric turbulence and optical imperfections cause blur.
  • Restoring historical photographs with focus errors.
  • Improving the effective resolution of microscope images beyond the diffraction limit in some modalities.
06

Material & Reflectance Analysis

The way defocus blur manifests can reveal surface properties. Specular highlights and translucent materials blur differently than diffuse surfaces. By analyzing the blur kernel morphology across a focal stack, algorithms can infer:

  • Surface roughness and glossiness (material BRDF properties).
  • Subsurface scattering parameters in translucent objects like marble or skin.
  • Fine geometric detail that is below the spatial resolution of the sensor but affects the blur profile. This finds use in automated quality inspection and digital asset creation for accurate material capture.
COMPARISON

Focal Stack vs. Light Field

A technical comparison of two core computational photography techniques for capturing scene information beyond a single 2D image, highlighting their data structure, acquisition, and primary applications.

Feature / MetricFocal StackLight Field

Core Data Structure

Sequence of 2D images

4D or higher-dimensional vector function

Primary Acquisition Method

Conventional camera with varied focus

Plenoptic camera with microlens array

Dimensionality of Captured Data

2D + focus parameter (2.5D)

4D (2 spatial + 2 angular)

Inherent Depth Information

Indirect (via defocus blur)

Direct (via ray intersection geometry)

Post-Capture Refocusing Capability

Limited (pre-defined focal planes)

Full (continuous synthetic aperture)

Parallax / Viewpoint Shift Capability

None

Yes (within captured angular range)

Primary Use Case

Extended Depth of Field (EDoF), Depth-from-Defocus

View Synthesis, Digital Refocusing, 3D Reconstruction

Typical Spatial Resolution

Full sensor resolution per image

Reduced by angular sampling (spatial-angular tradeoff)

Representation Subset

A 2D slice of the plenoptic function

A 4D subset of the full plenoptic function

Post-Processing for Depth

Required (e.g., focus measure operators)

Inherent (via epipolar geometry analysis)

Hardware Complexity

Low (standard DSLR/mirrorless)

High (specialized microlens optics)

FOCAL STACK

Frequently Asked Questions

A focal stack is a core technique in computational photography and 3D reconstruction. This FAQ addresses its fundamental principles, applications, and relationship to advanced neural rendering methods.

A focal stack is a sequence of images of the same static scene captured with a camera's focus distance set at incrementally different planes, from the nearest to the farthest depth. This collection samples the scene's appearance across the entire depth of field, with each image having a different region in sharp focus. It is a discrete, 2D+time representation used to overcome the optical limitation of a single image having a limited sharp focus range.

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.