Focus Stacking: Solving the problem of not enough Depth-Of-Field


It’s a common experience. You have awesome light, an excellent composition and a subject that really interests you. But something is awry. Something just isn’t working. As a photographer who also does a lot of design work I’m used to solving many different types of creative problems. In fact, that’s part of the “design thinking” process. To question everything in the hopes that whatever you’re trying to accomplish can be done better. 

I was at Theodore Roosevelt National Park in September, 2021. This was the third week of my four-week road trip. My creative juices were firing on all cylinders. Then I came to this scene at the Painted Canyon area in the SE corner of the park. It’s just off the highway. In fact, you don’t even need to pay the entrance fee to access the park here as this area doubles as a rest area.

For sunrise I decided to stay on the rim of the canyon. Shooting into it from above afforded some interesting subjects and compositions, but it also largely left the horizon very flat. I needed something to create interest in the frame. For this scene, I decided I’d use the clouds in the sky–they were gorgeous after all–and the grass-covered rim I was standing on. However, no amount of Depth-of-Field (DOF) was going to get everything in focus no matter how hard I tried. Not with sufficient sharpness anyway.

All camera settings rely on physics in one way or another

The problem with physics is that you have to balance your choices and make the best decision. I could have slammed my aperture all the way down to f/22 and hoped for the best. I would then manually adjust the focus to a mid-point so the foreground was just at the front edge of the range of acceptably sharp focus, or Depth-of-Field, and infinity would be at the back side of the DOF. Then everything “could” be in focus. Maybe. But I didn’t even try that. The reason I didn’t is that I don’t like shooting at f/22 or smaller on a wide angle lens if I can help it. It’s just too small. The reason it’s too small is the phenomena called diffraction. When light travels through an opening such as the aperture in a lens, some of it is diffracted, or scattered about without any control.

When you’re shooting such a small aperture on a 28mm lens as was the case here, a LOT of light is held back because the hole is so small. And that means a higher percentage of it gets diffracted. This scattered light ends up hitting the sensor in an uncontrolled way and that causes it to soften the resulting image. It’s just not as sharp as it should be so what good is having a long DOF anyway?

The Solution

Focus stacking isn’t a new technique, but it is getting easier and easier to implement as software manufacturers get better and better at analyzing the files and stitching together an image that has more DOF than would ever be possible with a single shot. And if you’re really ambitious, you’ll use a shallow DOF and get many different shots at slightly different focus points to achieve incredible detail throughout the entire scene.

However, this scene only required two shots. One for the foreground and one for the background. I’ve included zoomed in samples here since the difference isn’t so obvious in lower resolution.

Shooting it was easy. You simply activate a focus point on the foreground and snap a frame. Then tap the camera’s screen to activate an AF point in the mid ground and take another shot. Since I was using f/8.0 I was in the lens’ sweet spot meaning it’s got a decent amount of DOF and it’s delivering a result that is the sharpest it can be. I then got a shot with the camera tilted up slightly to get more sky. I wanted a vertical panorama so this was easy to accomplish. In this case though, I also zoomed in a bit to make the clouds a bit “larger” which really isn’t necessary, but it did adjust the scale of the clouds a bit, making them balance out the foreground elements a bit better.

The focus stacking process

I use Adobe Lightroom Classic and Helicon Focus to focus stack my images. The initial processing is performed in Lightroom. Then I use the export function to send the images to Helicon Focus, perform the stacking there, and when I close Helicon Focus the image is sent back to Lightroom. It’s a simple enough process but when you’re in Helicon Focus there is a lot to consider.

figure 2, screen grab of Lightroom showing the export shortcut to Helicon Focus

Focus stacking details

When the images are brought into Helicon Focus (HF from now on) you have a simple preview of the image in the main window, and a listing of all the source images in the top right section of the application window. Below that, in the lower right hand part of the application window you’ll see the “Rendering method” options. This is where a majority of your work is performed in HF. The screen shot shown here is set to the default settings which is Method B with a Radius of 8 and a Smoothing of 4.

figure 3, HF Rendering method options

If you’re new to HF you simply have no idea what these mean and the descriptions are nearly pointless. “Method A (weighted average)” means nothing to me anyway. And the other options are just as cryptic. Thankfully, they have a fairly good description on their website as to what these methods mean and what type of images they are good for. Let’s look at a few of these options and see what they’re all about.

Method B

This method is great for images with a simple surface, something like a sidewalk or street. It’s predictable, simple and easy to progress from one area to the next, both physically and visually. It’s essentially smooth and nothing too fancy about it. The HF engineers suggest that for these types of subjects Method B will be the best, but that also Method A and Method C may produce fine results.

