Focus Stacking

What and Why?

If you have done any Macro Photography, you will have come up against the problem of very shallow depth of field. So for example on a flower, the stamen may be sharp, but the rest of the flower out of focus. Sometimes that is used to advantage, but at other times you would want to see fine detail in the rest of the plant.

Focus stacking is a way of doing that. It is achieved by taking a series of photographs, focussed further and further into the subject and then processing them all to produce a single picture which only shows the parts of the various images which are in focus. It does that by using layers and layer masks, as described in this tutorial.


However you are going to process the photographs, the initial stages are the same – getting a range of images, each with a part in focus.

Start with a tripod, giving as firm a base as possible, a camera and macro lens, a remote release and a steady hand. If you do not have a remote release, then a 2 second delay will give the camera time to steady before shooting. If the final images are still not perfect then SLR users may wish to use mirror lock-up. Image stabilisation, if available, should be switched off on the lens whilst on a tripod.
Each image needs to look identical in terms of positioning, light and contrast, so the camera should be on manual focus, iso=200, with f/stop and exposure also set manually. f/stop should be a high number, to give as much depth of field as possible, though probably not on its limits, where lenses tend to be softer. Time to experiment!

Focus on the nearest part of the image, take the shot and then focus further into the image, taking that and so on until you have as much of it as you wish. You will now have several images – identical, except for the point of focus.

Layers and Masks

The final image will be created by making each image a layer in one final image. That is achieved differently for Photoshop CC and Photoshop Elements, as described below.

A mask is attached to each layer (image). When first created, a mask is White, so the main picture shows just the top layer. If any part of the mask is Black, then that part of the associated layer is transparent, and the layer below becomes visible. So if only the in-focus part of the top layer is painted White on the associated mask, then the rest of the image below is visible. If the next layer is selected and the associated mask painted black in the out of focus areas, then the next layer becomes visible and so on down the stack.

In the end, only in-focus areas are visible, plus any out of focus areas in the bottom layer which haven’t been included in the layers above.

It is as easy as that 😀. (You may want to read that again, or follow through the detailed instructions, when it will become clearer).

Photoshop CC 2015

Photoshop CC has the advantage of a script to make all the images into layers and a facility to create the mask, exposing only in-focus areas of all the images. The workflow is:

  1. Rename Files as taken to image_1.jpg to image_x.jpg where x is the number of images. The name can be whatever you want, but the index number (1 to x) is useful, so that 1 is the nearest to the lens as taken and x is farthest away. The nearest to the lens should be at the top of the folder, and so at the top of the stack.
  2. Start Photoshop
  3. File>Scripts>Load Files into Stack….
  4. Browse to files >  Select images > Open > OK (Click on first, hold down shift key and click on last to select all)
  5. In Photoshop, select all Layers
  6. Edit > Auto-Blend Layers
    1. Stack Images
    2. Seamless Tones and Colours
  7. OK
  8. Save image as jpg

You should have an image which incorporates all of the in-focus parts of the images.

If you wish to correct a selection, then click on the layer to select it and then on the mask to select that. Paint on the image – Black to make that part of the layer transparent, white to include it in the final image. Remember, though, that anything in a layer below white in the mask will no longer be visible.

Photoshop Elements is more “manual” and will be included in a separate sheet.