Home Feature Articles Focus Stacking: Manipulating depth-of-field through computational photography

Focus Stacking: Manipulating depth-of-field through computational photography

The author gets down and dirty with the nuts and bolts of this powerful technique

21

Ever found yourself unable to get all of your landscape shot in focus, from a few feet away to a distant horizon? Or, struggled to achieve sharp focus on all the petals of a flower in a macro shot? If so, there is a digital photography technique riding to your rescue. It’s called focus stacking, and the Macfilos team asked me to share my experience with it.

No good deed goes unpunished

A few weeks ago, I made the mistake of sharing a few ‘focus-stacked’ images with a member of the Macfilos team. Next thing I knew, he was asking me to write a little article about focus stacking. It was such a charming request, I was unable to refuse. So here we go. Focus stacking; I’d call it “fighting the depth-of-field (DoF) restrictions”.

Many of the wonderful articles here on Macfilos talk about some more or less expensive lenses and their capabilities to isolate a photographic subject from its foreground or background. In fact, that’s making use of the lens’s DoF.

How do you calculate the DoF in a given situation? Here’s the equation you need:

c = circle of confusion ≈ 0,03mm
f = focal length
s = subject distance
A = aperture number

This looks pretty simple. I’m sure anyone of us could easily solve that equation while out in the field, taking photos!

105mm macro. Left image: somewhere in middle of stack. Right image: fully stacked 15 images

DoF challenges

We all know that DoF is determined by aperture, focal length and subject distance. So, the closer you get, or the more wide-open the aperture, the shallower DoF will be. We also know that closing the aperture will increase DoF until we get visible diffraction. The App Store offers many solutions for quickly having help on hand to calculate DoF, via your phone screen.

A shallow DoF offers many creative opportunities. But occasionally, it can be problematic.

Focus Stacking is therefore one solution to overcome too shallow a depth of field, be it in landscape photography or when photographing close subjects, especially macro images. We simply take several images of a subject, each using a different focal plane, and merge/stack these in post-production.

Many roads lead to Rome

There are various ways to go about focus stacking. My experience is based on using manual lenses on a Leica M10. The camera should be on a tripod, though. I hope none of you readers think I kneeled on that rock in the photo below with a DoF calculator on my iPhone. No, I used Live View, watching the red focus-peaking marks slowly crawl to infinity as I turned the focus ring.

Many later-model digital cameras have built-in focus stacking programs. You could call them  “automatic focal plane changing” capabilities. The user has to do the stacking afterwards. My Nikon D850 offers such a menu entry.

As mentioned above, the camera needs to be on a tripod to get usable results. The focal plane will be moved forward at an adjustable rate until the preprogrammed number of images are taken. It’s also sometimes called ‘focus bracketing’.

A game of millimetres

Unfortunately, I can’t tell the camera how far it should move the focal plane forward for each bracket. Imagine if I could set the incremental advances in focus distance by using an Excel sheet I had at hand. Confession: I have such sheets. No, that’s too simple and too likely to guarantee success. To enjoy the full experience, you have to guess and gain experience as you go.

Bear in mind, though, that for a 105mm focal length and aperture of f/5.6, at 25cm the DoF is 1.1mm. That’s what I call razor-thin. All the best with capturing fifty incremental changes in focal plane without something going wrong.

Don’t ask me for any recommended settings in different situations. You should try it out and just be aware that you will get a ton of unsuccessful attempts.

What additional challenges might you face?

It’s nice to have calm, wind-free conditions when focus stacking for landscape photography. Not only does that make for sharp reflections on a water surface, but it also reduces the likelihood of leaves and other light objects moving between frames, ruining the final stack.

I have occasionally discovered such problems after going through the complete process of post-production. No frustration there …

There is also a distinct possibility of light conditions changing when a sequence of some 50 images is taken. Do it over!

The only way to be certain of avoiding these pitfalls is to choose subjects that can be photographed in the studio. Even then, don’t forget to turn off any wind machines that might ruffle hair or clothing.

Post-Production

An in depth report or detailed instructions for which post-processing set up to use is beyond the scope of this short article.

Suffice it to say that I typically gather my first impressions of the “to stack” images in Lightroom. I’ll usually run my quick and dirty developing preset and then export to either Photoshop or Helicon Focus.

Photoshop

