Focus Stacking with Open Source Software and Photoshop

The object of focus stacking is simple – combine several near-identical shots of a subject to create an image with a greater depth of field than could be achieved in one photograph.  The only change between each exposure is a subtle shifted of focus – everything else (lighting, composition etc) remains static.

It is not as scary as it may sound, so rather than an in-depth tutorial, this post simply describes my very first personal experiment with the technique.

Why do it?

There are a variety of simple methods to maximise the zone of sharpness in an image:

  • use a prime lens with a short focal length
  • choose a narrow aperture
  • move the camera further away from the subject

Each method has limitations, or may compromise other creative requirements; aperture is worth special mention in this regard. It can be tempting to dial in the smallest available aperture setting, but this can be a mistake. Any aperture smaller than f11 can actually reduce sharpness or resolution throughout the image (including the focal plane). Surprised? Google “lens aperture and diffraction” to learn more.

Focus stacking is most commonly used with macro photography, where zones of sharpness are typically very shallow, and changing lens or distance to subject are not an option.

Setting up

I wanted a subject that would easily show the success (or failure) of my experiment, so placed a desiccated flower (the button-hole from my wedding a few years ago) on a windowsill that received indirect (therefore diffuse) sunlight.

A 60mm macro lens was attached to a Nikon D7100, which was mounted on a sturdy tripod to keep the camera perfectly still throughout shooting.

A few test shots established the exposure settings required: ISO 200, f/8, 1/8sec shutter speed. Of course, using window light for multiple shots requing the same exposure was risky as the strength of sunlight can change rapidly, but the sky was heavily overcast so I figured fluctuations would be minimal.

Shooting

Connecting camera to laptop via USB cable, I booted up a nifty bit of software called Digicamcontrol. This open source tethering program has focus stacking functionality built in.

I could have tried manual focussing to create a series of shots with small, consistent adjustments in focus, but Digicamcontrol simplified the process. Rather than reinventing the wheel, here is the exact method I followed to capture the images that would form my stack: http://digicamcontrol.com/blog/focusStacking

If you did not follow the link, it essentially describes the process of setting the parameters required to generate component images for the stack:

  • number of images
  • focus step size
  • interval between each shot
  • near & far focus points

Specifying the near and far focus points was relatively straightforward. For the step value I took a punt on “35”, but there are far more scientific methods of determining this value, such as online step size calculators and tables. For the shot interval I selected 1 second, but that value would have been higher had I been using flash.

The software used these parameters to determine the number of shots required: 11.

Stacking the shots

Once Digicamcontrol had instructed the camera to fire off the 11 shots I switched to Adobe Bridge and loaded the first image into Adobe Camera Raw.

Since this was primarily a test exercise I decided to apply all tone and colour edits here rather than Photoshop, and then apply those changes to the other 10 images via Bridge (Edit -> Develop Settings -> Copy/Paste Camera Raw Settings).

The first image shot was loaded into Photoshop CS6, then each subsequent shot was opened (in the order the images were shot) and copied to a new layer in the first file. This produced a single working image file of 11 layers with the first shot at the bottom (“background” layer) and the last shot at the top of the layer stack.

Blending the stack

Selecting all the layers in the stack, I then ran the following commands:

  1. Edit -> Auto-Align Layers
  2. Edit -> Auto-Blend Layers

Finally, I flattened the image and cropped it slightly, then compared the resulting composite image to a single shot with the same settings and composition; here they both are:

focus stack comparison full
Top image is the single shot, bottom image the merged “stack”.

Here are the same two images cropped in to better demonstrate the difference between their respective depths of field:

focus stack comparison detail
The “stack” is at the bottom again. Maybe I should have done some dusting first…

Ideally I should have shot the single comparison image with a smaller aperture, but the difference between f8 and f11 or f16 on a macro lens a few inches from the subject would be extremely minimal!

In Conclusion

I am not 100% convinced of the more general artistic merits of focus stacking, especially when software is shouldering much of the burden – but that is the subjective opinion of a tog who appreciates the use of out-of-focus elements within imagery. I am also sceptical about HDR photography (which has similarities to this technique) and often wonder whether the ends justify the means… but then I did enjoy playing with another ‘stacking’ technique: http://www.adrianmulton.co.uk/blog/timestacking_quick_tutorial/

I can, however, envisage scenarios where creative interpretation of a subject requires greater depth of field than available from a single shot. I also see this as a useful technique in commercial product photography, so will continue to experiment….

To chat about your photography requirements, call me on 07757 259390 or send me a message via email.

Or check out some more examples of my product photography.

adrian signature

Leave a Reply