This is CallMeAlan.uk

Focus Stacking - A Complex Method of Obtaining Massive Depth of Field

Depth of field defines, quite simply, the amount of your subject which is in focus, or, in other words, the distance between the nearest and the farthest parts of the image subject which are in acceptable focus.

Out on the hilltop, shooting the scenery below you, the odds are that the whole picture will be in focus. Get in a bit closer to the subject, taking a picture of a friend out in the street for example, the odds are that the friend will be in focus, but the houses behind her will be blurry. Nornmally this is fine, you're happy for her to be the only finely defined part of the picture. But the keyword there was 'closer', and you'll know that the closer you get, the narrower that finely defined front-to-back distance will be. Photograph your dinner from a foot away and the steak may well be in focus, but the string beans are blurred. Get right up close and personal and try to snap that dead fly and perhaps just one small sliver of one compound eye will be sharp. Put the camera on a tripod, dial up the aperture to f/22 and expose for about 10 seconds and a slightly larger sliver of eye will be in focus - but not very good focus, because at f/22 diffraction turns 'sharp' into 'fuzzy' - back to that word 'acceptable'.

So what can the macro photographer do to get objects close to the lens in full focus, front to back? How can he increase his depth of field? Quite simply, he can't - at least, he can't in a single shutter press. No, he has to be clever. He has to take a series of separate photographs. He starts by getting the nearest part of the object in focus and presses the button. He then repeatedly moves the focus point towards the farthest part of the subject in tiny steps, pressing the button each time. He ends up with a number of separate pictures, each with a different part of the subject in focus. Then what? Well, he doesn't say to his friends look, here's a fly with part of its left eye in focus, and in this picture you can see the same fly with one antenna in partial focus. No no no! He combines ALL the images into one single end result, taking the best bits of each image and discarding the out of focus bits. This can be a massive project. Take the fly: if one picture, taken at an aperture small enough to avoid diffraction, let's say f/8, has enough depth of field to cover just one tiny sliver of one compound eye, then how many pictures will it need to fit the whole fly into focus? Down at this level of magnification the answer is dozens, and dozens, and perhaps more dozens.

In my examples below I don't go down to the tiny level of a dead fly, but I've chosen three scenarios - still lifes - which are small enough and thus require the camera close enough, that no single shot can provide enough depth of field to get the whole still life nice and sharp.

Scene One - The Coloured Pens

Here I've arranged 8 coloured felt tip pens in parallel, leading away from the camera. In this experiment the camera (Pentax K-1) was mounted on a very firm tripod and had a Pentax 100mm macro lens mounted. I used ISO 200 and an aperture of f/8. Exposures were around half a second. I just took 8 pictures, with a different pen in focus each shot, going front to back. You can't achieve reliable focus positioning by peering through the viewfinder, so I was using Live View, in which what the lens sees is displayed on the screen. I switched on Focus Peaking, which causes a highlight to appear around in-focus parts of the picture.

In this picture:

you can see that the pink pen was in focus

and in this one:

the penultimate pen, the purple one is focussed.

After focus stacking the 8 originals, here is the result:

Perfect focus, from front to back. I'm prepared to guarantee that such depth of field would be impossible with normal cameras and lenses, and the only way you could get this picture with a single shot would be to use an extraordinarily expensive and complex large format view camera with its lens tilted.

Scene Two - A Random Still-Life

I think my next scene is perhaps more impressive. It's a group of simple objects displayed on a grey towel (no expense spared here) ranging from about 12 to about 30 inches from the lens. This scene required 14 individual exposures in which, as before, focus was progressively moved away from the camera. Here are a couple of examples:


You can clearly see how narrow the depth of field is in each of these pictures.

But focus-stacking the 14 images provided us with this:

Which I think is quite remarkable! (Even though I seem to have slightly missed focus on the brown pen.) The watch seen in the picture was not running - I wonder how the focus stacking software would have dealt with the stack if the second hand had been moving?

Scene Three - Coins of the Realm

In my final example I'm really pushing things, and achieving a result which I believe no camera ever made could match in a single exposure. The scenario is six coins arranged in a column leading away from the camera, at distances ranging from something like 4 to 10 inches. The depth of field in each image was impressively tiny, and I took 37 separate pictures. Here are a couple of individual shots:


You can clearly see how tiny the depth of field is.

Yet, stacking all 37 pictures gives us:

Wow, I'm going to say that this is just extraordinary! What do you think?

My examples here have been kitchen-worktop/old grey towel setups. But why should focus-stacking be limited to macro work? Why not go out somewhere with scenery, set the camera on a low tripod, and snap away, covering that tiny flower just inches from the lens right up to the distant snow-capped mountain? The possibilities are endless!

All very well, I'm impressed, but .... HOW???

So far I've shown you what can be achieved with focus-stacking, but how is it done?

Well, one way would be to bring each picture into PhotoShop (or similar) on its own separate layer, then you could manually mask off the out-of-focus parts of each layer with a virtual brush, thus making them transparent and allowing only the good bits to shine through - if you've got hours to spare, that is, because it's a time-consuming business.

Or you could use a software product, loading each of your pictures into it in a group, clicking 'Go', and waiting while it does everything for you. There are a few around, but I used a product called Zerene Stacker for my work. It's very simple, but very clever. You simply select the pictures, drag them over to the left hand pane of the software, and watch the right-hand pane as the end result is built up. It just knows what's in focus and what isn't! It will even attempt to align the pictures if, for example, the tripod moved slightly. The other major player in the field is called Helicon Focus, which I haven't tried, but I daresay it's equally clever.

If you want to have a go at stacking - and you really should - you can get hold of 30-day trials of both Zerene and Helicon and see which you prefer.




I've put album of various other stacks and explanation on the next page. Please have a look. I'm proud of this work!