Thursday, June 26, 2008

Introduction: Understanding and Fixing Compact Camera Images

This is the first of several posts where we'll look at the characteristics and problems with compact consumer digital camera images and work out ways to deal with them. I recently decided to dust off my panoramic tripod head and try it out with the Canon G9 compact consumer camera. Setting up the panorama head to get the entrance pupil of the lens centered on the horizontal and vertical axes was simple. More time consuming was measuring and automating the correction of the G9's images so that they could be used effectively for high-quality stitched images.

First, these are the assumptions going into this series. The average person won't go to the lengths discussed here to squeeze the most quality out of the camera's images. (But you aren't an average person). I'm using the Canon G9 camera as an example but the concepts and techniques apply to any digital camera in this class. Furthermore, for simplicity and because I'm doing this ultimately for use in wide-angle panoramas, I'll only discuss the shortest focal length (7.4 mm). The same issues and techniques apply to other focal lengths in the zoom range but let's not get too buried in detail. Finally, while some of this discussion is of most obvious use when the goal is trying to stitch images together, the techniques can be used to greatly improve single images as well.

Let's start by discussing sharpness and depth of field. If you're not familiar with the concepts, head on over to the superb tutorials at the Cambridge In Colour site and get acquainted with depth of field and hyperfocal distance concepts. Because of the tiny sensors in the compact consumer cameras like the G9, the depth of field is very deep compared to a dSLR, for example. I prefer to use the more conservative Leica proportional circle of confusion size for calculations. For the G9's size, the standard assumed circle of confusion size used to determine what is in focus is 0.006 mm but I'll use the slightly smaller 0.005 mm size for added insurance. At that size, and the 7.4 mm focal length lens set at its widest aperture (f/2.8) the hyperfocal distance is 12.7 feet. That means if you focus at 13 feet, everything from a little over 6 feet away to infinity will be in focus. And that's the shallowest depth of focus you can get in this camera! At f/4, the hyperfocal distance is 9 feet meaning everything from 4.5 feet to infinity will be in focus. That should suit all but the most extreme requirements for depth of field, but the G9 will go all the way to f/8.

The problem with going beyond f/4 is that the G9 (and similar cameras) is diffraction-limited at f/4. That means that if you close the aperture down smaller, you will get greater depth of field but the overall image sharpness will decline due to diffraction effects. There may be extreme cases where f/4 just isn't sufficient and you're willing to pay the price of the image degradation to get the extended depth of field. For me, however, I'm sticking with f/4 and focused at 9 feet for the bulk of my work with this camera. In fact, I've set the custom settings (C1 and C2 on the G9) to be aperture-preferred f/4, manually focused at 9 feet. I turn on the camera, dial to C1 and I'm set to get the sharpest images with the most depth of field without any more fuss. (Obviously if you're subject is closer than 4.5 feet you need to override this.) I set up the C2 custom set the same way but added a 2 second timer delay to the settings so that I can trip the tripod-mounted camera shutter and get my hands off before the shutter fires. That greatly reduces the chances of vibration blurring.

The following example image was shot at the shortest focal length (7.4 mm), widest aperture (f/2.8), and focused at the hyperfocal distance of 13 feet. The Cyclamen flowers 6 feet away are sharp, as are the leaves on the trees behind the house. Only the closest stretch of fence rail on the right is showing focus-blurring.



By the way, if you do frequently use the camera in closer and still need to manage the depth of field closely, go to www.dofmaster.com and get the DOFMaster Depth of Field Calculator program to make your own depth of field calculator. Using this a little bit is a real eye-opener when you see what happens when you change aperture or focus distance.

The next series of posts will explore analyzing and fixing the images that come out of the camera. We'll fix vignetting, lens distortion, and transverse chromatic aberration. Your images will look better than ever. Meanwhile, get familiar with hugin panorama photo stitcher software. It's free and, even if you never do panoramas, it includes a command called fulla that we'll be using to correct our image flaws. It's a command-line utility, not a windows program, but that works to our advantage to automate image correction.

Saturday, June 7, 2008

Selective Focus Stacking


There are three controls commonly used to select what is in focus in an image: selecting what the lens is focused on (obviously); varying the aperture to control the depth of field; and tilting the plane of focus (via tilt/shift controls on a view camera or a PC lens on a SLR). Using these, even combined, sometimes won't create what you want. Suppose you want a fairly deep zone in focus and everything else way out of focus. The aperture control can give you a deep zone of focus when stopped way down but it either may not be enough or it may make other elements sharper than you want. If you open the aperture up, you get the nice unfocused surroundings but with a very shallow zone that's in focus. We want to get the best of both extremes.

This is where focus stacking comes in. Focus stacking entails taking several identically-exposed images from the same vantage point, but with each one focusing to a different depth of the subject you want in focus. Specialized software then combines the images, selecting the sharpest portions of each image and creating a single image with often remarkable depth of field. Focus stacking is commonly used in macro- and microphotography where depth of field is miniscule even with the aperture closed way down.

You can use focus stacking in a slightly different way. Open your aperture way up (giving a very shallow depth of field and nice unfocused surroundings) and shoot several images varying the focus through the depth of the region you want in focus. Combine with focus stacking software and you can get an image with the main subject in sharp focus front to back, and the surrounding depth nicely out of focus.

The example image of a rose blossom on a piano keyboard was shot with 5 exposures with focus ranging from the near tips of the petals, to the far edges of the sepals behind the blossom. The 50 mm lens was wide open at f/1.4 for these exposures giving a very soft image except for the vary shallow zone of focus where the lens was focused in each image. Combine the stack in the software and you get the rose blossom and sepals razor sharp front to back with everything else nicely blending to gauzy tones. You won't be able to get this effect in any other way.

This particular image was created using the freely-available CombineZM focus stacking software, but there are several other choices of software that can do the same thing.