Fact-checked by Grok 2 weeks ago

Focus stacking

Focus stacking is a post-processing in and that combines multiple images, each focused on a different of the , to produce a single composite image with an extended beyond what is possible in a single . This method addresses the limitations of shallow inherent in close-up or magnified imaging, where only a narrow slice of the scene can be sharply focused at once due to optical constraints. The process typically involves capturing a sequence of photographs—ranging from a few for landscapes to dozens or more for subjects—while incrementally shifting the point, often using a to maintain and consistent . Specialized camera features, such as Nikon's Focus Shift Shooting or similar modes on other systems, automate the adjustments to ensure overlapping depths of field across the stack. In software like or dedicated tools such as , the images are then aligned, and algorithms detect and merge the sharpest regions from each frame, discarding out-of-focus areas to create a seamless all-in- result. Commonly applied in to capture intricate details of small subjects like or flowers without blur, focus stacking also benefits landscape and architectural imaging by ensuring foreground-to-background sharpness, and in scientific for documenting specimens with high resolution.

Definition and Principles

Basic Concept

Focus stacking is a technique that combines multiple slightly out-of-focus images, each captured with the focused on a different plane within the subject, to produce a single composite image featuring an extended beyond what is possible in a single exposure. This method enables the creation of fully sharp images across a greater range of distances, particularly useful when the subject's depth exceeds the camera's natural . The core process begins with acquiring a stack of images—typically 5 to 10 frames for general subjects and 20 to 100 or more for —by systematically shifting the focus point in small increments along the , either manually or via automated rails or camera features. In post-processing, the images are aligned to compensate for any minor shifts and then blended to select and merge only the in-focus portions from each frame, resulting in a composite where is preserved throughout the desired depth. This approach leverages computational to simulate an all-in-focus result without altering the optical setup during capture. Focus stacking addresses fundamental optical limitations, such as the shallow at wide s needed for maximum , which restricts focus to narrow planes, or the diffraction-induced from stopping down the to deepen at the expense of . By , single-image methods cannot simultaneously achieve both extensive depth and high acuity, making stacking essential for scenarios demanding comprehensive , like or microscopic .

Optical Foundations

The (DOF) in optical imaging represents the range of distances along the over which a subject appears acceptably sharp in the . In conventional , DOF is approximated by the \text{DOF} \approx \frac{2 N c u^2}{f^2}, where N is the (aperture ratio), c is the circle of confusion (a measure of acceptable , typically around 0.02 mm for full-frame sensors), u is the subject distance, and f is the . This approximation holds when the subject distance greatly exceeds the , revealing that DOF scales linearly with the and quadratically with subject distance while inversely scaling with the square of the . In , where high magnification requires short subject distances (e.g., u \approx 0.1 m) and longer s (e.g., f = 100 mm), DOF becomes extremely shallow—often mere millimeters—even at moderate apertures like f/4, limiting sharpness to a thin slice of the subject. To extend DOF in such scenarios, photographers often increase the by stopping down the , but this is constrained by limits. causes light to spread beyond the geometric image of a , degrading as the aperture shrinks; peak typically occurs around f/8 to f/11 for most photographic objectives, balancing aberration control with minimal . Further stopping down (e.g., to f/16 or beyond) extends DOF but introduces noticeable softness across the image due to , making focus stacking preferable as it allows capturing multiple images at optimal apertures (e.g., f/5.6) without compromising overall . In microscopy, DOF constraints are even more severe due to the use of high (NA) objectives for . The NA is defined as \text{NA} = n \sin \theta, where n is the of the medium between the and specimen (e.g., 1.0 for air, 1.51 for ), and \theta is the half-angle of the maximum cone of accepted by the . High-NA objectives (e.g., NA = 1.4) achieve superior but yield a shallow DOF, approximated by \text{DOF} \approx \lambda / \text{NA}^2, where \lambda is the illumination (typically 0.5 μm for visible ). For a 100× oil-immersion with NA = 1.4, this results in a DOF of approximately 0.25–1 μm, confining sharp focus to an exceedingly narrow and necessitating stacking for extended volumetric imaging. Non-stacking alternatives to extend DOF include wavefront coding and light-field cameras. Wavefront coding employs a phase mask (e.g., cubic ) at the to create a depth-invariant , which digital then restores to near-diffraction-limited quality over a much larger defocus range (up to 30 times the standard tolerance); its advantages are single-exposure capture and no mechanical motion, though it demands computational processing and may introduce minor artifacts or require higher . Light-field cameras, using microlens arrays to capture directional light information, enable post-capture refocusing and synthetic DOF extension via large apertures (e.g., f/4) without noise penalties from stopping down; benefits include reduced risk and flexible depth rendering, but drawbacks encompass lower (due to light partitioning) and alignment sensitivities compared to stacking's full-resolution outputs.

History

Origins in Microscopy

The shallow depth of field in high-numerical aperture (NA) objectives poses a significant challenge in light microscopy, restricting sharp focus to a narrow plane and complicating imaging of thick biological specimens. Early concepts of focus stacking emerged in the 1990s alongside the maturation of confocal microscopy, where z-stack scanning enabled the acquisition of successive optical sections through a sample at varying focal depths. This technique, integral to laser scanning confocal microscopes (LSCMs), allowed for the compilation of 3D reconstructions by projecting multiple slices, providing a foundational approach to extending focus across depth in biological imaging. Advances in optics and electronics during the decade, including stable lasers and high-efficiency scanning mirrors, facilitated routine z-stack collection for analyzing cellular structures like microtubules. The first automated implementations of focus stacking appeared around 2004 in electron microscopy, building on robust autofocusing methods to generate through-focus image stacks for extended . For instance, convolution-based autofocusing algorithms enabled rapid, noise-resistant focus measurement over the full focal range, supporting unattended operation for large-scale imaging of fixed cells and tissues in bright-field, phase contrast, and modalities. By 2004, through-focus stacks in () were post-processed using software like Auto-Montage Pro to select in-focus patches and create all-in-focus composites, demonstrated on complex samples such as osteoporotic to reveal resorption features. Adoption of these techniques was driven by the demand for reconstructions in biological samples, such as diatoms and cells, where confocal z-stacks revealed intricate internal architectures previously obscured by out-of-focus light. The transition from manual analog processes to digital stacking accelerated with the integration of (CCD) sensors in the , replacing tube-based video cameras and enabling precise digital capture and processing of multi-plane images for enhanced resolution in volumetric analysis.

