Sep 11 2008 - Focus Stacking or Creating Infinite Depth of Field With Multiple Images
is another blog in the model photography series. In an earlier blog I talked
about the importance of depth of field in model photography.
In this image, the engine is in good focus but the trail crew is not.
However, sometimes no matter how small you make the aperture on your camera, you can't get enough depth-of-field, especially if you are close to the subject or using a long telephoto lens. In smaller scales, Z or N, this becomes an ever larger problem as the camera gets closer to the subject. Take for example the image to the left - the foreground is unfocused even though I used the smallest aperture on my Olympus lens, f/22.
With focus on the foreground, the crew is focused but the engine is not
In this second image, the focus plane has been moved to the foreground which has brought the trail crew into good focus but now the locomotive has become fuzzy. What about using an even
smaller aperture? As you go to smaller aperture, the tiny opening is
subject to edge diffraction effects (you can see diffraction when you
look through a fine screen such as a piece of fabric at a bright
point light). Actually this diffraction is always there, but at larger
openings it is just a tiny fraction of the light. As the opening
becomes smaller, it becomes noticeable and the edges of objects will
get blurred. This lack of depth of field becomes one of the giveaways that a photograph is of a model and not full size. So what is the solution?
Stack Focused image - 10 images of different focus combined together in such a way that the sharpest pixel is always kept.
Focus stacking - the Digital Answer
There is a nice solution to this problem for digital photography using software algorithm called "Focus Stacking". I first heard about this at the Model Railroad Hobbyist Website in a blog posting there. In this neat solution, a "stack" of images that are focused at successive planes, but are otherwise as identical as possible, are loaded into a special program and processed into a new image. In the new image the best focused are is kept from each image so that the final image is well-focused everywhere. There is a bit more to the algorithm because the position of objects moves as the lens is focused and the apparent brightness will change shift slightly as the focus changes. The software can take all this into account and produce an excellent image in most cases. Obviously, if there is no image in which an object is in focus, then it will still be unfocused in the final image. If the camera moves during the focusing, the software may not be able to compensate fully, so be sure to use a tripod or place the camera securely on the layout while taking the images.
The method is not perfect as artifacts can be added by the software, especially at edges. However, the artifacts are usually minor especially for photos that are going to be made into jpegs and shared on the web.
At the time of this writing, the Wikipedia article on Focus Stacking lists 5 programs you can download to focus your images. I tried 4 out of 5 of these programs and found hey were not all equal in performance.
The "Extended Depth of Field" plug-in for ImageJ did not work well on this stack of images.
I found that 2 of the programs, CombineZM and HeliconFocus, both did an excellent job. Helicon is the easiest of the two o use, but requires a license fee. CombineZM has a few quirks, but once learned it works nicely. It took me a long time to figure out that I needed to use the Macro/Do Stack command to prompt the program to process the stack into a final image. I suppose reading the manual might have been in order :-). CombineZM leaves a mirror artifact around the edge of the image, but this can be easily cropped within the program by selecting the good bit and using the File/Save Rectangle option.
Alas, I was unable to get the ImageJ plug-ins to work well. ImageJ is a very useful program in its own right and being Java it works on most platforms and is freely usable Open Source software. I tried for a long time to get both Extended Depth of Field (see the image to the left) and Stack Focuser to produce images of the quality of the other two programs, but, alas, I was unable to. I suspect that these programs are meant for image stacks that are closer together as would be produced in micro-photography. Note the extreme artifacts around the telephone pole in the image to the left.
Now, I don't mean to condemn this software, perhaps I did not use it correctly or was unaware of a flag that would fix the artifacts. If anyone has an answer to the issue, please let me know.
An image down the street in Ogden focus stacked with HeliconFocus. I put the camera directly on the layout and there was some jiggling between pictures as I pressed the shutter and the software still did a great job.
I can see that Focus Stacking is going to be a really useful tool for improving the pictures of my layout and models! I hope you have a chance to give it a try.