A big part of photography is coming up with creative ways to overcome the limits of the laws of physics. One of these techniques is focus stacking.
Even wide angle lenses at narrow apertures—a combination which gives you the broadest possible depth of field—can’t have both the extreme foreground and extreme background in sharp focus. You can come close, but if, say, there’s a cool shell right in front of you, and something else of interest in the distance, one or both of them is going to be a little bit blurry. Just look at this photo.
While it’s not bad, the shell is less sharp than I’d like while the castle on the island is in focus, or as much in focus as is possible with my setup.
Here’s a photo where I focused on the shell instead.
While it looks much the same at web resolution when you zoom in on the high res file, you can see the shell is in sharper focus—look at the rings around the shell as well as the small pebbles nearby to see it—while the castle on the island isn’t.
This is where focus stacking comes in. It’s a technique that combines multiple frames into a single composite image that has a depth of field that’s impossible to get in real life. Here, I’ve stacked the two photos above.
Look closer, and both the shell and castle are sharp.
Pretty awesome, right? Let’s look at how to do it. I’m going to demo this using Photoshop, but you should be able to replicate this technique in most good image editors.
When to Use Focus Stacking
Focus stacking is useful any time you want a depth of field in your images that you can’t get optically. The two main times this happens are when you’re shooting landscapes with something happening in both the foreground and the background, like in the example above, or when you’re doing macro photography. Most of the rest of the time, you won’t need to use focus stacking since your lenses and camera will give you enough depth of field.
Shooting for Focus Stacking
Focus stacking starts with the camera. Get things wrong here, and no amount of Photoshop work will save your shot.
Once you’ve settled on your final composition, lock your camera down on a stable tripod and switch to manual exposure. You want there to be as little variation between the two shots as possible.
Next, switch your lens to manual focus mode. This is one of those situations where you’re going to get the best results doing things by hand. Turn on the live view screen and zoom in to the maximum—it’s normally 10x—on the foreground. Twist the focus ring until it looks as sharp as possible and then take your first shot.
Next, use the live view screen to zoom in on whatever is in the background. Again, adjust your focus until it’s sharp and take your shot.
Two frames are normally enough, but if you’re working with wider apertures or just want to be sure, you can take a third frame and focus somewhere in the mid-ground.
Focus Stacking Images in Post
If you do a lot of focus stacking or want to blend a dozen frames to get perfect macro shots, you should check out dedicated focus stacking software like Helicon. It’s designed to work in extreme situations. On the other hand, if you’re looking to extend the depth of field in your landscape shots, then you’ll probably be fine with whatever image editor you already use. I’m going to show it with Photoshop. To follow along, you’ll need to be familiar with how layer masks work. If you’re not, check out our full guide to layers and layer masks before continuing.
Open all the frames you want to blend in a single document. To do that in Photoshop, go to File > Scripts > Load Files Into Stack. Click “Browse” and select the files. Select the “Attempt to Automatically Align Source Images” checkbox—that will fix any small tripod wobble—and then click “OK.”
Since the differences between the two images are probably quite subtle, I recommend zooming in to 100% and then renaming your layers to make it easy for you to remember which one is focused where. I like to put the layer where the background objects are in focus on top, but it doesn’t make too much difference.
Select the top layer and go to Layer > Layer Mask > Reveal All.
Select the Brush tool (the keyboard shortcut is B) and make sure you have a nice, big, soft brush.
Select the mask and start painting with black over the areas of the frame that are slightly out of focus. I’ve turned off the bottom layer to give you an idea of where I’m masking.
Zoom in, swap back and forth between the layers, and mask things so that everything transitions between the two frames nicely. If you need to, you can use more advanced selection tools.
Once you’re done, you should have seamlessly blended the two frames into a single image with an extended depth of field.
Focus stacking probably isn’t something you’ll need to use a lot, but it’s a handy technique to know. Just make sure to get things right on location.