What is focus stacking? :: Digital Photo Secrets

What is focus stacking?

by David Peterson 5 comments

At some point, just about every photographer turns his attention away from those more obvious subjects, and points his camera at the things that we don't often see—those tiny, thumbnail-sized things that we pass by every day but rarely stop to appreciate. Macro photography is a very attractive genre for many photographers, and it's becoming more accessible as camera technology improves, and the cost of dedicated macro lenses goes down.

But if you started shooting macro without a whole lot of formal instruction, you may have noticed that your macro shots don't look like a lot of those beautiful macros that you've admired on Flickr, or in magazines like National Geographic. To understand what I mean, keep reading.

[ Top image Pedro Aphalo by Flickr user aphalo]

First, let's take a look at a couple of examples:

  • Nikon D7000
  • 800
  • f/4.0
  • 0.004 sec (1/250)
  • 90 mm

Gerbera daisy 2 by Flickr user squesada70

    Stacked Gerbera-2 by Flickr user Gewel Maker

    In the first example, you see what is probably more typical of the sort of macro photo you take. You have a very sharp area in the foreground, but the sharpness drops off radically the further away from the lens you get. The second image is very similar, except that you don't have that same depth of field issue. The sharpness that begins in the foreground is maintained throughout the shot, even in the more distant parts of the subject.

    Why does this discrepancy exist, and what did the second photographer do that the first one did not?

    Depth of field at macro ranges

    If you haven’t really spent a lot of time with very small subjects, you may think the answer is obvious: it’s aperture. Logically speaking, it seems as though you should be able to get good depth of field in those macro images as long as you're dialing in that narrow aperture of, say, f/22 or even f/32. But the reality is different than what logic tells you. Why is that?

    The reason why you're not able to get good depth of field at macro images is because of the distance between your lens and your subjects. When you get very close to a very small object, your depth of field decreases significantly, even at narrow apertures. And that's not something that you can change, because your aperture can’t get any narrower than what your lens allows. There are a few semi-successful tactics that can improve focus across the object: you can zoom out so there’s greater distance between your lens and your subject, and then crop closer in post processing, but this isn’t a great solution because you won’t capture as much detail if you’re not very close to your subject. You could also orient your camera so that it’s parallel to your subject, which will give you consistent focus, but that can produce an image that doesn’t seem to have a lot of dimension. So how did the second photographer achieve such startling depth of field in his image? The answer is that he didn't.

    Instead, the second photographer used a technique called “focus stacking.” The image that you're looking at isn't a single image as it came out of the camera. Rather, it is a compilation of images. The photographer essentially shot a series of photos using different focal points, starting from the point closest to the camera and finishing with the most distant point. He then combined those images in post-processing until he got what you see before you—an image that is tack-sharp from foreground to background despite the fact that it is a macro.

    In camera: how it’s done

    Some professional macro photographers use a macro rail for focus stacking. This is basically just a device that attaches to your tripod, which allows you fine control over how close your camera is to your subject. Rather than changing the focus on the camera itself, focus is changed via camera position. When the camera moves, the focus point moves, too. The photographer increments the camera down the rail, taking a photo at every stop, until he has all the images he needs to make a complete photograph. Using this technique, you’ll get a series of images that have slightly different magnifications, but focus stacking software is designed to compensate for those differences (and even slight differences in camera position that can happen when you bump your camera).

    Of course, macro rails don't come without some challenges. When you move the camera, for example, you can also get changes in perspective, which can make it hard to stitch the image together in post-processing without some ghosting. Macro rails are best for very small objects shot with longer macro lenses.

    For most people, simply changing the focus in camera is going to lead to good results. You can get a super-precision focusing screen to help you with this, which is an add-on for your camera that makes it much easier to precisely focus on individual points on your image. Autofocus is out—make sure you’re in manual focusing mode because the difference between one focus point and another is going to be much more slight when manually focusing than the difference between your camera’s built-in focus points.

      Coffee beans macro, focus stacking by Flickr user Fæ

      The number of photos you will ultimately have to take when focus stacking depends greatly on what your subject is. If it's a subject with a flat surface such as a leaf you won't have to do any focus stacking it all, if it's not completely flat you may need two or three images, and if it's very wide or broad or at an extreme angle to the camera, you may need as many as 20 or more exposures in order to achieve that tack-sharp focus from foreground to background.

      What you need

      Again, a tripod is essential for this sort of work, and you will find it helpful to use one with a ball head or pistol grip so that you don't inadvertently move your camera between shots. A remote release is almost as essential as the tripod, so you will not only keep camera shake out of the shot but so you won't accidentally bump the camera’s position when you touch the shutter button. If your camera is a DSLR, it's a good idea to engage mirror lockup—that way there will be no vibration added when the mirror moves prior to the exposure. This is important with macro because any vibration is actually magnified at those macro ranges, even if it's not something you would ordinarily notice in a non-macro photo.

      Camera settings

      Shutter speed is only important for focus stacking if you are shooting in low light, which is not really advisable. Long shutter speeds may generate thermal noise, and it is critical that you keep noise out of your macro images because noise can obscure detail and make your image appear soft. For this reason, you also need to be shooting at the lowest available ISO. Contrary to what you might assume, you should use a middle-range aperture rather than your camera’s narrowest aperture, because very narrow apertures don’t tend to produce images that are as sharply-focused as mid-range apertures are. Most cameras achieve maximum lens sharpness at around f/5.6 or f/8.

      The focus stacking procedure is relatively simple, if repetitive—if you're using a focusing rail simply turn the focusing rail knob while looking through the viewfinder until you see the closest part of the subject come into focus. Stop there and take a photo. If you're not using a focusing rail, you can manually twist your focusing ring, however be aware that your camera needs to remain in the same position for each one of these photos, so any bump to the left or the right may cause some distortion in the images. Again, focus stacking software is designed to take into account slight differences between images, but if the perspective changes enough your results are going to be disappointing, so it’s best to avoid bumping your camera if at all possible.

      Take the first shot using your shutter release and wait a few seconds for the vibrations to cease, then move the camera again or rotate the focusing ring until the next area comes into focus. Repeat the process until you have taken a shot of every focus point from the nearest to most distant from the camera.


      You need good post-processing software in order to master focus stacking. The latest versions of Adobe Photoshop have this feature, but most pros will tell you that you’ll get the best results if you use dedicated software that is designed exclusively for focus stacking (some of which is freeware).

      Open up your focus stacking software and load the photos into the software. You'll want to make sure that you're loading the photos in the same order as you shot them so the focus stacking software can correctly align the images. Depending on what software you're using, the procedure will be slightly different, but let’s look at how it’s done in Photoshop since this tends to be the more often-used option.

      First open up the photos in Photoshop in the order that you shot them. Now select all the photos and choose edit > auto align layers. When the layers are aligned go to edit > auto blend layers. When the software is finished processing, you may notice that the edges are slightly out of focus—you're going to need to crop the image to get rid of those areas.


      That’s it in a nutshell, however you may find there's a bit of a learning curve when it comes to getting those focus points exactly right, so practice makes perfect. If you're finding that you're not getting good alignment with the focus rail, remember that you should only be moving forwards and backwards, not to the left or the right or you will have problems with perspective that can’t easily be corrected in post-processing. If you're still finding it too complex, switch to manual focus and practice focus stacking with your focus ring until you've mastered it. Then go back to using the focus rail and see if you can perfect your technique.


      1. How to focus stack
        • Use a focus rail, or
        • Manually focus on different parts of your subject
        • Shoot as many images as you need (up to 20 or more)
      2. What you need
        • A tripod
        • A remote release
      3. Camera settings
        • Use a low ISO
        • Use a middle-range aperture (f/5.6 or f/8)
        • Move your focus point incrementally for each shot
      4. Combine images in post processing

      Most people think this post is Awesome. What do you think?


      1. Roz says:

        Thank you for a clear and concise explanation of something which I thought sounded a bit daunting. Looking forward to putting this into practise.

      2. BT says:

        I tried this using Photoshop and another program in Winblows 7. Usually, Winblows crashes the program when it tries to use the scratch disk or virtual memory.

      3. Patrick says:

        Could anybody tell me which software for photostacking works with photoshop elements, or runs separetly

      4. Cecilia Prest says:

        Hi David, which freeware software would you recommend? Thanks for posting this- as usual, very well explained!

      5. Chris W. says:

        Very clearly & concisely written. Now I have a good basic understanding of this advanced technique. Thank you.

      Leave a Comment

      Your email address will not be published. Required fields are marked *

      14 minutes
      About David Peterson
      David Peterson is the creator of Digital Photo Secrets, and the Photography Dash and loves teaching photography to fellow photographers all around the world. You can follow him on Twitter at @dphotosecrets or on Google+.