According to the help page reference above, Method B is also excellent for images that have glare. It also performs well for image stacks of 100 or more images and performs exceptionally well if you want to preserve colors and good contrast. Stating this may make you wonder if the other methods are bad at this. In fact, they aren’t, but Method B and A simply perform better than Method C when it comes to color accuracy and contrast. In my experience with this one image it wasn’t ever a problem (I ended up using Method C)

In my example here, Method B was a disaster. I used the standard setting of Radius set to 8 and smoothing set to 4.

figure 4, Method B Radius 8, Smoothing 4

I also tried it with Method B and a Radius of 1 and smoothing set to 1

figure 5, Method B Radius 1, Smoothing 1

Method A

The HF help page says that Method A works best on images where preserving color and contrast is a priority. Also, if you happened to shoot the focus stack out of order, Method A is a good choice, as is Method C, but Method B is not. Method A is not recommended for image stacks of 100 or more frames. It also performs well if there’s glare in the image and they claim that it performs well with subjects that have a simple surface. They also suggest it performs well with images that have many crossing lines and changes in surface level, which is exactly what I have in my focus stack I’m working on here. As you can see here in these examples, Method A performed poorly.

figure 6, Method A, Radius 8, Smoothing 4
figure 7, Method A, Radius 1, Smoothing 1

Method C

The only thing that Method C is NOT recommended for is subjects that have glare. They say it performs wonderfully with image stacks with more than 100 frames, and for subjects that have many crossing lines and changes in surface level. As shown in the detail example here, Method C wins the day. However, with Method C, there is not an option to set the radius, only the smoothing. So I tried two different renderings, one with a smoothing set to 1 and another with it set to 4. I couldn’t see any difference whatsoever.

figure 8.2, Method C, Smoothing 1
figure 8.2, Method C, Smoothing 4, no difference that I can tell anyway.

Radius Setting

The HF engineers recommend experimentation so you get familiar with the tool, and I couldn’t agree more. In short, if your image has lots of fine details, you’ll want a small radius setting. If you don’t have many details that are ultra fine, then a larger setting may be appropriate.

Smoothing Settings

When focus stacking, the trick is to blend the areas from the different frames into a cohesive unit that looks like it all belongs. These transitions can be very tricky to accomplish. This is where smoothing comes in. A lower setting will produce a sharper image while a higher setting will cause some blurring to happen. Once again, experimentation is key to see just what your subject and shooting technique requires. Look for artifacts in the transition areas. If you see something that’s too much, to glaring, then try a higher smoothing setting and maybe that’ll fix it.

Alignment Settings

HF also allows you to align the images in the stack. This would be needed if you were not on a solid tripod or if you have other movements in the frame. Often times our lenses will exhibit focus breathing. The alignment setting will take all forms of misalignment into account. Maybe the subject shifts from left to right, up or down, maybe it’s rotated from frame to frame for some reason. But the biggest issue you’d need to address on a super detailed shot is focus breathing, and for that, the software will automatically zoom in or out the different frames to accommodate for this phenomenon. I did not find it necessary for this image since it’s a very simple composition made up of just two frames for the focus stack.

Final Assembly

Once all the stacking is performed, the rest of the image production was rather easy. I brought in the sky image over the foreground image and expanded the canvas to position it so the horizons align properly. In doing this, I like to use the layer blend mode of Difference so I can easily see how the two layers are lining up to each other. Given the difference in focal length there’s still going to be some differences, but it’s still easy to get aligned properly.

figure 9, using the difference layer blend mode to show the proper alignment between the two frames. In this case, looking only for the horizon to be aligned as best as possible.

I then used a layer mask on the sky layer to hide the foreground that is still part of that layer. The colors of the sunrise allow it to blend seamlessly when using a slight gradient transition in the layer mask and it looks great.

figure 10, PS screen grab showing the layer stack and the layer mask allowing the sky to extend further.

There were a few anomalies in the transition area between the foreground and background focus frames. This was caused by the grass blowing in the wind. Not something I can blame on the software. However, if I had the Pro version of HF I’d be able to use their retouching functions as much as needed to make the fix. But for now, I’ll either live with it or fix it later in Photoshop.

Why I didn’t use PS to focus stack

Photoshop has a focus stacking function. But I suspect it’s best suited for simple forms and surfaces. As you can see in the result here it’s just not an acceptable transition between the foreground and background frames.

figure 11, Using Photoshop to do the focus stacking work just messed up in the areas between the grasses.

Be sure to watch my updated experience with a 240 frame macro shot!