Focus Stacking Macro Photographs with a Hacked Flatbed Scanner


Focus stacking is when you combine multiple photographs of different focus distances in order to obtain a single photo with a much greater depth of field than any of the individual shots. This can be done by turning the zoom ring on your lens, but this can be difficult to control (especially for highly magnified photos). It can also be done using special rigs designed for the purpose, but those are generally quite pricey.

Photographer and software engineer David Hunt recently came up with the brilliant idea of turning an old flatbed scanner into a macro rail for shooting focus-stacking photos.

Hunt writes that the main question was whether the scan element could support a hefty DSLR and lens:

I came up with the idea of re-purposing an old flat-bed scanner that I had in the attic gathering dust. It’s so old, that the most recent drivers available for it are for Windows XP. So it hasn’t been used in a couple of years. Being a scanner capable of 2400 dpi, it was definitely accurate enough, but would it be able to move a 3KG camera and lens? If I could get at the stepper motor to drive the scan element, maybe I could attach a camera to it and move it in very fine increments, ideal for macro photography.

After opening up the scanner, Hunt found that it didn’t require too many additional modifications. There was already a nice flat platform for the camera to rest on, and the movements were small and smooth enough to not jar the camera between shots.

In addition to the scanner, Hunt uses a Raspberry Pi to serve as the brains of the rig. The single board computer connects directly to the stepper motor interface of the scanner, and can move it at various speeds. Hunt uses it to move his camera towards his subject in increments as small as 0.02mm, with an exposure snapped at each stop.

Here’s a video showing the rig in action:

Here’s a before-and-after comparison showing what a single exposure looks like and the increased depth of field that is achieved by stacking a large number of them:


Head on over to Hunt’s blog if you’d like to examine some of the more technical details of the project, including the Python code he wrote to move the scanner mechanism at tiny increments and to trigger his camera’s shutter.

Macro Pi – Focus Stacking using Raspberry Pi [David Hunt via Imaging Resource]

P.S. Hunt is the same photographer who turned his broken battery grip into a tiny computer for controlling his DSLR.

Image credits: Photographs by David Hunt

  • Mansgame

    Can’t he just change the focus point on the camera whether manually or using the af points for each picture in the stack instead of moving the camera?

  • Nicholas Butler

    you can take a single photo with a smaller aperture to aquire the same affect..

  • Mansgame

    There are limits -especially with macro where you have a very narrow DOF. Still I think 3-5 f/16-22 pictures for the stack would have been enough so this is one of doing something just because he can rather than it being practical.

  • Pat David

    There are nasty diffraction limits that you’ll hit before the aperture is small enough.

    Funnily enough, I had just written a tutorial on the software side of this, taking the focus stacked images and combining them with the open source Enfuse:

    I think CombineZ is free, but I just happened to already have enfuse installed as part of Hugin.

  • Ultima Gaina

    Using the a manual focus work up to a certain extent, but i found that:

    1. the framing is slightly changing when you adjust the focus instead of relatively moving the object or the camera

    2. you don’t have enough accuracy, and i might realize that you missed a focusing step therefore you might end up with a blurred “ring” in the middle of your picture

    What I would suggest, is to keep the camera fixed (on a sturdy tripod) and put the subject on the automated rail. The camera is much heavier that the insects and other tiny objects this system is designed for. A heavy camera+lens will impact the accuracy of these micro-movements.

  •!/thelonelylights Adam Cross

    I’ve found the focus stacking feature in Magic Lantern to be pretty good, I don’t shoot macro but I tested it out since it’s there and I was really impressed, better than doing it all manually anyway – but this scanner idea is genius ^_^

  • Mansgame

    very informative…

  • Stan

    At what aperture did he shoot the individual frames?

  • JanKarloCamero

    Pretty neat!! Ive been doing some Raspberry Pi projects at work and a stepper motor is a good application for this. Since Macro shots require really stable surfaces, this tool is a welcome addition in a photographer’s arsenal!

  • 15MinuteNews

    100mm Macro, my favorite lens. Nice idea, must be pretty sturdy to hold the camera and lens and still drag it along.

  • Mack21

    i have never needed that…. i just change the focus.

    there is enough software who does it automatically.
    helicon focus for example.

    and i bet nobody would see a difference to this approach.