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.
Glossary
Focal Stack

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.
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.
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.
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.
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.
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.
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.
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.
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.
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 / Metric | Focal Stack | Light 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) |
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.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
A focal stack is a core data structure in computational photography. These related concepts define the acquisition, representation, and processing of light for advanced imaging and 3D reconstruction.
Light Field
A light field is a 4D or higher-dimensional vector function that describes the amount of light flowing in every direction through every point in space. It is a sampled representation of the full plenoptic function.
- Core Data for Focal Stacks: A focal stack can be synthetically generated from a captured light field by integrating rays that converge at different virtual focal planes.
- Acquisition: Requires specialized hardware like a plenoptic camera with a microlens array.
- Applications: Enables post-capture refocusing, viewpoint shifting, and depth estimation without multiple physical exposures.
Plenoptic Function
The plenoptic function is the complete theoretical description of all visual information in a scene. It is a 7D function: I = f(x, y, z, θ, φ, λ, t), representing light intensity at every 3D position (x,y,z), for every direction (θ,φ), for every wavelength λ, and at every time t.
- Theoretical Foundation: A focal stack and a light field are both finite, lower-dimensional samples of this infinite function.
- Goal of Modeling: The aim of plenoptic function modeling is to reconstruct or approximate this complete function from sparse samples to enable photorealistic view synthesis.
Depth from Defocus
Depth from Defocus is a passive depth estimation technique that calculates scene geometry by analyzing the differences in blur (defocus) between two or more images captured with different focus settings.
- Primary Use of Focal Stacks: A focal stack is the ideal input for DfD algorithms. By measuring how a point's blur circle changes across the stack, its depth can be precisely triangulated.
- Contrast to Stereo: Unlike stereo vision, which uses parallax from viewpoint shift, DfD uses information from a single viewpoint with varying optical parameters.
- Algorithm Steps: Typically involves modeling the point spread function (PSF) of the camera and solving an inverse problem to find the depth map that best explains the observed blur variation.
Extended Depth of Field
Extended Depth of Field is a computational imaging technique that combines a focal stack to produce a single, fully focused image where all objects from near to far appear sharp.
- Direct Application: This is one of the most common practical uses for a captured focal stack.
- Fusion Algorithms: Techniques like wavelet-based fusion or Laplacian pyramid blending select the sharpest pixels from each image in the stack based on local focus metrics (e.g., gradient magnitude).
- Microscopy & Macrophotography: Critical in fields like microscopy and macro photography, where the physical depth of field is extremely shallow.
Refocusing (Digital)
Digital refocusing is the process of synthetically changing the focal plane of a photograph after it has been captured, simulating the effect of having focused the camera lens at a different distance.
- Enabled by Light Fields: A primary feature of light field photography. From a single light field capture, a full focal stack can be rendered computationally.
- Mechanism: Achieved by integrating or shifting the sub-aperture images extracted from the light field to simulate the convergence of light rays at a new plane.
- User Interaction: Allows for interactive 'focus picking' in post-production, useful for portrait photography and creative control.
Focal Sweep
A focal sweep is a specific capture technique where the camera's focus distance is continuously varied during a single sensor exposure, effectively integrating a focal stack into one blurred image.
- Motion Blur Analogy: Similar to motion blur, but applied to the focus parameter instead of camera position.
- Computational Decoding: Specialized deconvolution algorithms can recover a depth map or even a full focal stack from this single, purposefully blurred image.
- Advantage for Dynamic Scenes: Useful for capturing depth information of moving objects, as all focus distances are captured simultaneously in time, avoiding misalignment issues in a traditional sequential focal stack.

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us