Evolution in Photography

The adaptation of focus stacking to photography emerged in the mid-2000s, building on foundational techniques from microscopy to address shallow depth-of-field challenges in macro imaging. The rise of digital single-lens reflex (DSLR) cameras enabled precise manual focus bracketing, allowing photographers to capture sequences of images with incremental focus shifts. In 2006, free software like CombineZM and Helicon Focus facilitated the blending of these sequences into all-in-focus composites, marking a key milestone for accessible macro photography. A significant advancement occurred in 2012 with NASA's mission, where the rover's incorporated onboard focus stacking to analyze Martian rock samples by merging multiple images. For instance, in 2014, MAHLI produced a detailed stacked image of the rover's first sampling hole in , measuring 1.6 cm in diameter and 6.7 cm deep, demonstrating the technique's utility in extraterrestrial exploration. This application highlighted focus stacking's potential for high-resolution imaging in constrained environments. Commercial adoption accelerated in the as manufacturers integrated focus stacking into camera , simplifying the process for photographers. Olympus pioneered in-camera stacking with the 2014 firmware update for the OM-D E-M1, which automated and merging up to eight images. The shift to mirrorless systems further popularized the feature, offering electronic viewfinders for real-time focus preview and reducing the need for post-processing. By the 2020s, AI-assisted focus stacking had permeated consumer devices, particularly smartphones, enhancing for extended . iPhone Pro models, starting with the 2021 , leveraged neural engines for multi-frame fusion and AI-driven sharpening in macro mode, simulating stacked results in to improve macro and modes. These trends, extending through 2025, democratized the technique across mobile platforms.

Technique

Image Acquisition Process

The image acquisition process in focus stacking begins with establishing a stable hardware setup to ensure precise control over focus shifts and minimal movement between exposures. A sturdy or focusing rail is essential for maintaining alignment, particularly in where even slight vibrations can blur the stack. Systems like the StackShot macro rail, which provides motorized control over 100-200 mm of travel, allow for automated bracketing by incrementally moving the camera or subject along the . In applications, motorized stages and objectives mounted on a trinocular enable similar precision, often using variable focus lenses or adapters to connect cameras for capture. lenses, such as a 100 mm f/2.8, are commonly paired with these setups to achieve high while preserving . Focus bracketing involves capturing a series of images by systematically incrementing the focus plane, either manually via the lens ring or automatically through or controls. In work, step sizes typically range from 1-5 μm for extreme close-ups, though 75-150 μm is often used for broader subjects to balance detail and efficiency. These increments are guided by principles, ensuring each frame advances the sharp plane by a fraction of the lens's total DOF. The process starts by focusing on the nearest point of the subject, then advances to the farthest, with the or executing the steps at a controlled rate, such as 150 μm per interval in automated distance mode. To maintain consistency across the , exposure parameters must remain fixed, including (typically f/5.6 to f/8 to optimize without excessive ), ISO, and . This uniformity prevents tonal shifts that could complicate blending, with challenges like subject in live specimens addressed through short s or controlled LED to freeze motion without altering illumination. parameters, such as the total number of images, are determined by dividing the required travel distance (subject depth) by the step size, often yielding 20-100 frames; an overlap of 20-50% between adjacent frames is incorporated by reducing step size relative to the DOF, ensuring seamless coverage. For instance, a 1 mm subject depth at 50 μm steps might require around 20 images with built-in overlap for robust stacking.

Focus Detection and Blending

Focus detection in focus stacking begins with analyzing the acquired image stack to identify regions of in each frame. The stack serves as input, where each image captures a different . Algorithms compute a focus measure for pixels or blocks across the stack, quantifying based on local image properties. A widely adopted edge-detection method uses the variance of the Laplacian operator, which highlights high-contrast edges indicative of by computing the second of changes; higher variance correlates with sharper regions. This measure, derived from early work on optimal focus operators, effectively discriminates in-focus areas in defocused images by emphasizing magnitudes. Frequency-domain approaches complement spatial methods by transforming images via the to isolate high-frequency components associated with sharp details. In these techniques, the energy or power spectrum in higher frequencies serves as the focus metric, as defocus attenuates these components, leading to smoother spectra. Seminal implementations compute the ratio of high- to low-frequency energy, enabling robust detection even in textured or noisy scenes. Once in-focus regions are identified, alignment corrects for minor shifts, rotations, or induced by camera movement or subject depth variations during capture. Feature-based methods extract and match keypoints using (SIFT), which detects interest points robust to scale and orientation changes, then estimates homographies for registration. Alternatively, phase correlation in the domain computes translation offsets by identifying peaks in the cross-power spectrum, offering sub-pixel accuracy for translational misalignments common in stacks. Pyramid blending techniques then facilitate multi-resolution alignment, progressively refining correspondences from coarse to fine scales for seamless transitions. Blending combines the sharpest regions into a composite image, typically via weighted averaging guided by measures to generate a that assigns contributions per . This creates an all-in- output where each point draws from the frame with maximum sharpness. To mitigate artifacts like halos at depth discontinuities, advanced methods employ wavelet decomposition for multi-scale fusion, preserving edges while smoothing transitions, or Poisson blending, which solves a gradient-domain to seamlessly integrate regions by matching intensities and gradients. Noise in the is addressed through filtering across corresponding s, selecting the value to suppress outliers while retaining sharpness.

Applications

Macro and Landscape Photography