I set the chosen images to “Open as Layers” in Photoshop. Once they have loaded — yes 50 frames at 45MB can take a while — I select all layers, “Auto-Align Layers” and “Auto-Blend Layers”. You will find out how fast your processor is, and if the latest RAM addition was worthwhile. I reduce everything to one layer, and then I am ready to do some fine-tuning of colours and whatever.

You will not be able to change the result of the “Auto-Blend” by fiddling around with the masks. Either take it or leave it!

Helicon Focus Pro

Okay, it’s not the software with a low price tag for a single special purpose. But, it offers different types of calculations and is a lot faster than Photoshop. Its Pro version allows you to do things like making corrections with a brush. It works as a Lightroom Plugin, so frames from Lightroom can be exported directly to Helicon.

As I said, it’s a special purpose software which does not provide the enormous number of functions that Photoshop offers. I’d recommend it if you do a lot of focus stacking.

Conclusion

I consider focus stacking a niche area, but it is useful for getting around DoF issues in landscape and macro images. To me, it offers the chance to use a 105mm Macro lens at f/5.6. That’s often an aperture where lenses have their best performance in terms of sharpness or lines/mm. The aperture at f/32 would not be enough with this lens to get a close subject completely in focus.

I can’t imagine Leica M users kneeling behind a tripod with the camera mounted, taking 50 focus-ring-turned, bracketed shots of a bug 50 cm away. Although, it would be funny to see that happen.

Focus stacking is certainly an important tool for product photography. And if you see an image of Frangipani blossoms completely in focus, guess what …

Here is a link to a brief video I made, demonstrating the Helicon Pro software in action:

Here’s a link to a helpful online article on focus stacking

Here’s a video of someone out in the forest, using focus stacking for macrophotography

Do you have any experience with photo-stacking? Which software applications and workflow do you usually use? Let us know in the comments below.


Join our community and play an active part in the future of Macfilos: This site is run by a group of volunteers and dedicated authors around the world. It is supported by donations from readers who appreciate a calm, stress-free experience, with courteous comments and an absence of advertising or commercialisation. Why not subscribe to the thrice-weekly newsletter by joining our mailing list? Comment on this article or, even, write your own. And if you have enjoyed the ride so far, please consider making a small donation to our ever-increasing running costs.


