One of the primary objectives when making an image is to achieve proper focus to draw attention to a subject or areas of interest. For some photographs, such as portraits, only the person or people in the image may be in focus. In other situations, however, it may be preferable that everything in the image be in focus. This is generally the case with landscapes, but may apply to other types of images as well. Sometimes getting everything in focus in a single image proves to be difficult, if not impossible. That's when image stacking becomes necessary. This article explores some of the different aspects of image stacking, including what it is, when you need it, and how to utilize this technique to create the images you envision.
Understanding Depth of Field
Before getting into image stacking, it may be beneficial to take at least a shallow dive into what depth of field is and how it relates to camera and lens settings. An in-depth discussion of depth of field would include such terms as the circle of confusion and hyperfocal distance. In a nutshell, depth of field, or DOF, is defined as the distance between the closest and furthest objects in a scene that appear to be in acceptable focus. When an image is captured by a camera, it is essentially a two-dimensional representation of a three-dimensional world. The width and heighth is relatively easy to understand, as they are represented by the frame of the image. Depth can be more complicated and difficult to see, since it is flattened in the resulting image.
The amount of area that is in focus in an image is affected by the size of the camera's sensor, focal length and aperture of the lens, and distance from the lens to the subject. Generally speaking, a smaller sensor will have a greater DOF for a given focal length and aperture than a larger sensor. In other words, a crop (APS-C) sensor will have greater DOF than a full frame sensor and a micro four-thirds sensor will have a greater DOF than a crop sensor. The tiny sensor in your smartphone camera will typically get everything in a scene in focus without any problem.
The focal length and aperture of a lens will also play into the DOF equation. To put it simply, a larger aperture (i.e., f/2.8) will have a shallower DOF than a smaller aperture (i.e., f/22). Additionally, zooming into a scene with your lens will generally decrease the DOF as will decreasing the distance from the lens to the subject in an image.
What is Image Stacking
When the desired depth of field cannot be achieved with a single image, image stacking techniques may be used. Also known as focus stacking, this technique is performed by capturing two or more images of the same scene. Each of the images have a different portion of the scene in focus. The number of images that are required will depend on how shallow the depth of field is in each image and how much of the scene you want to have in focus. The images are then stacked or blended together in computer software to reveal only the sharp areas in each image. The result is a single image file with everything you want in focus.
In the series of images below, the first two are the focus stack. In the first image, the focus point was placed on the log just inches to the right of the camera. Note that the background is out of focus. For the second image, the focus point was moved to the reflected trees in the water. Most of the image is in focus, except for the log very near the camera. The third is the final result after stacking, where everything is tack sharp. Quick Tip: in each of the first two images, you might notice black specks in the sky. Those are birds. The birds were removed in the final image using the spot removal tool in Lightroom. Otherwise, they would look like sensor dust and be a distraction in the image.
Why You Would Need It
As previously discussed, the image stacking technique may be a good choice if you cannot achieve enough depth of field to get everything you want to be in focus in a single image. A couple of situations when image stacking may be necessary are when shooting macro or landscape photos. Both of these types of photography can present some challenges for getting everything in focus that should be.
With macro photography, the lens is typically very close to the subject and the focal length is usually quite long. A common macro lens has a focal length somewhere in the neighborhood of 100 mm. In that situation, the depth of field is sometimes razor thin. In fact, the lens may only be capable of focusing on a fraction of an inch of area at a time. Several images, as many as 6 or 8 or even 20 or more, may be needed to get the depth of field that is needed for a macro image. It will really depend on how much of the subject you want to have in focus, the distance from the lens to the subject, and the actual depth of the area that you want to have in focus.
A landscape image will typically have a foreground element, a middle ground, and background. Usually (but not always) you want to have everything in sharp focus, from the closest subject in the front all the way to the back of the image. This can present a challenge, especially with a strong foreground element that is very close to the camera. If you focus on the foreground element, then the mountains or trees in the background may be out of focus. Conversely, if you focus on the mountains or trees in the background, then the foreground element may be out of focus. That can be a big distraction in a landscape image.
Alternatively, focusing approximately one-third into the scene may give you enough depth of field. However, if it doesn't, then two or more images may be needed, each one focused on different elements in the scene, to result in a totally sharp image.
Why Not Just Stop Down?
You may have heard the phrase “stopping down” a lens. If you are unsure of what that means, it is essentially closing down the aperture to make the opening through which light can pass to the sensor smaller. Stopping a lens down from an aperture of f/3.5 would mean changing the aperture setting to f/4, f/5.6, f/8, or smaller. The larger the number on the bottom of the fraction, the smaller the opening through the lens. Kind of confusing, but you can learn more by reading this article.
Since a smaller aperture will produce greater depth of field at a given focal length, you may ask why not just stop the lens down to get everything in focus in a single shot. That is actually a good strategy and may work a lot of the time. However, there are some limits to how much depth of field you can achieve, even with the lens stopped down all the way. There are also some caveats to doing so.
Every lens has a sweet spot – the aperture setting where the lens produces the sharpest images. This will vary with each lens, but is generally believed to be around f/8. That doesn't mean you shouldn't shoot at an aperture smaller than f/8. On the contrary, f/11, f/13, and even f/16 work fine. What you should be aware of, however, is that closing down the aperture will introduce diffraction, and diffraction can make an image appear less sharp. The amount of diffraction will vary by lens and camera, but apertures of f/16 and smaller may have an impact on image sharpness. That impact may or may not be a concern. I've shot plenty of landscape images at an aperture of f/22 that were acceptably sharp for me.
Another reason to not stop down is that you may want to maintain a shallow depth of field. That sounds counterintuitive, but for macro photography, you typically want the subject to be in sharp focus and for the background to just totally fade away into blurry goodness, aka bokeh. Using a wide open aperture will keep the background soft, but a lot of images will need to be stacked to bring the object of the image into sharp focus.
Focus Stacking How To
Nick Page did a great video course on focus stacking over at Improve Photography Plus. If you are not already a member, hop over there and give it a try. There are tons of video courses and other resources for download that will help your photography. Not to mention an interactive community where you can ask questions and glean inspiration.
For the purposes of this article, I will focus (pun intended 😉 ) on stacking images for landscapes. The procedures for capturing the images are generally the same, as is the post-processing techniques. The only thing likely to change is the number of images that you use.
The most important piece of gear for capturing a sequence of images is a tripod. Rock solid support for your camera is essential to prevent the camera and lens from moving between shots. Plus, the peace of mind will allow you to fully concentrate on the composition and get everything in focus.
After the camera is set up on the tripod for the composition you want, it is time to evaluate how much depth of field you need and how many images will be necessary. For a landscape scene with a strong foreground element, you will likely need at least two shots. One will focus on the foreground and one at least a third of the way into the scene. However, a few extra shots won't hurt. Take another shot that is focused a little closer to the foreground and another focused on the background. As you capture the images, review them on the camera's LCD screen to be sure that everything gets in focus between all the images. If you end up with more than you need, you can always throw them out later. It's better to have too many images than to not get the proper coverage.
Capturing a good set of images for focus stacking can be a tedious process. What follows is pretty straightforward and can be done relatively quickly once you get the workflow down. There are a number of photo editors out there. Since I use and am most familiar with Adobe Lightroom and Photoshop, that is the workflow detailed in this article. Regardless of where you start, the Photoshop portion should be the same.
After capturing all the images for your focus stack, import them into Adobe Lightroom (or whatever photo editor you use). Here is where you can make some basic adjustments, such as exposure, highlight or shadow recovery, contrast, and clarity. Just be sure to sync the adjustments across all the images so they are identical. Then bring the images into Adobe Photoshop as layers. If you're in Lightroom, select all the images to be stacked, then go to the Photo Menu -> Edit In -> Open as Layers in Photoshop (Mac or Windows).
The Magic of Photoshop
Photoshop is where the magic happens. First, the images will need to be aligned to compensate for slight movements or focus breathing from frame to frame. To do this, select all of the layers, then select the Auto-Align Layers option in the Edit menu. In the window that pops up, the Auto option will be checked by default. That should work fine. Click OK and the images will be aligned, possibly leaving slivers of transparent canvas around the frame. Those will be taken care of in the next step.
After aligning the images, make sure all of the layers are still selected. Go back the Edit menu and this time select the Auto-Blend Layers option. Make sure the Stack Images option is selected in the pop-up window, as well as the Content Aware Fill Transparent Areas. That will fill in the gaps around the edges of the final image.
The Final Result
The Auto-Blend function in Photoshop automatically selects the sharp parts of each image in the stack and blends them into one final image. If you look in the Layers panel after blending, you will notice that each layer has a mask showing which areas have been retained and which ones left out. It really does a great job most of the time. The result that you get should be an image that is sharp throughout. The final image can now be saved back into Lightroom for additional adjustments and polishing to make your masterpiece.
Note that this may take a few tries to get right. If one single area is not in focus, then the image won't look right. The image below is a good example of what can go wrong. I focused on the knot in the log right in front of the camera, then near the middle of the log, and finally down by the water. That wasn't enough to get everything in focus. Notice the blurry areas right below the knot and by the water's edge.
Give this technique a try the next time you need a little more depth of field than you can achieve with a single image. With a little bit of practice, it can be a very effective way to get everything you want to have in focus as sharp as can be.