Focus stacking plays a pivotal role in by addressing the inherently shallow at close distances, enabling photographers to capture sharp details across entire subjects like and flowers. At 1:1 magnification, typical of , the can be mere millimeters, necessitating stacks of 50 or more images focused incrementally from front to back to achieve comprehensive sharpness. This approach allows shooting at optimal apertures such as f/5.6 to f/8, preserving and avoiding the softening that occurs at f/16 or smaller, which would otherwise be required for depth. For instance, in documenting a or , stacks of 8 to 11 images have been used to render textures from eyes to wings in exquisite detail, transforming challenging close-ups into highly resolved compositions. In , focus stacking overcomes depth-of-field limitations to deliver edge-to-edge sharpness, extending the effective for scenes spanning foreground to distant mountains. Stacks of around 10 images, each focused at progressive distances, ensure uniform acuity without relying on stopped-down apertures that compromise overall image quality. This method builds on traditional principles akin to those employed by , but leverages digital tools for precise control, allowing photographers to blend exposures in for natural-looking results that emphasize environmental depth and clarity. Modern workflows integrate focus stacking seamlessly through in-camera bracketing features introduced by and Nikon in 2018, which automate the acquisition of image series with adjustable focus steps and shot counts. On Nikon's D850 and subsequent models, users set parameters like 1–300 shots and step widths of 1–10, capturing sequences from near subjects to infinity, which are then aligned and merged using software such as or Helicon Focus for artistic refinement. Canon's R-series cameras similarly enable bracketing with focus increments tailored to subject distance, producing raw files for post-processing that prioritize creative intent over automated composites. A illustrative case study in wildlife macro photography involves focus stacking a bee laden with pollen, where multiple rail-mounted exposures—captured with a and 60mm lens—reveal granular details of pollen grains and body segments without introducing from subtle movements. This technique, as applied to species like , combines frames to produce a fully focused image that highlights ecological intricacies, such as pollen , in a single, artifact-free view.

Microscopic Imaging

In light microscopy, focus stacking, often referred to as z-stacking, is essential for thick specimens where the shallow (typically 0.5–2 μm at high magnifications) limits single-plane sharpness. By acquiring a series of images at incremental focal planes along the , z-stacking enables the creation of composite images with extended , allowing clear visualization of entire structures such as whole-mount sections or biological samples exceeding 50 μm in thickness. For instance, in cellular structures within sections, stacks of over 100 slices spaced at 0.5 μm intervals are commonly used to capture fine details across the sample volume, such as membrane distributions in labeled cells. This technique is particularly valuable for opaque or scattering samples, where it overcomes limitations of traditional widefield by fusing in-focus regions from multiple planes into a single, high-contrast output. In electron microscopy, focus stacking extends to scanning electron microscopy (SEM) and (TEM) to generate 3D-like composite images of intricate nanostructures, compensating for the limited inherent to high-resolution imaging. , with a around 1 μm at magnifications above 1000×, benefits from stacking multiple focal planes to reconstruct detailed surface topographies of specimens like diatom frustules, which exhibit silica nanostructures spanning several micrometers. In TEM, focal series stacking—acquiring images at slightly varied focus levels—helps mitigate defocus artifacts in thick sections, enabling sharper composites for volumetric analysis of internal features in biological samples. These methods produce pseudo-3D views that reveal morphological details otherwise obscured by the instrument's narrow focal plane. Automation in microscopic focus stacking relies on motorized focus drives integrated with software for precise z-axis control and image acquisition triggers, ensuring consistent intervals and minimal drift in long sequences. Motorized stages, often piezo-driven for sub-micrometer accuracy, allow automated scanning of the focal plane while software synchronizes camera capture, typically at speeds supporting hundreds of frames per minute. This setup integrates seamlessly with for fluorescence-based stacks, where laser scanning combines with z-stepping to generate multi-channel datasets from labeled specimens, enhancing contrast in fluorescent signals across depths up to 100 μm. The primary output benefit of focus stacking in is the generation of volumetric data suitable for , transforming 2D image stacks into interactive models that facilitate of specimen and spatial relationships. By aligning and fusing slices, these stacks enable software-based reconstruction into rotatable 3D visualizations, such as surface-rendered models of cellular organelles or architectures, which support measurements like and with . This approach, rooted in early practices for depth extension, has become standard for creating publication-quality 3D representations in biological research.

Emerging Uses in Science and Medicine

In space exploration, focus stacking has been integral to imaging systems on NASA Mars rovers, enabling detailed analysis of rock surfaces and geological features. The Mars Hand Lens Imager (MAHLI) on the Curiosity rover, operational since 2012, incorporates onboard focus stacking to combine multiple images taken at varying focal depths, producing fully sharp images of microscopic textures on Martian rocks despite shallow depths of field as low as 1.6 mm. This capability extends to the Perseverance rover's SuperCam instrument, which uses precision focus stages for laser-induced breakdown spectroscopy on rocks, with focus stacking enhancing clarity for biosignature detection in samples collected since 2021. Such techniques support analysis of rover imagery for identifying potential organic compounds. In , focus stacking improves visualization in by extending for clearer internal views, particularly in gastrointestinal () procedures. A 2022 study demonstrated its use in noncontact dermoscopy, though adaptable to GI , where stacking 10-30 images creates hyper-focused renders of mucosal surfaces, reducing in curved anatomies. In neuroendoscopy, focus stacking has been applied since 2022 to capture all-in-focus images during surgical , enhancing diagnostic accuracy for lesions by combining shots across varying focal planes. For in surgical , focus stacking generates depth maps from z-stacks, enabling volumetric reconstructions of tissues; a 2021 method in multispectral used it to visualize thick samples in real-time during procedures, improving spatial understanding for tumor resection. Industrial applications leverage focus stacking for high-precision , notably in where defect at magnifications up to 1000× is critical. Basler's integrated focus stacking cameras capture multi-focal images of wafers to detect sub-micron defects like scratches or particles, combining them into extended-depth images without mechanical adjustments, thus boosting throughput in (AOI) systems. Similarly, SHIBUYA's 3D Vision Inspection System uses rotary heads to scan packages, identifying voids or misalignments by reconstructing sharp models from fringe projections. In forensics, focus stacking aids analysis by photographing small, irregular items like fibers or tool marks with full sharpness; guidelines from the Scientific for (SWGDE) in 2024 recommend it for , using 5-20 stacked images to document details unresolvable in single shots. Recent advancements from 2023 to 2025 integrate with focus stacking for real-time applications in vision, enabling dynamic depth extension in autonomous systems. A 2024 algorithm for microscopic vision uses a novel focus measure to select optimal slices from stacks, supporting robotic inspection of irregular surfaces like those in fabs or surgical robots. In intelligent vehicles and manipulators, liquid lens-based systems with processing, as described in 2025 research, perform adaptive focus stacking for high-resolution to support tasks. These developments, often built on neural networks for detection, facilitate seamless into robotic workflows, as evidenced by NVIDIA's 2025 R²D² framework for unified stacks.

