by Dr. Robert Berdan
August 12, 2017
Above is a Focus stack of a diatom where I combined 10 images in Photoshop 400X
A focus stack is a photograph that is made up of a combination of two or more images that were focused at different points and then after combining the stacks the final image has a much greater depth of field. Stacking is done in software using the digital images. Stacking can be used in landscape photography by combining a photograph focused on the foreground and one focused on the background to create an incredible depth of field that exceeds what could be done using a very high F-stop (F16-F64), using a tilt-shift lens, or even a large format camera. In macro and photomicrography the closer one is to the subject or the higher the magnification the shallower the depth of field. In macrophotography the depth of field can be less than a millimetre and in microscopy the depth of field is measured in microns (thousands of a millimetre). The depth of field can be as small as 1-2 microns at magnifications of 400x and higher with a microscope. The subject depth and magnification determines how many images you need in a stack to get a sharp picture with enhanced depth of field. It is not uncommon to see some photographers use 40-100 stacked images in macro and photomicrography. Stacking is also used in product photography like jewellery or any place where it is essential that the entire subject be sharp and in focus. In this article I will compare three popular programs used for Focus stacking: Photoshop, Helicon Focus and Zerene stacker.
Diatoms - Photoshop stack of 12 images, Negative Phase contrast microscopy, 200X
For landscape photography the good news is that generally you only need 2 photos, one focused on the foreground and the other on the distant horizon. You can use the lens at F5.6-F11 where the lens provides the sharpest image and has an intermediate depth of field. Beyond F11 an image begins to lose sharpness due to diffraction of light. If you are only going to take one shot of a landscape and want maximum depth of field we often shoot at F11-F22 and focus at the hyperfocal point, but by stacking several images you can achieve greater depth and sharper images. Below is a simple demonstration.
Above I took two photographs 1) focused on the card and my hand, note the distant mountain is blurred 2) focused on the distant mountain, note my hand and card is blurred 3) Combined stack of the first two images in Photoshop now both the card and mountain are sharp and in focus. You could not achieve this using any F-stop as the card was only a few inches from my face. I hand held these shots but I recommend that you use a tripod. Photoshop is able to align images that are not in perfect alignment but I get better results by using a tripod. After stacking you may have to "fix" some areas of the image that don't blend perfectly - usually near edges.
Above is a two image focus stack from a scene in the Blaeberry Valley, BC. The two images were stacked in Photoshop, each image was taken at F16, 1\50 sec, ISO 200 with a 35 mm lens on a tripod. I took one shot focused on the flowers and one shot focused on the distant mountain and combined them in a focus stack. Stacking for landscapes can be useful and is easy to to do. In this instance I was fortunate that there was no wind, if there had been, stacking the images may not have worked so well, generally you need stationary subjects. I will describe different methods and software for stacking images below.
In looking for software to stack images I found that Adobe Photoshop CS6 to CC2017, Helicon Focus and Zerene Stacker appear to be popular programs for image stacking - all of these are commercial products, but the nice thing is that they all offer 30 free trial where you can test the software. I will list some of the other software below in my links that are free but I have not tested them. In searching for a stacking program the criteria I use to judge them are: 1) Quality of the rendered images 2) Ability to handle RAW files 3) Flexibility to modify and optimize the rendering process and output 4) Availability of other utilities and tools and 5) Ease of use. Some studies that compared Focus stack programs measured the time to process the image stacks. While speed is nice I am more interested in quality and I own a very fast computer (Alienware laptop with 16 GB RAM). All of the software I tested were comparable in speed of stacking and could stack 30 images in about 1-3 minutes. Had one program taken a hour or more to process my stacks I probably would not have considered it unless it did a really spectacular job.
Above I have stacked 13 images of a Diatom to increase the depth of field and show how Photoshop, Helicon and Zerene compare. The Photoshop and Helicon software images are comparable, the image stack produced in Zerene increased the thickness of the outline and does not appear as crisp as the other two.
In microscopy the higher the magnification used the shallower the depth of field. Below are a series of photos from a spherical Diatom at 200X. In total I took 20 focus shots, and I only show 2 focus points below 1) the top, 2) middle and then the stacked composite image where the entire diatom appears in focus (below you can view it in 3D relief). I converted the images to black and white to try and achieve greater sharpness and eliminate any chromatic aberration in my microscope objectives (Achromat Objectives). The bottom image shows the stacked photo which I created using Adobe Photoshop where you can see most of the Diatom in focus. Further down the page I show a 3D model of the Diatom that reveals that the central region was actually a depression and the Diatom is not a sphere.
Bottom 20 image stack shows the Diatoms Focus stacked with maximum depth of field. 200X Phase contrast microscopy. Below I show the Diatom in 3D and that the middle Diatom is not a sphere but has a central depression.
For those that own Photoshop CS6 or higher stacking is simple to perform and for landscapes you only need 2 images. In my tests shown below Photoshop sometimes did the best job, other times Helicon Focus did a better job. What I like about using Photoshop to stack is that I can load RAW files from the Camera (Nikon or Canon) directly into a stack, Auto-align, then Auto Blend them. I flatten the image and then can begin processing the image or repairing sections without leaving the program and it's fast in my experience (Windows 8, 16 GB RAM).
To stack images in Photoshop you can do this 2 ways 1) by loading the files in Photoshop or 2) loading the files into Photoshop using Adobe Bridge - which is my preferred method.
Method 1) In Photoshop Select Files > scripts > load files into stacks > Select the images you want to stack click OK. The Layers palette should be open (if not Windows > Layers). 2) You shift-click on the layers to select all of the layers. 3) Select Edit > auto-align layers > Select Auto (no other check boxes selected) and click OK 4) Select Edit > Auto Blend layers - check radio button stack Images (radio button check Seamless tones and colours) > OK. 5) Finally flatten the layers and you can begin to edit the image or remove any artifacts, sharpen the image etc.
Method 2) Working from Adobe Bridge (File > Browse in Bridge) in Photoshop CC only > click on the images you want to stack then go to the top of Bridge Select > Tools > Photoshop > Load files into Photoshop Layers. Then process as described above starting at step 3.
If the instructions are not clear try watching some YouTube videos on Focus stacking with Photoshop.
Above I show a Diatom RAW unprocessed file - the interior detail is out of focus. In the middle I applied unsharp mask to the single image and it helps, but the central detail is still not clear. In the third image I focus stacked 13 images in Photoshop and more detail can be seen. The Diatom was taken with a Nikon D500 camera using an Nikon Optiphot I microscope with 20X objective for a total magnification of 200X using polarized light and full wave plate to create the blue background.
The nice feature of the new versions of Photoshop CC is that after stacking you can select Filter > Camera RAW filter and apply noise reduction and other features offered by Camera RAW to improve the image further.
Above is a stack of just 5 images of a Diatom taken with a 20X Plan Achromat objective (200X magnification) polarized light and a full wave plate to create the blue background. The stacked image shows good detail with few artifacts.
Diatoms negative phase contrast, 8 stack of images using Photoshop CC 2017. Phase contrast microscopy creates the outer halos of light and the halos are not an artifact of the stacking process. 200X magnification.
Wasp head, 8 images stack taken with Canon 80D ISO 800 on a Wild Stereo microscope 10X. Most photographers use stacking programs with macrophotography. I will present a separate article on stacking of macro (1-10X) subjects in the future.
Helicon Focus stacking software interface showing a stacked Diatom on the right using stacking Method B
I downloaded a trial version of Helicon Focus and ran several stacking tests and I show some of the images below. Helicon is easy to install and use. It is available for both Mac and PC and they offer an excellent Help Page, Instructional videos and a Forum where users can interact, ask questions and share their knowledge. They offer other software and accessories but I only looked at their stacking program. This program will accept RAW files though they state they must first be converted to DNG (but it seemed to work with my Nikon D500 RAW files to my surprise so long as they all have the same orientation). The good news is that Adobe offers a free DNG converter you can download and use to convert your camera's RAW files to DNG (Digital Negative) RAW format which is universal. (I wish Nikon, Canon and other camera companies would use one standardized RAW format or provide the ability to convert to DNG directly in the camera - they have had 20 years to improve the RAW files - it's time to standardize!) You convert your camera RAW to DNG RAW by starting the Adobe converter, select the folder with your RAW files you want to convert then select the folder where you want the files to be saved to as DNG RAW format. Adobe converter converts quickly about 1 image per second. You can choose to stack .jpg or .tif files, but in my work flow I prefer to work with RAW files because of their flexibility and quality. Photoshop only offers one method to stack your images, whereas Helicon focus offers 3 methods, and Zerene two methods.
Above pictures of a Diatom taken at 200X polarized light microscopy. On the left is a single focus image, next is a stacked picture of the Diatom from 13 images using Helicon A weighted average stacking method, next is Helicon B method where the software uses a Depth map to stack, and finally C where the images are stacked using a Pyramid stacking method. All of the stacked images were done with the default parameters radius =8 and smoothing =4. In this series of stacks Helicon's B method provides the best quality picture.
Helicon Rendering Methods
The A method of stacking computes the weight for each pixel based on its content and then forms the weighted average of all pixels from all source images. This method works better for short stacks and preserves the contrast and colour.
The B method of stacking selects the source image containing the sharpest pixel and uses this information to form the depth map. This method imposes strict requirements on the order of the images - it should always be consecutive from top to bottom or bottom to top. It perfectly renders textures and smooth surfaces.
The C method uses a Pyramid stacking scheme which gives good results with complex objects (intersecting objects, deep stacks), though it may increase contrast and glare.
In addition to the different stacking methods, two of the methods A) Average and B) Depth map offer additional features which can be modified during the stacking - radius and smoothing.
Radius controls the size of the analyzed area around each pixel. The default size = 4. Setting the radius lower e.g. 1 can improve the appearance of fine hairs which otherwise might appear blurred. A high radius setting minimizes halos or other artifacts along object edges.
Smoothing is available with the A and B stacking methods. When analyzing the stack, the most sharply focused areas of the source image are found to be combined in the the output image. For "A" stacking method smoothing defines how the sharp areas will be combined. Low smoothing values produce sharper images, but the transition areas may have artifacts. High smoothing values will provide a slightly blurred image.
Below are a series of stacked images of a Diatom where I varied the radius and smoothing parameters.
Diatom in phase contrast 200X magnification. Radius value indicated by r=X and Smoothing value by s=X where X = some number.
1) Helicon A stacking method r=8, s=4
2) Helicon B stacking method r=8, s=4
3) Helicon C stacking method (no radius or smoothing feature)
4) Helicon B stacking method r=1, s=4
5) Helicon B stacking method r=35, s=4
6) Helicon B stacking method r=4, s=1 - I feel that this is the best and sharpest image from the group
7) Helicon B stacking method r=4, s=10
In this series of experiments the best stacks were produced by the B and C methods. Setting the smoothness to 1 in figure 6 seems to result in the best image, though most of the images look good and could be further improved through sharpening with unsharp mask in Photoshop. Photoshop does not offer more than one stacking method and does not offer any variables to tweak the stacking process.
Diatom 13 stacked images using Helicon B method with radius = 8 , smoothing = 4. 400X Phase contrast microscopy.
Note that some of the rows of dots are not completely smooth, they appear to be artifacts caused during the stacking process that are not seen in the Photoshop stack photo which I show in colour higher up the page.
Dinoflagellate Ceratium hirudinella polarized light microscopy, 200X Helicon C Depth Map 8 images stacked.
In addition to stacking images, Helicon also makes 3D images, stereo images and animations from the stacked pictures. Once you stack the image you can rotate it and view it from different angles. In the example below, the stacked image suggests the diatom is a sphere (inset top left), but the 3D map (bigger picture) shows that the Diatom is recessed in the center. The three D, stereo and animation features make this program attractive.
Top left a stack of 20 images of a Diatom. The 3D map of the same Diatom shows that the central region is a depression and that the diatom is not a sphere. I liked this feature and can see how it could be useful to anyone studying Diatoms and other microscopic organisms. The software can also export 3D obj models which can be further manipulated in 3D software - I will plan to explore these features further in the future.
3D model of a Diatom created in Helicon Focus, the inset top right shows a 5 images stack of the same Diatom. You can see the central depression or groove (raphe) in the 3D image. Click here to view 3D animation in new window.
Above is stereo pair of 3D models of the Diatom created in Helicon Focus.
The ability to create 3D models and animations from stacked photos is a feature I liked. Photoshop can import and work with 3D object files but it can't create 3D images from stacks. Zerene stacking software is able to make stereo pairs and rocking gif animations with the assistance of other software.
Zerene screen shot showing the interface and a stacked Diatom photomicrograph on the right.
This software program is available for PC (Win, Mac and Linux) and uses two stacking methods 1) PMax - which is a pyramid method good for low contrast subjects and subjects with small hairs. It tends to increase noise and contrast of the image. 2) The second method DMap or depth map keeps the original colour but is not as good at preserving detail.
Zerene does not support RAW files, one loads .jpg or .tif files into the stack. It blends images about the same speed as Helicon and Photoshop, but doesn't offer many features to modify the stacking process. I was able to achieve some good looking stacks with this program. The downside is its' high cost ($289 US for pro Edition) and lack of RAW file support. They do offer a Student edition for $39 US and they offer a free 30 day trial which allowed me to test their program. Some photographers report great success with it. You can view more sample stacking photos created with Zerene stacker here. Zerene also offers some retouching tools and outputs a synthetic rotation to make multiple images that can become a stereo pair, a rocking animation, even rocking stereo (.gif format) - view some examples on their web site, however the animations require additional software to create them.
To create stereo pairs or a rocking sequence Select > Options > Preferences > Stereo/Rocking. Different stacks will need different shits to make a good looking stereo pair.
Diatom - stereo pair produced in Zerene from 13 image .tif fileStack - DMap procedure.
You can make animated stereo pairs as .gifs described here - also see some of their sample animations . The rocking image animations are nice for web presentations.
Desmid Closterium sp positive phase contrast 400X 5 images stacked in Zerene using .tif files. Note the artifacts (wavy lines) in the D-Map stacked image on the right. In this instance the PMax stacking method worked best.
Stacking images can be used for landscape photography to provide greater depth of field and it is a powerful tool for both macro and photomicrography. Photomicrography is the most demanding as the depth of field is only a few microns (0.001 mm) and stacking images is often essential. I have been looking at photographs by some of the best macro and photomicrographers and many of them use stacking software (Helicon and Zerene), and some photographers stack as many as 100 images. Some photographers report that stacking images in Photoshop results in edge artifacts (e.g. Ldislav), though I generally see good results and most artifacts can be fixed with retouching tools. I will continue to use Adobe Photoshop for stacking, but I was impressed with the flexibility that Helicon Focus offers and the additional 3D features. To my surprise I also loaded some Nikon RAW NEF files from my Nikon D500 into Helicon focus and they worked, provided all images had the same orientation. This saves me from having to convert them to DNG. Helicon also offers some image editing functionality. Helicon software is $55 for one year license for the Pro version , and it offers the most flexibility and control in stacking fo the three programs I tested. Zerene worked well on .jpg and .tif files , but the pro edition is expensive ($289 US), and it lacks support for RAW files. I selected these three programs to compare because they appear to be the most popular ones used by macro and photomicrographers (e.g. on Flikr) - also see a research study which examined two of these stacking programs (Helicon and Zerene) for use in museum photography of insects and surveyed the popularity of the software use on the world wide web.
There are other tools for automated focusing that may be worth looking into for those that do a lot of this type of photography (e.g. Canon-Cognisys set up). An important question is how much overlap of focus is optimum - my guess is that between 30-50% of the focus depth would be ideal. More and I don't think you will see an improvement in the final image. I have even seen some excellent stacked photos using only 3-6 images of insects - see below and I have also seen photomicrographs that have used between 50-100 images. The number of images in a stack depends on the depth of field and the overall subject depth. With insects and other mobile organisms you also have the challenge of taking the shots while the critters hold still! According to some photographers you only get about 3-10 seconds at most to take your shots with live insects. Photographing some insects like dragonflies early in the morning is one answer and persistence for other insects and arthropods during the day is another.
First two images illustrate typical DOF (Depth of Field) of a single image at f/10 while the third image is the composite of six images, photos by Muhammad Mahdi Karim from Wikipedia Creative Commons.
If you don't have enough focus steps you will see banding in the image (regions with no fine detail). There are other Focus stacking programs, some are more expensive and some are free that you may want to consider. If you already use Photoshop then give it a try first and it might be all you need. A good free alternative to Photoshop is GIMP which can also perform stacking - watch this Video on how to focus stack in GIMP. If you are a professional or serious amateur macro or photomicrographer it's worth testing a few different programs to find what works best for you. For landscapes Photoshop does the job nicely with 2 images. Free software is nice and I have added some links to several free stacking programs below but have not tested them. I was happy to see that all three programs I looked at offer a free 30 day trial period and they don't put watermarks on top of the images or provide a reduced output size during the trial period. Based on these tests, I am will continue to use Photoshop for image stacking and I will get Helicon Focus to add to my bag of photo-tools.
For stacking images once in a while, I think that Photoshop does a satisfactory job but lacks the ability to tweak the stacking process. Helicon was the easiest software to use, supports RAW files, offers features to optimize stacking and creates 3D files from the stacks. Zerene also created nice stacks and stereo images, though its lack of RAW file support and high price makes the other programs more attractive.
Note: I am not affiliated with any of the companies mentioned. I was searching for the best stacking program to meet my macro and photomicrography needs and wanted to share my test results. No matter which program you choose you will need to spend some time experimenting in order to get the best results. For more perspectives on Focus stacking please visit the links below. I welcome readers comments. RB
References and Additional Links.
Adobe Photoshop - $12.95 per month includes Lightroom, Adobe Bridge - download free 30 day trial
Helicon Soft - Focus - web site where you can download a free 30 day trial - Cost $30-65\year for a license
Zerene Stacker - web site where you can download a free trial version for testing - Cost $39-$289 US
Adobe DNG converter - Free download
Focus Stacking - Wikipedia good overview and lists other stacking software
Review of Five best free stacking programs for Windows
Alan Hadley - free stacking programs Combine ZP, ZM, Z
Picolay - free stacking software
Research Study comparing Focus stacking software for insect collections: Leica vs Zerene vs Helicon Focus
LR/Enfuse - lightroom plugin for stacking and blending images
Focus stacking with CombineZP software - YouTube video
Focus Stacking with Lightroom & Photoshop
Extreme Macrophotography - great website with lots of information about Focus stacking
Focus stacking tips by Charles Krebs - one of the best macro\photomicrographers
Focus Stacking in microscopy by Quekett Microscopical Club
Focus-Stacked Macro Photos of bugs by Nicolas Reusens
Focus stacked images of Bugs
Focus stacking of live insects
How to Photograph live bugs Focus stacking - macroshooting.com
Build a World-Class Insect Imaging System for under $6000 - Scientific American
Image J - free image processing program that can do Image stacking and other types of image processing
Focus stacking in photomicrography - PDF
Post-processing Techniques for Macro Focus Stacking - Wade Sheldon - PDF
Zerene Systems - Focus stacking by Rik Littlefield - PDF
Zerene vs Photoshop - shows several comparison images
GIMP - free image editing program that can do focus stacking - watch this video to learn how on YouTube
For Geeks (computer programmers) - Pyramid methods in image processing - PDF
Forums - photomacrography.net and amateurmicrography.net
Expensive commercial stacking software -Syncroscopy (note this software is no longer being sold or marketed)
Robert Berdan is a professional nature photographer living in Calgary, AB specializing in nature, wildlife and science photography. Robert offers photo guiding and private instruction in all aspects of nature photography and Adobe Photoshop training.
Email at: firstname.lastname@example.org
Web site: www.canadiannaturephotographer.com
Phone: MST 9am -7 pm (403) 247-2457.
Click on the buttons below and share this site with your friends