
Focus stackingalso called focal plane merging, z-stacking, focus bracketing or focus blendingis a
digital image processing
Digital image processing is the use of a digital computer to process digital images through an algorithm. As a subcategory or field of digital signal processing, digital image processing has many advantages over analog image processing. It allo ...
technique which combines multiple images taken at different
focus
Focus (: foci or focuses) may refer to:
Arts
* Focus or Focus Festival, former name of the Adelaide Fringe arts festival in East Australia Film
*Focus (2001 film), ''Focus'' (2001 film), a 2001 film based on the Arthur Miller novel
*Focus (2015 ...
distances to give a resulting image with a greater
depth of field
The depth of field (DOF) is the distance between the nearest and the farthest objects that are in acceptably sharp focus (optics), focus in an image captured with a camera. See also the closely related depth of focus.
Factors affecting depth ...
(DOF) than any of the individual source images. Focus stacking can be used in any situation where individual images have a very shallow depth of field;
macro photography
Macro photography (or photomacrography or macrography, and sometimes macrophotography) is extreme close-up photography, usually of very small subjects and living organisms like insects, in which the size of the subject in the photograph is g ...
and
optical microscopy
Optics is the branch of physics that studies the behaviour and properties of light, including its interactions with matter and the construction of instruments that use or detect it. Optics usually describes the behaviour of visible, ultravio ...
are two typical examples. Focus stacking can also be useful in
landscape photography
Landscape photography (often shortened to landscape photos) captures the world's outdoor spaces, sometimes vast and unending and other times microscopic. Landscape photographs typically capture the presence of nature but can also focus on human-ma ...
.
Focus stacking offers flexibility: since it is a computational technique, images with several different depths of field can be generated in post-processing and compared for best artistic merit or scientific clarity. Focus stacking also allows generation of images physically impossible with normal imaging equipment; images with nonplanar focus regions can be generated. Alternative techniques for generating images with increased or flexible depth of field include
wavefront coding
In optics and signal processing, wavefront coding refers to the use of a phase modulating element in conjunction with deconvolution to extend the depth of field of a digital imaging system such as a video camera.
Wavefront coding falls under the ...
,
light-field camera
A light field camera, also known as a plenoptic camera, is a camera that captures information about the ''light field'' emanating from a scene; that is, the intensity of light in a scene, and also the precise direction that the light rays are tr ...
s and
tilt.
Technique
The starting point for focus stacking is a series of images captured at different focus distances; in each image different areas of the sample will be in focus. While none of these images has the sample entirely in focus they collectively contain all the data required to generate an image which has all parts of the sample in focus. In-focus regions of each image may be detected automatically, for example via
edge detection
Edge or EDGE may refer to:
Technology Computing
* Edge computing, a network load-balancing system
* Edge device, an entry point to a computer network
* Adobe Edge, a graphical development application
* Microsoft Edge, a web browser developed b ...
or
Fourier analysis
In mathematics, Fourier analysis () is the study of the way general functions may be represented or approximated by sums of simpler trigonometric functions. Fourier analysis grew from the study of Fourier series, and is named after Joseph Fo ...
, or selected manually. The in-focus patches are then blended together to generate the final image.
This processing is also called z-stacking, focal plane merging (or in French).
In photography
Getting sufficient
depth of field
The depth of field (DOF) is the distance between the nearest and the farthest objects that are in acceptably sharp focus (optics), focus in an image captured with a camera. See also the closely related depth of focus.
Factors affecting depth ...
can be particularly challenging in
macro photography
Macro photography (or photomacrography or macrography, and sometimes macrophotography) is extreme close-up photography, usually of very small subjects and living organisms like insects, in which the size of the subject in the photograph is g ...
, because depth of field is smaller (shallower) for objects nearer the camera, so if a small object fills the frame, it is often so close that its entire depth cannot be in focus at once. Depth of field is normally increased by
stopping down aperture
In optics, the aperture of an optical system (including a system consisting of a single lens) is the hole or opening that primarily limits light propagated through the system. More specifically, the entrance pupil as the front side image o ...
(using a larger
f-number
An f-number is a measure of the light-gathering ability of an optical system such as a camera lens. It is calculated by dividing the system's focal length by the diameter of the entrance pupil ("clear aperture").Smith, Warren ''Modern Optical ...
), but beyond a certain point, stopping down causes
blurring due to diffraction, which counteracts the benefit of being in
focus
Focus (: foci or focuses) may refer to:
Arts
* Focus or Focus Festival, former name of the Adelaide Fringe arts festival in East Australia Film
*Focus (2001 film), ''Focus'' (2001 film), a 2001 film based on the Arthur Miller novel
*Focus (2015 ...
. It also reduces the luminosity of the image. Focus stacking allows the depth of field of images taken at the sharpest aperture to be effectively increased. The images at right illustrate the increase in DOF that can be achieved by combining multiple exposures.

The
Mars Science Laboratory
Mars Science Laboratory (MSL) is a robotic spacecraft, robotic space probe mission to Mars launched by NASA on November 26, 2011, which successfully landed ''Curiosity (rover), Curiosity'', a Mars rover, in Gale (crater), Gale Crater on Augus ...
mission has a device called
Mars Hand Lens Imager
Mars Hand Lens Imager (MAHLI) is one of seventeen cameras on the ''Curiosity'' rover on the Mars Science Laboratory mission.
Overview
The instrument is mounted on the rover's robotic arm. It is primarily used to acquire microscopic images o ...
(MAHLI), which can take photos that can later be focus stacked.
In microscopy
In
microscopy
Microscopy is the technical field of using microscopes to view subjects too small to be seen with the naked eye (objects that are not within the resolution range of the normal eye). There are three well-known branches of microscopy: optical mic ...
, high
numerical aperture
In optics, the numerical aperture (NA) of an optical system is a dimensionless number that characterizes the range of angles over which the system can accept or emit light. By incorporating index of refraction in its definition, has the property ...
s are desirable to capture as much light as possible from a small sample. A high numerical aperture (equivalent to a low f-number) gives a very shallow depth of field. Higher magnification
objective lens
In optical engineering, an objective is an optical element that gathers light from an object being observed and focuses the light rays from it to produce a real image of the object. Objectives can be a single lens or mirror, or combinations of ...
es generally have shallower depth of field; a 100×
objective lens
In optical engineering, an objective is an optical element that gathers light from an object being observed and focuses the light rays from it to produce a real image of the object. Objectives can be a single lens or mirror, or combinations of ...
with a numerical aperture of around 1.4 has a depth of field of approximately 1
μm
The micrometre (Commonwealth English as used by the International Bureau of Weights and Measures; SI symbol: μm) or micrometer (American English), also commonly known by the non-SI term micron, is a unit of length in the International System ...
. When observing a sample directly, the limitations of the shallow depth of field are easy to circumvent by focusing up and down through the sample; to effectively present microscopy data of a complex 3D structure in 2D, focus stacking is a very useful technique.
Atomic resolution
encounters similar difficulties, where specimen features are much larger than the depth of field. By taking a
through-focal series, the depth of focus can be reconstructed to create a single image entirely in focus.
Software/application
Gallery
Pictures
File:Zassenhaus pepper mill - underside view - grinder (2019-08-06).jpg , Pepper mill, stack of 28 frames
File:Electric guide 3×2.5 mm.jpg , Stacked image of 3 × 2.5 mm electric wires
File:Philips Series 7000 shaver head.jpg , Shaver head, stack of 36 frames, retouched
File:Macrolepiota procera Parasol -20191014-RM-165319.jpg , '' Macrolepiota procera'', stack of 15 frames
File:Orchideenblüte 2019-05-22 11-34-28 (C)-PSD.jpg , Stacked image of the inner ridge of an orchid blossom
File:Two Arecaceae in the fields viewed through a hole in a tree trunk in Laos at golden hour.jpg , Stacked image of two ''Arecaceae
The Arecaceae () is a family (biology), family of perennial plant, perennial, flowering plants in the Monocotyledon, monocot order Arecales. Their growth form can be climbing palm, climbers, shrubs, tree-like and stemless plants, all commonly k ...
'' viewed through a hole in a tree trunk
File:2013-06-07 14-57-13-bille-32f.JPG , Pellet, stack of 32 frames
File:2016-01-06 14-51-04 parc-tete-or 10f.jpg , '' Alluaudia comosa'', stack of 10 frames
File:2013-12-28 19-51-33 Litchi-20f.jpg , Mold on ''Litchi chinensis
Lychee ( , ; ''Litchi chinensis''; ) is a monotypic taxon and the sole member in the genus ''Litchi'' in the Sapindus, soapberry family, Sapindaceae.
There are three distinct subspecies of lychee. The most common is the Indochinese lychee fo ...
'', stack of 20 frames
File:Skull (front) - Dolmen de Marie Gaillard MHNT ANT 2017 0 54.jpg , Skull, stack of 6 frames
File:Sympetrum flaveolum male - Kulna.jpg, Sympetrum flaveolum male, stack of 36 frames
File:Pinot_Grigio-20201027-RM-114053.jpg, Pinot Gris
Pinot gris, pinot grigio (, ), or ''Grauburgunder'' is a white wine grape variety of the species ''Vitis vinifera''. Thought to be a mutant clone of the pinot noir variety, it normally has a pinkish-gray hue, accounting for its name, but th ...
grape, stack of 12 frames.
Videos
File:Hindesite - Lily - Focus Stacking (by).ogv, Focus stacking images of a lily
File:Focus stacking NEC USB chip imgp0017 wp.ogv, Focus stacking images of a microchip
Diagrams
File:Stack and Stitch Illustration.png , Software creates from the sharpest areas in a stack of sections.
See also
*
Brenizer Method
*
Deep focus
Deep focus is a photographic and cinematographic technique using a large depth of field. Depth of field is the front-to-back range of focus (optics), focus in an image, or how much of it appears sharp and clear. In deep focus, the foreground, midd ...
*
Epsilon photography
Epsilon photography is a form of computational photography wherein multiple images are captured with slightly varying camera parameters (each image varying the parameter by a small amount ''ε'', hence the name) such as aperture, exposure, focus, ...
*
Focus bracketing
In photography, bracketing is the general technique of taking several shots of the same subject using different camera settings, typically with the aim of combining the images in postprocessing. Bracketing is useful and often recommended in situ ...
*
Frazier lens
*
High dynamic range imaging
High dynamic range (HDR), also known as wide dynamic range, extended dynamic range, or expanded dynamic range, is a signal with a higher dynamic range than usual.
The term is often used in discussing the dynamic ranges of images, videos, audio or ...
(HDR)
*
Image stitching
Image stitching or photo stitching is the process of combining multiple photographic images with overlapping fields of view to produce a segmented panorama or high-resolution image. Commonly performed through the use of computer software, most ap ...
*
Image fusion
The image fusion process is defined as gathering all the important information from multiple images, and their inclusion into fewer images, usually a single one. This single image is more informative and accurate than any single source image, and i ...
*
*
Shift-and-add for stacking astrophotos
References
* Ray, Sidney. 2002. ''Applied Photographic Optics''. 3rd ed. Oxford: Focal Press. .
External links
{{Commons category, Focus stacking
Which cameras have built-in focus stacking?by Jeff Meyer, ''Camera Jabber'' Nov. 2019.
Articles containing video clips
Image processing
Photographic techniques