21 COMMENTS

  1. Thanks for the inspirational article. I recently purchased a OM system OM Mark II which will be great for this I think.

  2. Thanks for an inspiring article and wonderful pictures. Focus stacking is something I’ve never tried before, but after acquiring the new 100mm Panasonic macro, I’m tempted to give it a try.

    Andy

  3. Hi Dirk, fascinating article and outstanding images. Thanks a lot for telling us about this technique. I wish commenters would offer their thanks and compliments before launching into tales of their own views on focus stacking! I, for one, appreciate all the effort you put into your article. All the best, Jeff.

  4. News from a heretic: (Reaches for Olympus OM-1 ..that’s the new-ish, digital one)

    Menu> Computational Modes> Focus Stacking> (On)> Set number of shots (3-15), Set focus differential (1-10)> Squeeze shutter button (handheld). The End.

    Wait 5 seconds for processing ..result! The camera (with about 5 stops of stabilisation built in) aligns all the shots, crops slightly for absolute registration – no Photoshop or other software required.

    Cost of OM-1 camera and lens? ..About £1,250 (new) [weighs 600g] plus 60mm f2.8 Macro [120mm equivalent] about £300 (new) ..Total, about £1,550. (Alternatively, cost of 45mm f1.8 [90mm equiv.] also about £300 new.) = Total, about £1,550 (new)

    Cost of Leica M10 (new £8k, used £4k) [weighs 660g] + 90mm macro (new about £3k, used about £1900) = Total, about £11,000 (new), or used about £6k.

    Visible differences? ..er, very little to none.

    I do applaud all the effort, but why not get a camera which does all the stacking and the processing for you? ..At a fraction of the price(s) of a Leica or Nikon D850, etc? ..And does it handheld.

    People say, of course “Oh, an Olympus, they’ve got so many different things in their Menus ..too complicated for me, I won’t use half of it, it’s more like a computer with a lens on the front; I want a camera with next to nothing in the Menus.” ..But then when it comes to stacking, you have to do all the work yourself! ..You pays your (less) money, and gets your, erm, everything you need, even though you didn’t actually know that you would ever need it!

    • Or our very own L-Mount Panasonic S5II… This from a review on Travelog.com:

      “Another feature I wanted to try was focus stacking. You could argue that it would be quite easy to do this yourself by simply focusing on various important elements throughout your frame but the automated function certainly speeds up the process.”

      Must try it!

      • ..But you forgot to mention the next paragraph, Mike:

        “The image below is compiled in Photoshop of eleven images captured on the Lumix S5 II using the Lumix S 20-60mm f/3.5-5.6 lens at f/8.”

        The Panny shoots the images ..but doesn’t seem to actually stack them together in the way that, say, the Olympus does, does it?

    • It’s nice, that an OM1 can do that within the camera. What format does the image coming out have?
      The D850 is my workhorse along with a closet full of F-Mount lenses. The Nikon booklet has more than 350 pages. That’s why, I’d never read thouroughly.
      As I wrote, Focus Stacking is a niche and I’d never (well, you never know) give up my Nikons which I’ve been using for decades because any other cam can do it itself.

      Greets Dirk

      • Hi Dirk,

        “..What format does the image coming out have?..” You can shoot normally in Raw, Jpeg or Jpeg+Raw, but the resultant stacked images come out as Jpeg (saves time, I suppose, in the internal stacking).

        Nikons are, of course, great (“great but heavy”, as Niles’ bird might say – in that episode of ‘Frasier’ when he gets the bird stuck on his head). I’ve one or two F-mount lenses myself, and a Nikon 105mm in Leica fit ..now that’s a great long focus lens!

        • Yes Jpg, that’s what I’ve assumed.
          I’m a stubborn head in terms of the file format before editing. It has to be DNG, NEF or any other RAW-Format.
          The Nikon in Leica Fit is the 105 Ai-S f/2.4? For the M?
          It’s a gem.

          Greets
          Dirk

          • Oh no, no; nothing as modern as that: mine’s the f2.5 original screw-fit version, with an M-mount adaptor ring ..so it fits on any Leica, or Leica-fit camera!

  5. I once owned a Nikon PB-4 bellows, which will do tilts and shifts, plus a 105mm Bellows-Nikkor. The Bellows-Nikkor is in a short mount, which allows infinity focus on said PB-4.

    I never got around to using them, and they are collectable, so sold them off.

    More recently, I purchased a 45mm PCE-Nikkor, which also allows tilts and shifts. This lens and the above-mentioned combination allow huge DOF through the Scheimpflug principle. I have used the PCE only once so far.

    In both cases My intention was to shoot landscapes with continuous sharp focus from close-up outward, but I am beginning to think those kinds of images are not what moves me, or I would have used these lenses more.

    As far as focus stacking, that kind of image manipulation just does not appeal to me.

    • As I had mentioined to Keith, Tilt-Shift is another way to change the position of the focal plane.
      I own a 24 PCE-Nikkor. It’s resting in the closet. And yes, it can be used for that.
      But: The leek blossom is rather spherical than flat. It won’t help much to use a Tilt-Shift in this special case. It would have a DoF of 2.08 cm at f/5.6 and a distance of 20 cm to the subject. The blossoms diameter is about 5 cm.
      No doubt that this will work perfectly for landscape photography.

      Greets Dirk

  6. I have experimented with an M camera, doing hand-held shots of subjects within several feet distance with a slight change in focus distance on each shot. Provided you frame it fairly accurately it can work but I will admit using a tripod will yield better results. The set of images I took did auto-align successfully and the result was good. For landscapes in daylight it would be easier when you can use higher shutter speeds. I also do pano images with the M camera, hand held, provided I use a 30-40% overlap on each image. Lightroom or Ps will merge them successfully. I admit I go to great lengths to avoid using a tripod.

    • Hi Bill,
      nice to hear, that your approach is successful for you. I’ve tried that and failed.
      The chance to miss the nodal point of the lens is at least given. It might not be of relevance in far distant landscape photography. Don’t have a pair of power supply lines run through the image. You’ll find out about the npp quickly.

      I do a lot of landscape panoramas but the limits of LR or PS are 60.000 px length, if I recall that correctly. I’ve done some with 100.000 x 50.000 px and this for your camera is hopefully fixed on a tripod. The merging quality of LR or PS a “bit” inferior compared to PtGui. But that would be the topic of a different article.

      Greets
      Dirk

LEAVE A REPLY

Please enter your comment!
Please enter your name here