Software and Implementation

Open-Source Tools

CombineZP, originally released in 2006 by developer Alan Hadley, is a Windows-based open-source tool for focus stacking that processes image stacks to produce extended depth-of-field composites. It operates under the GNU General Public License (GPL), allowing free modification and distribution, and includes features like depth mapping to generate focus distance visualizations from stacks. The software supports various alignment and blending methods, making it suitable for enthusiasts and researchers seeking customizable processing without cost barriers. While active development ceased around 2010, the software remains available for Windows users through archival sources. Hugin, a cross-platform open-source panorama stitching tool built on Panorama Tools (Panotools), extends to focus stacking through its integration of Enfuse for multi-image blending. Available under the GPL, Hugin facilitates stack alignment to correct for minor shifts between frames, which is essential before applying blending algorithms like those in Enfuse for seamless depth extension. It integrates with image editors such as , enabling workflows where aligned stacks are exported for further refinement, and supports , macOS, and Windows environments. This accessibility promotes community-driven enhancements, with the latest release Hugin 2025.0.0 (November 2025) introducing a browser for project files, GPano tags for cylindrical output, and bug fixes, alongside ongoing refinements to Enfuse blending capabilities in recent versions. For microscopy applications, Fiji—an enhanced distribution of the open-source ImageJ platform—offers plugins like Extended Depth of Field (EDF), which is Java-based and freely available for scientific use under a permissive license. The EDF plugin processes z-stacks from confocal or light to create in-focus composites and optional height maps, emphasizing accessibility for researchers in and . Developed by the Biomedical Imaging Group at EPFL, it runs on multiple platforms without installation fees, fostering collaborative development through its plugin ecosystem. The plugin remains available via the BIG-EPFL update site. Enfuse, often bundled with Hugin, has seen refinements in its blending capabilities through Hugin's recent releases. Community-driven GitHub repositories, such as focus-stack by Petteri Aimonen, provide additional open-source options for precise stacking without proprietary dependencies. These developments underscore the role of open-source software in democratizing focus stacking for both hobbyists and professionals.

Commercial Software

Commercial software for focus stacking provides polished, user-friendly interfaces with professional support, often integrating advanced algorithms for alignment, blending, and retouching tailored to photographers and microscopists. These tools typically require purchase or subscription and emphasize reliability for high-volume workflows, contrasting with open-source options by offering dedicated customer service and frequent updates. Helicon Focus, developed by Helicon Soft since its initial release in , is a dedicated focus stacking application available for both Windows and macOS platforms. It supports RAW file processing from various cameras and includes advanced retouching tools such as manual brush selection for fine-tuning blended areas, depth-of-field editing, and model export capabilities. The software employs methods like depth mapping and pyramid blending to handle complex stacks efficiently. Pricing includes a lifetime Pro license for $200, with options for Lite ($30/year) and Premium ($65/year) versions that add features like and remote camera control. Zerene Stacker, produced by Zerene Systems, specializes in high-fidelity stacking for and applications, supporting Windows, macOS, and . It features two primary algorithms: PMax (Pyramid Maximum), which prioritizes sharpness retention for natural-looking results, and DMap (), suitable for structured subjects with potential issues. The software excels in processing difficult stacks with motion artifacts or specular highlights, often producing superior detail in translucent or reflective specimens compared to general-purpose tools. Licenses range from $89 for the Personal Edition to $289 for the Professional Edition, with a 30-day free trial available. Adobe Photoshop and Lightroom incorporate focus stacking through built-in features since Photoshop CS6 in 2012, leveraging the Auto-Align Layers and Auto-Blend Layers tools for seamless integration into broader editing workflows. In Lightroom Classic, users select bracketed images and open them as layers in Photoshop, where the software automatically detects focus shifts and composites the sharpest regions while aligning for parallax. This process supports RAW files via Camera Raw integration and is optimized for non-destructive editing. Adobe's subscription model, via the Photography Plan, costs $19.99 per month for access to both applications, with cloud storage and mobile syncing included. Hardware-integrated solutions in commercial cameras enable focus bracketing directly in-device, simplifying acquisition for compatible lenses. Olympus and cameras, such as the and Lumix G9 II, support focus bracketing with up to 999 frames via firmware updates, including 2024 enhancements for extended sequences and in-camera stacking on select models. Canon's R5, introduced in 2020, offers focus bracketing with subsequent Depth Compositing in the included Digital Photo Professional software, allowing users to select and blend specific frames while cropping extraneous areas for precise control.

Advantages and Limitations

Key Benefits

Focus stacking provides an extended (DOF) that surpasses the limitations of single-exposure imaging, where shallow DOF often leaves parts of the subject blurred. By capturing a series of images at incrementally shifted focal planes and merging the in-focus regions, it produces composite images with uniform sharpness across the entire scene, enabling all-sharp results impossible with traditional methods. For example, in scenarios, this allows full clarity from an insect's eye to its wings, overcoming optical constraints inherent to magnifying lenses. A key advantage is the preservation of image sharpness, as focus stacking permits the use of wide apertures (such as f/5.6 to f/9) to maximize performance without invoking , which softens details when apertures are stopped down for greater DOF in single shots. This approach yields higher resolution and micro-contrast compared to stopped-down images, where typically dulls fine textures starting around f/9 on full-frame sensors. The method's versatility extends to advanced applications, such as generating 3D-like renderings and animations directly from the focal stacks, which can be rotated or sequenced into videos for dynamic . It also diminishes the need for specialized , like multi-camera rigs or stereoscopic setups, by leveraging a single fixed camera to derive depth maps and models from the stack data. Efficiency gains arise from automated processing, which streamlines workflows compared to manual techniques. Recent advancements as of 2025, including AI-assisted tools in software like ON1 Photo RAW and , further optimize blending to reduce noise and ensure coverage while minimizing processing time.

