In-Camera Focus Stacking

Focus stacking in Lumix cameras

Broadly speaking, the extent of the depth-of-field in any image is a function of the aperture used, the focus distance, the focal length of the lens and the size of the camera’s sensor. Small apertures help to create extensive depth of field, as do distant subjects, wide lenses and small sensors. You’d think it would make sense to use all of these tools when we want to produce an image that is sharp from the closest object to the furthest away, but unfortunately it isn’t that straight forward. There are a number of reasons we mightn’t want to use a wide lens, for example, so we need to find alternative ways to tackle depth-of-field to control the way focused areas in our images look. Panasonic’s Focus Stacking function is designed to do just that.

What is depth-of-field

To refresh your memory, depth-of-field is the term used to describe the zone in an image that appears sharp. Depth-of-field is measured from the closest part of the scene that is sharp, to the furthest part. When the closest and furthest sharp objects are a long way apart the depth-of-field might be described as ‘extensive’. When those two points are close depth-of-field is ‘shallow’.

Focus stacking in Lumix cameras
Setting the lens to f/2.8 in this example might only render the cat in focus but, with the focus point still on the cat, switching to f/22 might get the tree in focus at the same time. When only the cat is sharp the depth-of-field is described as ‘shallow’, when the tree is sharp as well the depth-of-field is ‘extensive’ – or deep.

The struggle

Often we want an extensive depth-of-field but find it difficult to achieve. We might need a long lens for the perspective the image requires, and then find that even the smallest aperture doesn’t render sharp everything we want to appear in focus. With any focal length we’ll also find that the smallest apertures don’t produce the sharpest images because something called diffraction begins to make edges softer as apertures close beyond the middle of the f-stop range. Usually the best apertures are in the middle of the range – between f/4 and f/8 for Lumix lenses. Closing down any more, to f/11 or f16 for example, might achieve more depth of field, but the subject will look softer because of the way light spreads out as it passes through a small hole.

Sometimes we want to combine an extensive depth-of-field with a subject that is very close to the camera – in macro photography for example. With close subjects depth-of-field is especially shallow, so it is very hard to get front-to-back sharpness by the usual means.

On the plus side, for those wanting lots of depth-of-field Lumix cameras use small sensors and lenses with shorter focal lengths – which both help to extend the zone of sharp focus in all situations.

The Solution

Many modern Lumix models offer a Focus Stacking function that helps users to precisely control the depth of the zone of sharp focus in their images. The feature works by shooting a series of images at different focus distances which get combined in-camera to create an image in which everything we want to be in focus is in focus.


An extension of the 4K Photo and Post Focus modes, the mode shoots a short 4K video during which the focus of the lens is racked from the closest object to the furthest – then the sharp areas of each of the frames is combined to generate the final image.

Focus stacking in Lumix cameras
This not only makes it easier to create scenes in which everything is focused, but also for us to use the best apertures of our lenses. As we aren’t relying on aperture to deliver depth-of-field we don’t need to use f/22 and suffer the softness that comes with diffraction – we can use f/4 and get the best from the lens in every frame thus rendering every part of the scene with the optimal aperture for the lens.

Focus stacking in Lumix cameras

This panel shows how depth of field is extended as the lens aperture closes, but even at f/22 we can’t get the handle and the top of the subject in focus. Using the focus stacking function though makes it possible to render both areas sharply. The focus stacked image is smaller in this panel because it uses 18.7MP instead of the full 20MP.

 

Front-to-back, or selective

The mode allows us to determine how much depth-of-field the final image will have by offering us Range and Auto merging options. In Auto Merging the camera blends all the frames taken in the clip and produces an image in which everything will be sharp, but the Range Merging option allows us to use the rear screen to touch the objects we want to be sharp – then the camera only blends that range. The range will be continuous from the closest object touched to the furthest, thus producing the effect of a wider aperture than a full merge.

Why Range?

Focus stacking in Lumix cameras

You might think that using the Range option to create a shallow depth-of-field only delivers the same effect as setting a wider aperture, but actually the effect is quite unique. Shooting a normal portrait at f/1.2 with the Nocticron 42.5mm f/1.2 lens, for example, will give us the kind of mad out of focus background that we love – making the subject jump out of the frame. Only the subject’s eye will be sharp though, and if we want to get the whole head focused we’ll have to close down to f/8, for example. Closing the aperture to f/8 will alter the way the background looks, rendering it much more detailed, focused and distracting than at f/1.2. If we use the Range Merge feature we can achieve the same zone of sharpness for the subject’s head as we would at f/8, but at the same time retain the mad out of focus background of f/1.2. And that gives our pictures a unique feel.

Focus stacking in Lumix cameras

Selecting areas destined to be focused in the final image from a Range Merging focus stack

Restrictions

Obviously as this is in effect a multiple exposure technique it works best with the camera on a tripod shooting a stationary subject. You can shoot hand-held but success rates might dip a little – but only a little – though moving objects won’t be rendered well. We are shooting video so flash and flickering light sources don’t work either, and the end result will always be a JPEG.

In most of the Lumix models the JPEG will come from the 4K Photo mode, and thus will be 8-million-pixels. The GH5 and G9 offer 6K Photo, so we can get 18.7MP images that measure 3744×4992 pixels.

The mode works best with the closest and furthest objects aren’t miles apart. When the focus distance changes during the video clip the size of objects in the scene will also change. This can make it difficult for the camera to blend the images together convincingly if there are extreme focus distance variations. If you find your final result has odd areas you can try merging it again which will often produce a different result. Sometimes you just need to shoot it again though, so try to merge on the spot and check the results before moving on.

Getting the best from the mode

As we are going to end up with a JPEG it makes sense to pay attention to the JPEG settings we are using. All the Photo Styles are available in the Focus Stacking mode, as are iDynamic and the Highlight/Shadow controls that will help to tailor the image to the way you want it. Use the controls within Photo Styles to adjust contrast and saturation further, or use the Artistic Filters to apply a ready-made style that won’t need editing after. Some items, such as the Grain in Monochrome, aren’t available in this mode but the majority of filters and styles are.

Focus stacking in Lumix cameras

The final image made with the Auto Merging stacking option. The picture was made by the Lumix G9 with the Leica 45mm f/2.8 macro lens, set to f/2.8

Tags: , , , , ,