Tamalpais Valley Railroad

We move stuff there and back again

 

Home

Community

Contact

Humor

Links

Wireless DCC

Arduino

Articles

Micro Book

X2011 Convention

LED Lighting

Donner Summit Progress

Feb 18 Frog Power

Jan 18 DIY DCC Decoders

Jan 8 - Donner Summit v3

Jan 6 09 - Slim Princess

Oct 23 - Sound Xperiment

Oct 15-Construction Start

Sep15 - Main St Colfax

Sep 1 08 - Focus Stacking

Aug 15 08 - Colfax Depot

Aug 4 08 New Layout 2

Jul 31 08 New Layout Plan

Jul 22 08 - Snow in Ogden

Jul 19 08 McCloud Railway

Jul 8 Solar and Profits

Jun 27 08 AC-12 4294

Jun 23 08 Donner Trip

Jun 19 08 SP GP9 #5623

Jun 18 08 Depth of Field

Jun 16 2008 Craftsman Kit

Jun 15 2008 Cab Forwards

Jun 14 2008 Rivet Count

Jun 13 2008 Why?

Jun 12 2008 White Balance

Jun 11 2008 Photography

Blog

Gallery

Gallery 2

Videos

Construction

How-to

Water

Trees

Grass

Terrain

Servo Switch Decoder

Trackplan

Prototype

SP Railroad Atlas

Sep 11 2008 - Focus Stacking or Creating Infinite Depth of Field With Multiple Images

This 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. 



Which Software?

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.

Next->


Blog List
Jan 6 09 - Slim Princess
Oct 23 - Sound Xperiment

Oct 15 - Construction Started
Sep 15 - Main St Colfax
Sep 1 - Focus Stacking
Aug 15 - Colfax Depot
Aug 4 - Donner Summit 2
Jul 31 - Planning the Next Layout

Jul 22 - Snow in Ogden
Jul 19 - McCloud Railway
Jul 8 - Solar and Profits
Jun 27 - AC-12 4294
Jun 23 - Donner Pass Trip
Jun 19 - SP GP9 #5623
Jun 18 - Depth of Field Test
Jun 16 - Craftsman Kit
Jun 15 - Cab Forwards
Jun 14 - Counting Rivets
Jun 13 - Why MR is cool
Jun 12 - White Balance
Jun 11 - Photography

RSS feed

Blog List
Oct 13 - Construction Started
Sep 15 - Main St Colfax
Sep 1 - Focus Stacking
Aug 15 - Colfax Depot
Aug 4 - Donner Summit 2
Jul 31 - Planning the Next Layout

Jul 22 - Snow in Ogden
Jul 19 - McCloud Railway
Jul 8 - Solar and Profits
Jun 27 - AC-12 4294
Jun 23 - Donner Pass Trip
Jun 19 - SP GP9 #5623
Jun 18 - Depth of Field Test
Jun 16 - Craftsman Kit
Jun 15 - Cab Forwards
Jun 14 - Counting Rivets
Jun 13 - Why MR is cool
Jun 12 - White Balance
Jun 11 - Photography

RSS feed

Subscribe in a reader
Blog Roll

Confessions of a Model Train Geek
CNJ Bronx Terminal
Modelrailroading.wordpress.com
Dan's Train Blog
Lebanon Railroads
Westport Terminal RR
Rob Hinkle's Blog
Espee Mike



© Copyright 2012 by Duncan McRee, All Rights Rreserved - dmcree at tamvalleyrr dot com

Website powered by Network Solutions®