Technical Challenges

One significant technical challenge in focus stacking is the emergence of artifacts during image blending, particularly ghosting and halos. Ghosting often arises from subject movement between frames, such as wind-induced swaying of foliage or fine structures like insect hairs in macro shots, resulting in blurred or duplicated elements in the composite. Halos, conversely, manifest as bright or dark edges around high-contrast boundaries, commonly observed in software like CombineZP and Zerene Stacker when processing stacks with intricate details, such as the reflective elytra of beetles. These artifacts degrade image quality and require extensive manual retouching, especially in field conditions where environmental motion exacerbates the issue. Processing demands pose another hurdle, as focus stacking involves computationally intensive and blending of multiple high-resolution . For a typical 50-image stack, and blending can take seconds to several minutes on standard , depending on and software ; larger stacks or older systems may extend times further. requirements are substantial for high-resolution DSLR files (e.g., 20 MB RAW each), quickly overwhelming systems during layer-based processing in tools like Photoshop. AI enhancements in recent software help mitigate these demands by improving accuracy and reducing computation time. Alignment errors, including parallax shifts, complicate workflows, particularly in non-macro setups. occurs with ordinary due to perspective changes as the focus plane shifts, causing misalignment where foreground and background elements appear to move relative to each other across frames; this is pronounced beyond close-up distances without telecentric lenses. Precise focusing rails, such as those enabling 0.01 mm steps over depths like 3.75 mm, are essential to minimize these errors, but even minor vibrations or imprecise stepping can lead to visible distortions in the final stack. Focus stacking is inherently limited for moving subjects, as any motion—such as affecting leaves or branches in landscapes—produces inconsistencies across frames, yielding double images or blur halos that demand significant post-processing. bloat is also a practical constraint, with a 25-image stack of 8256×5504 files (10 each) generating intermediates exceeding 250 , and final outputs from 6–20 frames often reaching 120–500 or more due to layered blending, straining and editing capabilities.

Examples and Illustrations

Photographic and Microscopic Images

In , focus stacking enables the capture of intricate details across subjects with shallow , such as . A notable example is a stacked image of a tachinid fly ( family) from , captured using a Canon 7D camera with a Canon MP-E 65mm lens at f/14 and combined from six images in Helicon Focus software, resulting in exceptional sharpness from the fly's head to its , contrasting sharply with single-frame shots where only portions, like the eyes or wings, remain in due to limited . For , focus stacking extends sharpness across expansive scenes with varying distances. An illustrative composite involves a mountain vista, such as , where multiple tripod-mounted exposures—focused sequentially on foreground elements like rocks and flowers, midground vegetation, and distant peaks—are blended to produce an image sharp from the nearest details to the horizon, overcoming the trade-offs of choices that blur either the foreground or background in single exposures. In microscopic imaging, focus stacking reveals fine structures in translucent or three-dimensional specimens. For instance, a stack of a Biddulphia , acquired at 50x magnification with a objective and processed in Helicon Focus, uncovers the intricate silica frustules and ornate patterns across the cell's depth, which appear fragmented or obscured in individual slices due to the microscope's narrow . Similarly, in biological cell imaging, z-stacking of cocultured MDA-MB-231 tumor cells (GFP-labeled) and fibroblasts (RFP-labeled) in a , stained with Hoechst 33342 for nuclei and captured at 4x objective with 53 μm steps using Agilent BioTek Cytation systems, yields a projected image with clarity from the nuclear cores through the cytoplasmic membranes and , surpassing the partial focus of any single z-plane. Beyond Earth-based applications, focus stacking has been employed in extraterrestrial exploration. NASA's Curiosity rover utilized its Mars Hand Lens Imager (MAHLI) to produce a focus-stacked image of its first drill hole in the John Klein rock at Yellowknife Bay in February 2013, combining multiple frames at varying focus distances to achieve detailed views of the 1.6 cm diameter and 6.7 cm deep borehole's walls and surrounding sediment, demonstrating the technique's utility for analyzing Martian geology where depth of field is constrained by the instrument's design. More recently, in 2024, NASA's OSIRIS-REx mission applied focus stacking to image the returned asteroid samples from Bennu, merging multiple frames to create hyper-detailed views of the regolith particles, revealing fine textures and compositions essential for understanding solar system origins. In advanced scientific applications, focus stacking enhances in particle . A 2024 study demonstrated its use in single-event particle radiography to stack images for of dense objects, improving resolution beyond traditional methods and enabling detailed internal structure analysis in .

Process Diagrams

Process diagrams in focus stacking visually represent the sequential steps of capture, , focus detection, blending, and rendering, providing a clear overview for both photographic and microscopic applications. These illustrations often employ flowcharts, schematics, and layered representations to highlight the technical progression from raw stacks to composite outputs, emphasizing precision in depth control. The acquisition diagram typically appears as a flowchart outlining the initial capture phase, where multiple images are taken at incremental focus positions to cover the subject's depth range. In microscopy setups, this involves a variable focus lens (VFL) integrated with the camera at the trinocular port, with focal power adjusted linearly via current (e.g., from -2 to +13 diopters) to generate images at high frame rates like 60 Hz. The number of images (N) is determined by dividing the specimen height by the objective's depth of field (DOF), such as 25 images for a 1,118 µm height with a 44 µm DOF, ensuring overlap between steps from initial current I₀ to final I₄. Rail movement is often absent in such systems to maintain constant subject-to-objective distance, though motorized rails may be depicted in macro photography variants for precise z-axis shifts. Exposure settings, while not always diagrammed explicitly, are synchronized with focus changes to minimize motion artifacts. Detection and blending schematics illustrate the post-acquisition analysis, showing layered input images from the focal stack alongside focus maps and the resulting composite. A common representation displays input slices {I₁, I₂, I₃} at depths {Z₁, Z₂, Z₃}, where focus measures (visualized in ) identify sharp regions per image, followed by defocus estimation (e.g., orange hues indicating extent). The blending merges these, creating a before-and-after view: the "before" reveals individual in-focus bands, while the "after" composite exhibits extended DOF with all regions sharp, though preliminary blends may show artifacts at depth transitions. Blending coefficients (λᵢ) and focus indicators (αᵢ) are mapped pixel-wise to weight contributions, ensuring seamless across the stack. Alignment illustrations, often rendered as vector diagrams, depict parallax correction through feature matching to compensate for shifts between stack images due to lens geometry. These show a linear sensor position change contrasting with non-linear object distance variations, incorporating lateral magnification and affine transformations (e.g., \tilde{P} = K \begin{pmatrix} h^T - h^T C_0 & v^T - v^T C_0 & (0, 0, d) \end{pmatrix}) to align sub-images into a perpendicular projection. Feature points, such as chessboard corners, are matched across the stack to refine sub-pixel accuracy, removing perspective distortions and enabling halo-free compositing by blocking erroneous foreground rays. Blur spot radius (C) is modeled geometrically based on sensor distance deviations (S vs. Ŝ) and aperture (A), guiding correction vectors. In stack visualizations, particularly for , diagrams portray s derived from z-stacks leading to volumetric renders, transforming 2D focal planes into spatial models. A (e.g., dark tones for closer regions) is generated via Gaussian of measures across planes spaced by 10 µm, estimating relative depths like 33 µm or 45 µm for overlapping structures. The flows from individual slices to a representation merging detections, then to full graphs of filamentous samples (e.g., fungi), viewed from multiple angles to reveal topological details. Volumetric rendering connects points into coordinates, extending DOF and enabling reconstructions homeomorphic to models.

References

  1. [1]
    Focus Shift Ⅰ, the Basics: Stacking Focus - D850 - Consumer - Nikon
    Focus stacking is a means enhancing depth of field by taking a series of shots and generating a composite image consisting only of the areas that are in focus.Missing: explained | Show results with:explained
  2. [2]
    FocusALL: Focal Stacking of Microscopic Images Using ... - NIH
    Focal stacking is a method of generating a focused image from images captured at varying depths of field by fusing in-focus areas. The objective is to generate ...
  3. [3]
    Focus Stacking: The Ultimate Guide (With Step-By-Step Instructions)
    Focus stacking is a technique designed to achieve a deep depth of field by blending (or stacking) several images together. Each stacked shot is focused in a ...
  4. [4]
    Focus on Everything | American Scientist
    A photo processing technique called focus stacking has changed that. Developed as a tool to electronically combine the sharpest bits of multiple digital images, ...
  5. [5]
    Focus Shift, the Basics: Stacking Focus - Nikon
    The number of shots can be set to values between 1 and 300. You'll generally need over a hundred shots to cover the desired field depth when photographing an ...
  6. [6]
    [PDF] Focal Stack Compositing for Depth of Field Control
    Focal stack compositing combines images focused at different depths to simulate depth of field effects, including reduction, extension, and non-physical ...
  7. [7]
    [PDF] High-Performance Photography with a Conventional Camera
    A focal stack is a sequence of photos taken with distinct focus settings and possibly different apertures. Just like an individual photo has a well-defined expo ...
  8. [8]
    [PDF] Overcoming the Diffraction-Limited Spatio-Angular Resolution Tradeoff
    The large aperture preserves high diffraction-limited reso- lution, but creates a shallow depth of field, hence out-of- focus blur. The smaller apertures ...
  9. [9]
    [PDF] lenses and apertures - Stanford Computer Graphics Laboratory
    Apr 8, 2014 · • depth of field is linear in some terms and quadratic in others. • if you focus at the hyperfocal distance H = f 2 / NC, everything from H ...
  10. [10]
    [PDF] Defocus & Depth of field - MIT
    Although the camera does not take a "second look" to see if the intended focus has been achieved, the lens does take a "second look" to ensure it has moved the.
  11. [11]
    Numerical Aperture and Resolution
    ### Summary of Numerical Aperture (NA) and Depth of Field
  12. [12]
    [PDF] Chapter 7 Lenses
    (The equations are Depth of focus = magnification squared X resolving power / NA; Depth of field = wavelength / NA squared).
  13. [13]
    [PDF] Extended depth of field through wave-front coding
    This combined optical–digital system pro- duces a PSF that is comparable to that of the diffrac- tion-limited PSF but over a far larger region of focus. We ...
  14. [14]
    [PDF] Light Field Photography with a Hand-held Plenoptic Camera
    Deconvolution of these images retrieves image detail at all depths. While their results in producing extended depth of field images is compelling, our design ...
  15. [15]
    Confocal Microscopy: Principles and Modern Practices - PMC
    To collect a z-stack, the focal point is changed, and the scanning process repeated over the new slice; an example of several slices of a z-stack is shown in ...
  16. [16]
    Robust autofocusing in microscopy - PubMed
    Jan 1, 2000 · This report describes a robust and fast autofocus approach useful for a wide range of microscopic modalities and preparations. Methods: The ...
  17. [17]
    Improved depth of field in the scanning electron microscope derived ...
    Aug 5, 2025 · The depth of field limit in the scanning electron microscope (SEM) can be overcome by recording stacks of through-focus images (as in ...
  18. [18]
    Microscopy Basics | Understanding Digital Imaging - Zeiss Campus
    Between 1970 and 1980 researchers coupled tube based video cameras with microscopes to produce time lapse image sequences and real-time videos. In the 1990s ...
  19. [19]
    [PDF] CombineZM Help
    Where possible please make sure you have the latest version by checking the date in the 'About Box', the latest version is dated 20th of December 2006. For ...Missing: Combine ZM
  20. [20]
    What is focus stacking?
    It consists of taking pictures of the different depth planes that form the scene; then, either by hand (serious work) or via software, keep only the focused ...
  21. [21]
    Curiosity's Mars Hand Lens Imager (MAHLI) Investigation
    Jul 5, 2012 · Perform an onboard focus merge and minimize rotation between images in a focus stack, so as to provide options for reduced downlink data volume ...
  22. [22]
    First Sampling Hole in Mount Sharp
    Sep 25, 2014 · The hole is 0.63 inch (1.6 centimeters) in diameter and about 2.6 inches (6.7 centimeters) deep, at a target called "Confidence Hills" on ...Missing: stacking | Show results with:stacking
  23. [23]
    FOCUS STACKING & BRACKETING WITH OM-D
    The focus stacking feature will shoot the set number of photos at the designated focus differential and then merge them into one jpeg file at full resolution.
  24. [24]
    AI and the iPhone 15: Photography's Brownie Camera Moment
    Oct 13, 2023 · Apple's iPhone 15 uses AI to shape every photo. Is it the new Brownie camera—simple snapshots, or a step away from true photography?
  25. [25]
    None
    Summary of each segment:
  26. [26]
    [PDF] A Rapid Image Acquisition Method for Focus Stacking in Microscopy
    The DOF of a lens system and the height of a specimen determine the minimum number of images required to obtain an all-in-focus image.
  27. [27]
    None
    ### Summary of Image Acquisition for Focus Stacking
  28. [28]
    [PDF] Focus Stacking Images of Morphological Character States for ...
    Although most images vary, generally a distance-per-step of. 75–150 μm and a camera f-stop of 5.6 allowed for enough overlap for all parts of the final image ...
  29. [29]
  30. [30]
    [PDF] Distinctive Image Features from Scale-Invariant Keypoints
    Jan 5, 2004 · This paper presents a method for extracting distinctive invariant features from images that can be used to perform reliable matching between ...Missing: alignment | Show results with:alignment
  31. [31]
    Focus Shift, the Basics: Stacking Focus - Tips & Techniques | Nikon USA
    ### Summary of In-Camera Focus Bracketing in Nikon Since 2018
  32. [32]
    How to Focus Stack Images - Photography Life
    Jul 8, 2019 · Focus stacking is a technique that can be beneficial when a photographer wants to extend the apparent depth-of-field of an image.<|separator|>
  33. [33]
    Focus Stacking in Macro Photography - DPReview
    Apr 11, 2013 · In this article, nature photographer Erez Marom explains the technique of focus stacking and shows its implementation in Photoshop.
  34. [34]
    Focus Stacking Tutorial for Landscape Photography
    Aug 2, 2023 · Focus stacking lets you take several photos of a landscape, focused at different points, and combine them together into the sharpest possible image.
  35. [35]
    Focus Stacking in Landscape Photography
    In this guide about focus stacking in landscape photography, I show you how focus stacking works in the field and how to stack photos during photo editing.
  36. [36]
    Focus stacking in Canon cameras
    Enable Focus bracketing from your camera's menu and set the number of images to be captured. The focus increment value can be increased when the subject is ...
  37. [37]
    In photos: The beauty of bees: Digital Photography Review
    Dec 28, 2013 · They shoot multiple images on a Cognisys StackShot Rail and then combine them to create a picture of a bee completely in focus. Check out a ...
  38. [38]
    Plasma Membrane Sterol Distribution Resembles the Surface ...
    J774 cells were labeled for 5 min with DHE/MCD, washed, and imaged in z-stacking modus with planes being 0.5 μm apart. (A) individual planes of a J774 cell ...
  39. [39]
    3D volumetric microscopy of thick scattering samples using a ... - NIH
    The focus setting of the microscope can be slowly changed from the top to the bottom of the tissue sample to obtain a low-contrast image stack. Each image can ...
  40. [40]
    Insight into diatom frustule structures using various imaging ... - Nature
    Jul 15, 2021 · Imaging of diatoms applying visible light, electron and X-ray microscopy provide a deeper insight into the morphology of their frustules.
  41. [41]
    The Automatic Microscope | Nikon's MicroscopyU
    Focus motors are attached to the fine focus transmission gearset of a microscope to enable automated axial focus control through the image acquisition software.Figure 3 - Filter Wheel And... · Figure 5 - Precision... · Figure 8 - High-Performance...
  42. [42]
    a practical approach to volume rendering from serial sections
    Apr 21, 2010 · We provide a set of protocols for acquiring high-resolution 3D images of diverse microscopic samples through volume rendering based on serial light ...
  43. [43]
    MAHLI for Scientists | MAHLI – NASA Mars Exploration
    The Mars Hand Lens Imager (MAHLI) is a focusable color camera located on the turret at the end of the MSL robotic arm. The instrument acquires images of up ...<|separator|>
  44. [44]
    Curious about Curiosity? Here's the tech behind NASA's Mars rover ...
    Aug 9, 2012 · MAHLI has a very shallow depth-of-field of just 1.6mm at macro, and so offers an onboard focus stacking function that can combine the best ...
  45. [45]
    Small Motion Steps Yield Big Effects in the Quest for Life on Mars
    Precision motion control, including focus stages and piezo actuators, enables the SuperCam to examine rocks for organic compounds and control laser focus for ...
  46. [46]
    NASA's Perseverance Mars Rover Studies Trove of Rocks on Crater ...
    Apr 10, 2025 · Since January, the rover has cored five rocks on the rim, sealing samples from three of them in sample tubes. It's also performed up-close ...
  47. [47]
    Workflow for focus stacking. The focus measure is visualized in...
    Conclusions The focus stacking–based approach for noncontact dermoscopy improves the quality of diagnostic images by ensuring an all-in-focus view of ...
  48. [48]
    Pursuing perfect 2D and 3D photography in neuroanatomy
    Oct 28, 2022 · Another technique that is widely used in microphotography is focus stacking. This digital technology is designed to achieve a greater depth of ...
  49. [49]
    Focus stacking and 3D visualization in multispectral microscopy of ...
    A custom built fluorescence microscope with an electrically tunable lens is used to acquire multi-focus z-stacks of thick biological samples under multispectral ...Missing: surgical | Show results with:surgical
  50. [50]
    Integrated Focus Stacking Solution Delivering Extended Depth of ...
    Focus stacking extends the depth of field by capturing multiple images at different focal positions and combining their sharpest regions into a single image ...
  51. [51]
    3D Vision Inspection System|SHIBUYA CORPORATION
    The inspection unit and software can be customized according to applications. Rotary type inspection head. Rotary type inspection sample. Focus Stacking High- ...
  52. [52]
    [PDF] Guidelines for the Use of Macro Photography in Forensic Science
    Aug 5, 2024 · Whenever possible, evidence should be ... • Focus Stacking is a technique of taking multiple photographs of the same subject at.
  53. [53]
    Focus stacking technique in identification of forensically important ...
    Focus stacking software is one of photographing software that allows a combination of pictures with multiple depths of field to get the whole object in focus.
  54. [54]
    A novel focus measure algorithm for three-dimensional microscopic ...
    Oct 1, 2024 · A focus stacking microscopic measurement system is constructed to validate the proposed focus measure function. Six classical and latest focus ...
  55. [55]
    High-resolution imaging system for integration into intelligent ...
    Sep 8, 2025 · A liquid lens, essential for adaptive focus stacking and precise imaging, is priced at 1500 €. The high-speed network card, required for real- ...
  56. [56]
    R²D²: Building AI-based 3D Robot Perception and Mapping with ...
    Jun 17, 2025 · R 2 D 2 explores several perception models and systems from NVIDIA Research that support a unified 3D perception stack for robotics.
  57. [57]
    Vincentdecursay/CombineZP - GitHub
    ... stacking.html (26/08/2011). Compiled version found here: https://combinezp.software.informer.com/download/ Version: 1.0 (x86) Date update: Jan 27, 2012. File ...
  58. [58]
    Hugin - Panorama photo stitcher
    Hugin is a cross-platform tool to assemble mosaics of photos into panoramas and stitch overlapping pictures. It is recommended for general use.Hugin Download · Hugin Tutorials · Hugin Documentation · ScreenshotsMissing: focus | Show results with:focus
  59. [59]
    Align a stack of photos - PanoTools.org Wiki - Hugin
    Aligning photos taken at different focus distances to merge into a single extended Depth of Field image. Panorama tools is particularly useful for this ...Missing: open source
  60. [60]
    Hugin-2024.0.0 release notes
    Hugin-2024.0.0 Release Notes. Hugin is more than just a panorama stitcher. Changes since 2023.0.0. Added browser for project files to Hugin.Upgrading · Known Issues · Download
  61. [61]
    Extended Depth of Field
    Aug 12, 2025 · This plugin provides an extended depth of field algorithm to obtain in focus microscopic images of 3D objects and organisms using different ...
  62. [62]
    BIG > Extended Depth of Field - Biomedical Imaging Group
    Launch ImageJ and open an image stack. Select "Plugins > Extended Depth of Field > Easy mode..." for a simplified user interface, or "Expert mode..." for ...
  63. [63]
    Biomedical-Imaging-Group/EDF-Extended-Depth-of-Field - GitHub
    The idea is to merge a stack of micrographs taken at different focal positions (aligned along the optical axis) into a single, entirely focused composite image.
  64. [64]
    Hugin-2023.0.0 release notes
    Hugin is more than just a panorama stitcher. Changes since 2022.0.0. PTBatcherGUI can now also queue user defined assistant and user defined output sequences.Upgrading · Known Issues · Download
  65. [65]
    Fast and easy focus stacking - GitHub
    This project implements a cross-platform tool for focus stacking images. The application takes a set of images captured at different focus distances and ...Installation · Basic Usage · Building On LinuxMissing: Enfuse 2023 2024
  66. [66]
    Helicon Focus Licenses
    Helicon Focus Premium package · 1 year license. $30 · 1 year license. $55 · 1 year license. $65.
  67. [67]
    Zerene Stacker — Purchasing Licenses
    Jan 2, 2025 · Professional Edition, $289 USD · Prosumer Edition, $189 USD · Personal Edition, $89 USD · Student Edition, $39 USD · Upgrade, any levels, email ...
  68. [68]
    An In-Depth Guide to Focus Bracketing - Panasonic UK & Ireland
    The focus bracketing mode automatically shoots a series of images at a range of different focus positions so that we don't have to shift the focus ourselves.
  69. [69]
    Focus Bracketing - Product Manual : EOS R5 Mark II - Canon
    Focus bracketing enables continuous shooting with the focal distance changed automatically after each shot. These images enable you to create a single image ...
  70. [70]
    Depth of Field Challenges: Bypass the Limits with Focus Stacking ...
    Aug 3, 2016 · Focus stacking sidesteps the limits on depth of field while also avoiding the dulling effects of diffraction. With a bit more effort than a ...
  71. [71]
    Focus stacking: Comparing commercial top-end set-ups with a semi ...
    In this manuscript we present a focus stacking system, composed of commercial photographic equipment. The system is inexpensive compared to high-end commercial ...
  72. [72]
    [PDF] The Art of Successful Focus Stacking - Zerene Stacker
    Sep 29, 2016 · Telecentric Optics Have No Parallax. Ordinary Optics. Telecentric Optics. Page 58. Telecentric Optics Have No Parallax. Ordinary Optics.<|separator|>
  73. [73]
    An Excellent Free and Open Source focus-stacking solution
    Apr 29, 2024 · Focus-stack is free, and while it's a bit slower, it's easy to batch process while you go get a coffee, and in my opinion the outputs are just as good.
  74. [74]
    Focus stacking of live subjects - The Smaller Majority
    Aug 21, 2012 · Component images used to produce the stacked-focus image of a tachinid fly. I shoot for focus stacking mostly using a featureless white or ...
  75. [75]
    Focus Stacking Landscape Scenes - Zerene Stacker
    Some scenes just beg to be sharp everywhere, but have too much depth to make that possible in a single shot. Here's an example: mountrainierfinal.jpg
  76. [76]
    Enhancing depth of field by combining image stacks
    Stacking combines images taken at different focal planes to create a single image with great depth of field, by selecting sharply focused parts.
  77. [77]
    None
    ### Summary of Biological Cell Focus Stacking Example
  78. [78]
    Illustration of the multifocus imaging technique. The images at left...
    The image pairs at right are the focus indicator map α i (top) and the blending coefficient map λ i (bottom) for the frame at left. The larger image at bottom ...
  79. [79]
    [PDF] MaCal – Macro Lens Calibration and the Focus Stack Camera Model
    Computational photog- raphy methods such as focus stacking combine the sharp ar- eas of many photos into one, which can produce spectacular images of insects ...
  80. [80]
    Three-dimensional graph reconstruction of filamentous structures ...
    Brightfield microscopy Z-stacks is one of the simplest techniques for imaging samples characterized by a given depth, and it consists of acquiring images at ...