Friday, December 26, 2008

Look Sharp!

Every once in awhile I come across images on the Web that look unusually crisp and sharp. But not in a bad way with obvious halos and other over-sharpening artifacts in images almost as common as those that look too soft. After tinkering with a few approaches, I've settled on a method that works well for me.

For a long time, I've been a big fan of PixelGenius's PhotoKit Sharpener, a suite of Photoshop tools for image sharpening based on the seminal work of Bruce Fraser and other authorities. Although I still use it exclusively for all sharpening aspects in my printing workflow, I've sometimes been less enamored of the results for Web sharpening.

Until recently, I used PhotoKit Sharpener to do capture sharpening and then used Photoshop's bicubic sharper algorithm for resizing down to Web territory. I've been relatively pleased with the results but looked around for a little extra boost.

After reading up on clinical comparisons of resampling algorithms (of which there are many more than offered in Photoshop), it seemed like there was a relative consensus that Lanczos, Sinc, and Catrom algorithms tended to do a better job than some of the others, including Photoshop's bicubic family.

I decided to try using the ImageMagick convert command to resize using the Lanczos filter. It's a command-line tool (which automatically turns many people off) with a huge and daunting set of often sparsely-documented options. But, after some Web research, here's what I ended up coming up with as my own starting point for down-sizing images for Web use:


convert -filter Lanczos -resize "500x500>" -density 96x96 \
-quality 80 -sampling-factor 1x1 -unsharp 0.6x0.6+1+.05 \
input_file_name output_file_name


This combination of command line options does the following:

-filter Lanczos
obviously selects the Lanczos resampling method from the many that ImageMagick supports.

-resize "500x500>"
indicates we want the down-sized image to be 500 pixels on the longest dimension. The ">" character indicates that we don't want to create a new image if the existing one is already that size or smaller.

-density 96x96
is just bookkeeping to indicate the image has a resolution of 96 ppi. It's not really necessary.

-quality 80
indicates the JPEG compression quality I want.

-sampling-factor 1x1
indicates the sampling factor for the JPEG compression. I don't know for sure, but this may be the default.

-unsharp 0.6x0.6+1+0.5
applies a little unsharp filter after the down-sizing. This is one of the most difficult areas to find useful information and guidelines on but this is what I came up with for 96 ppi display and it works well in most cases for me.

When I prep an image for Web use, I do the bulk of the work in Photoshop, convert to the sRGB color space (boo! hiss!) and save it as a TIFF file. Then I apply the convert command just described to create my Web-sized image. I actually have this command, and a couple others to handle IPTC copyrighting, etc., in a batch file that I just pass the TIFF file name to for processing.

Not every image will work optimally with this particular process but it's looking like a great starting point for my taste. Give it a try if you have ImageMagick installed. (It's available on all major platforms.)

Sunday, November 2, 2008

Faking Slow Exposures for Waterfalls

When shooting pictures of waterfalls, here's a way to get that soft milky look to the moving water when you can't get exposures long enough to do it directly. I recently had a pocket camera and pocket tripod in my coat pocket on a nice hike along a series of waterfalls in Ithaca, NY. I didn't have a polarizer or neutral density filter to enable slower exposures and this example was shot in open shade on a bright sunny day. I used the slowest ISO I had available (80) and closed the aperture as much as I could without destroying the image with diffraction. I was still stuck with a 1/30 second exposure giving the following result:



Not bad but I wanted the falling water to look softer. With the camera fixed on the little pocket tripod, I shot 5 identical exposures of the waterfall without moving the camera. I used the 2-second timer on each exposure to make sure my shutter-button presses didn't mess up the exposures.

I brought the 5 images into Photoshop on separate layers of one file. I wanted to blend the images together so that stationary objects stayed the same and the moving parts (the water) got averaged together. It's a simple matter of changing the layer opacities to allow each layer to contribute equally to the final composite. The background layer stays at 100% opacity, the second layer is at 50% opacity, the third at 33% opacity, and so on as seen here:



If you think about it a little bit, this allows each layer to contribute equally to the averaged stacked final image. Of course I could have used fewer or more images depending on what the desired outcome is but you get the idea. The result with 5 stacked images is much closer to what I was hoping for. Ten images would have made it really milky smooth.

Thursday, October 2, 2008

Night Sky Shooting

The current DSLRs are getting better characteristics making night sky photography viable: lower noise at higher ISOs and better long-exposure tolerance. Upon getting a Nikon D700, one of the first things I wanted to do was try out night sky photography like I used to do in the good old film days. You have two choices with long exposures of the night sky: either keep the camera stationary and get star trails or move the camera to compensate for the earth's rotation to get long exposures of faint sky features without smearing into trails.

It's the latter that I find most interesting usually. So, with a vacation based on a cottage overlooking a pond coming up, I hastily put together an equatorial mount to take night sky pictures if the weather cooperated.



An equatorial mount is simply a camera (or telescope) mount that allows you to rotate your gear precisely around an axis parallel to the earth's axis of rotation but in the opposite direction to compensate for the apparent rotation of the night sky as the earth turns.

You can build a primitive mount using some scrap lumber and some common hardware as I did. At its core, the mount is two boards joined at one end by a door hinge. The hinge is our rotation axis and will be aligned with earth's axis as described later. The bottom board is fixed in position so that it correctly aligns the hinge. At the end opposite the hinge on the bottom board we drill a hole through which a T-nut can be driven for a 1/4 X 20 bolt to be screwed in. (This means a bolt 1/4 inch in diameter with 20 threads per inch. The bolt should be at least 3 inches long.) In use we slowly (one revolution per minute) screw in the bolt so that it drives the upper board away around the hinge axis. This drive bolt is located 11.43 inches from the center of the hinge axis.

Here's why. (Math-phobes skip this paragraph, it will make your head hurt.) The earth completes one revolution every 23 hours, 56 minutes, and 4.1 seconds approximately. This is the sidereal or star day, not a solar day which is the familiar 24 hours, the extra four minutes of which are spent rotating a bit more to compensate for the earth's orbit around the sun. So, this means the earth rotates 360° every 23 hours, 56 minutes and 4.1 seconds or about 1436 minutes. That means the earth rotates about 0.25° every minute so we need to rotate the same amount in the opposite direction to compensate. Because we're using a bolt with 20 threads per inch, we can move our upper board 1/20 inch per minute. We need to find the distance between the hinge and the bolt that will cause the upper board to rotate 0.25° when we raise the far end 1/20 inch. Simple trigonometry shows that distance to be 0.05/tan(360/1436) or 11.43 inches. There's some heavy round off in these calculations but the error is well within our ability to drill holes with precision into lumber.

Next we need to mount our board assembly to keep our hinge axis in alignment with earth's. In my case, I knew I was going to be shooting pictures at 44° north latitude so the hinge needed to be angled up at 44°. I cut a couple of supports at this angle and screwed the bottom axis board to it. An adjustable setup would be better if you're going to use this at different locations. The angled supports were in turn screwed to a piece of plywood with a hole drilled in the center to thread a bolt through to secure the whole apparatus to a tripod. (You could simply set it on a level table top instead.)

The final tweak was to screw a piece of wood cut at 45° to the top rotating board to provide some elevation for mounting a ballhead and the camera, giving them clearance to point in any direction needed.

To align everything on site, it helps to have a compass and a good map that provides a couple of important pieces of information. You need your latitude so that the hinge can be angled up the proper amount, and you need the direction of true north that the hinge axis must be aligned with. Good maps, such as the USGS maps in the US, also include an indication of how far magnetic north deviates from true north. In my case, I was shooting at about 44° north latitude at a location where magnetic north was 14.5° west of true north. After adjusting the compass accordingly, I lined everything up beforehand, composed the approximate scene I wanted to capture, locked down the controls, and waited for dark. An alternative to all this is to eyeball along the hinge at night so it points in the direction of Polaris, the North Star, if you live in the northern hemisphere. In my case this wasn't an option because north was obscured by trees.

When shooting, keep a watch handy with a little light on it and use it to synchronize your rotation of the bolt with the seconds indicator of your watch—remember, we're screwing in the bolt at 1 complete revolution per minute. Trip your shutter and start slowly rotating the bolt and, if you've measured and aligned everything properly, you should get nice crisp star images.

Or not. As I found out, many wider-angle lenses don't do stars very well. There is a lot of coma and astigmatism that you don't notice in normal shooting. Experiment with lenses and f/stops to find the right combination to give you the best results.

In my case, I was getting good results at ISO 3200, 30-second exposures with a zoom set at 35 mm and f/4. I would shoot multiple exposures and then use stacking software to combine them to get nice clean (relatively) noise-free images.



Note that this solution is only accurate for a few minutes at a time, when the boards are closest together. As they rotate farther apart, the movement of the bolt pressing against the upper board has a progressively smaller effect on the rotation rate of the upper board. If you want a more robust solution, things get a lot more involved and you may want to simply buy a commercial equatorial mount (and maybe even a clock drive to turn it).

Update March, 2009: The image above, of the Milky Way over Osgood Pond in the Adirondacks, was the grand prize winner in the Adirondack Life magazine's annual photography contest. It was shot from the canoe house deck of the Gazebo, a gem of a rental cottage on the pond.

Sunday, September 14, 2008

Highs and Lows

I was at an arts and music festival helping out Lori with her pottery booth. I had a chance to wander around and shoot a few pictures. I brought the little Canon G9 and a monopod to get something other than the straight-on shots we instinctively go for.



One thing you can do is attach the camera to one end of the monopod on the side and then just rest that end on the ground and have the camera shoot upwards to get a ground-level view of the world.



Another easy way to get a different viewpoint it to fully extend the monopod and raise it high overhead to get a top-down view.

In both cases I find it convenient to simply set the camera at the hyperfocal distance (about 6.5 feet or 2 meters for the G9 at 7.4 mm set at f/5.6). Set the mode to aperture-preferred, put on a 5-second timer, click the shutter and either set the camera down or raise it high and wait for your 5-count to let you know the shutter has released.

It's not going to get you precision framing but you can get decent quality images from a seldom-used perspective. Also, if you're using a pocket camera, it's quite easy to move the camera into position at the end of the monopod and you won't attract quite as much attention as you would trying to wrestle a big DSLR into position to do the same thing.

(The only disturbing comment I got was from a woman who came from behind and, as she passed, said "Oh, thank God; I thought you had a gun." Maybe I should put some nice friendly colored electrical tape on my gun-metal grey monopod to reduce such anxieties.)

Friday, September 5, 2008

Part 7: Final Thoughts


To wrap things up on this series of posts, here are some personal observations on images created with point-and-shoot consumer pocket cameras like the Canon G9. This photo is a ground-level view of the Lackawanna Train Station, now a historical museum, in Vestal, NY. It was shot with G9 and processed using the techniques we've been going through. Shot at 7.4 mm and f/4, the processing removed the mustache distortion (combination barrel and pincushion distortions often seen in shorter focal length zooms), we've reduced the transverse chromatic aberration, and we compensated for the light fall-off (vignetting) at the edges.



Looking at a detail of the original image, we can see the chromatic aberration along the high-contrast edges of an eave ornament. After processing we see the chromatic aberration cleaned up and image details are sharper.



So let's summarize what we're working with:

  1. Small-sensor pocket cameras have great depth of field. In many cases this is good but it substantially removes one of the creative controls you have with a DSLR and fast lens: no chance of getting nice gauzy out-of-focus backgrounds with these cameras.
  2. Pocket cameras all have some amount of transverse and longitudinal chromatic aberration. We can reduce longitudinal (axial) chromatic aberration by using a smaller aperture; we can reduce transverse chromatic aberration using red and blue channel corrections. There are other chromatic aberrations inherent in the small sensors and inexpensive lenses that are beyond our ability to correct but these tend to be secondary.
  3. These small cameras (and many lenses on the big boys) have issues with geometric distortion. Barrel distortion, pincushion distortion, and even the more complex compound distortions can be corrected effectively. Not all pictures need this attention but ocean horizons, building edges, and other straight-line picture elements leap out when geometric distortion goes uncorrected.
  4. Small sensors have noise issues (at least as of this writing). Sadly the manufacturers still feel obligated to push the sensor resolution to ever-higher levels for marketing advantage but the price is paid in increased noise. Many cameras, like the Canon G9, would have far better images if the sensor sites were a bit larger even if it means a lower megapixel count.
  5. Looking up close at images created by any of these cameras will be clear to the experienced eye that they come from a smaller inexpensive point-and-shoot, and not one of the bigger pricier DSLRs or medium format digital cameras with good lenses.
  6. Almost any current point-and-shoot pocket camera is far more than adequate for images destined for the Web or for small family album prints. Only with extra care, as we've been exploring, will the images survive closer scrutiny and larger printing. However, you will not see an image taken with one of these class of cameras on the cover of Architectural Digest.


So, although it's tempting to say we can, with the tools and techniques described here, enhance a point-and-shoot image up into DSLR level of quality, that's only true if the shooter using a DSLR doesn't apply equal skill and similar tools to nudge those images to the next level of quality. The point-and-shoot images start off at a substantial disadvantage, can be improved greatly, but won't ever quite reach the quality of a carefully crafted DSLR image.

For the G9 in particular, here's a summary of its characteristics:

  1. Images suffer from moderate geometric distortions, edge fall-off, and chromatic aberrations as expected. None are show-stoppers and a carefully shot image can be cleaned up substantially using the techniques we've explored here.
  2. The aperture "sweet spot" for the G9 is between f/4 and f/5.6. Any lower and axial chromatic aberration becomes an issue. Any higher and diffraction starts turning detail to mush.
  3. Many of us who own the G9 wish the zoom range went a little lower, say to 24 mm equivalent rather than 35 mm. There is an after market for adapters to extend the zoom range optically. I've mentioned the Raynox wide-angle adapter which, when added to the G9, will yield a focal length down at the 24 mm equivalent range. The image, however, suffers greatly with uncorrectable vignetting at the corners at short focal lengths, bad geometric distortion and substantial chromatic aberration. Some, but not all, of this is correctable. My advice to anyone wanting quality 24 mm equivalent images from their G9 is don't consider the Raynox adapter. Maybe others are better but I have my doubts.


Bottom line: don't bring a knife to a gunfight. A consumer pocket camera does not compete with any reasonably good DSLR with a good lens. The pocket camera does, however, work great when you're not carrying a DSLR. The pocket cameras have some other strengths compared to DSLRs which we'll visit in future posts, not the least of which it attracts less attention than the flamboyant DSLRs. (For some reason some uninformed power-tripping Barney Fifes of law enforcement don't find pocket cameras the grave threat to national security that a SLR is, especially one mounted on a tripod.)

Monday, August 25, 2008

Part 6: Image Correction Alternatives

After enduring the math and tedium of developing our own corrections for images with vignetting, geometric distortion, and chromatic aberration, it's worth looking at some alternatives not involving such a high pain level.

First, if you're a user of a recent version of Photoshop, you have the Lens Correction filter available. This filter has adjustments for the 3 areas we've been exploring. It works fine for estimating simple adjustments in any of these 3 areas but it doesn't have any kind of built in knowledge of adjustments required for particular lens/camera combinations. If you only need approximate corrections and like the easy-to-use interface, this is a good way to go. If, on the other hand, you have stricter requirements or you have short focal length lenses with complex mustache distortion or other more complex problems, the Lens Correction filter won't handle it.

Another option to consider is DxO Optics Pro which is a sophisticated product handling a number of image problems including those we've been discussing plus many others. This software is tied directly to your camera/lens combination by way of modules that have very specific correction parameters built in that are the result of DxO's expert lab testing. Results can be very good, the product comes with standalone and Photoshop plugin versions, and can be used to batch process large quantities of images fairly easily. On the minus side, it's not inexpensive (although certainly not overpriced for what it does), it's a bit daunting to learn the quirky interface, and it only supports a subset of camera and lens combinations. For example, at the time of this writing, it doesn't support the Canon G9 we've been using as our example in this series.

Finally, there's PTLens which is a much less ambitious effort in terms of functionality but which has a much broader camera/lens coverage than DxO. It comes with a standalone version (handling only JPEG and TIFF images) and a Photoshop plugin. In terms of cost (about 10% of DxO), simplicity, and effectiveness for its strong point, geometric distortion correction, this is a gem. It also handles vignetting and chromatic aberration but you must make those adjustments manually, unlike the corrections for geometric distortion which cover a very broad range of cameras and lenses. PTLens had its genesis from Panorama Tools roots and handles geometric distortion under the covers in the same way that we discussed using the third-order polynomial radial corrections—except you don't have to be aware of it. By the way, the manual corrections for chromatic aberration in PTLens are also analogous to what we developed using corrections for the red and blue channels. In fact, the PTLens sliders show the numeric radial deviation from 1.0 (no change) as you visually tweak the image to your satisfaction. You can interchangeably use the PTLens numbers and the d coefficients we used in hugin parameters. I routinely will use PTLens to get in the ballpark and then transfer the corrections to hugin to refine the correction to as close as I can get to eliminating transverse chromatic aberration. The PTLens Photoshop plugin can be used to handle large numbers of images simply by making a Photoshop Action to run during ACR processing for example. The one thing I don't like about PTLens is it doesn't handle very large images well, having a tendency to bomb out with memory errors. But, other than that, you'll have a hard time finding a bigger "bang for the buck".

Both DxO Optics Pro and PTLens have free trial versions which should be exploited if you're at all interested in looking at their capabilities.

Given you can buy good solutions for correcting image problems we've been discussing, you may wonder why all the trouble doing it ourselves with all those measurements and mathematical manipulations. There are a few reasons. First, none of the products mentioned above handles all camera/lens combinations. For example, DxO doesn't handle the Canon G9 and PTLens doesn't handle the Canon G9 with the Raynox wide angle adapter we mentioned back in the post about geometric distortion. Second, by doing your own measurements you can be more confident that your custom-built corrections are as accurate as possible for your particular images. And third, there's nothing like grinding your nose into the pixel-level image flaws to get a real understanding of what your equipment capabilities and limitations are.

Next up, some final thoughts on compact consumer cameras generally and the Canon G9 in particular, given what I've learned going through these image correction exercises. After that, maybe we'll get back to some real photography discussion instead of all this techie pixel-bending stuff.

Monday, August 18, 2008

Part 5: Putting It All Together

In previous posts, we've looked at the Canon G9 point-and-shoot camera's vignetting, geometric distortion, and chromatic aberration. We've also looked at strategies for addressing these issues, primarily using the fulla command from the hugin panorama photo stitcher package.

The fulla command doesn't have a nice friendly GUI interface but it does allow us to put together arbitrary corrections to be applied to large numbers of images without a great deal of effort. Each of the fulla corrections we've explored in previous posts can be combined into a single command addressing vignetting, geometric distortion, and chromatic aberration.

Your workflow sequence is very important. The corrections we've been discussing should be applied to the images before any cropping, resizing, etc. have been done. I always shoot raw so I use ACR or some other tool for "developing" the image to set the correct initial tonality, color temperature, etc. and then export the image in 16-bit TIFF format (lossless unlike JPEG). I apply the image corrections and then bring the corrected version into Photoshop for subsequent processing.

Let's start with a hypothetical file shot on the Canon G9 at 7.4 mm and f/4, and processed from the raw CR2 file into a 16-bit TIFF file called example.tif. To apply my standard corrections for vignetting, geometric distortion, and chromatic aberration, I would use the following command:

fulla -c 1.0398:-0.1155:0.1954:-0.1605 \
-g 0.028:-0.0871:0.0521:1.007 \
-r 0:0:0:1.00024 -b 0:0:0:1.00041 example.tif

(The '\' characters indicate arbitrary line breaks for formatting here. This is actually all one command line.)

The "-c" option gives the polynomial coefficients for correcting vignetting, the "-g" option gives the polynomial coefficients for geometric distortion correction, and the "-r" and "-b" options provided the polynomial coefficients for transverse chromatic aberration correction. (But you already knew that.)

When fulla is done crunching the numbers, it outputs a file with a "_corr" filename suffix. So our example correction would create a new file called example_corr.tif. It will look substantially better than the original with the corrections applied.

Naturally you don't want to have to type in that command every time you process a file so you can create a MSDos batch command file (on Windows) or a Bash script (on Unix systems) to generalize it. Let's say we want to correct arbitrary numbers of files with one command. We can create a batch file like this:


for %%f in (%1) do \
fulla -c 1.0398:-0.1155:0.1954:-0.1605 \
-g 0.028:-0.0871:0.0521:1.007 \
-r 0:0:0:1.00024 -b 0:0:0:1.00041 %%f

(Once again, this should be all on one line in the real batch file.) Assuming you named this something like G9_74_4.bat (because it's only useful for the G9's 7.4 mm f/4 images), you can process all the TIFF files in a directory with a single command:

g9_74_4 *.tif

Unix, Linux, Mac users can create analogous script files using for iterations to do precisely the same thing.

I must mention something about the fulla command here: it's flaky and not mature in some regards. One frustration is that, when it outputs a corrected image, that corrected image has its metadata stored in an unconventional way that is not visible to Photoshop and many other applications. If you're running any kind of responsible workflow, this is not good, but there is a way around the problem.

ExifTool by Phil Harvey is a superbly-done high-function image metadata management tool. It has an extraordinary number of capabilities and it handles them well. If you download the tool, you can use it to save your EXIF (and other metadata) from your image, apply your fulla corrections, and then restore the original metadata in standard format. For example, you can save the metadata for all TIFF files in a subdirectory with this command:

exiftool -o %f.mie -ext tif .

Process your files using the fulla corrections and then restore the metadata to the corrected files.

exiftool -overwrite_original -tagsfromfile %-.5f.mie \
-ext tif .

You can even skip the intial save to MIE file (Meta Information Encapsulation) and simply rewrite the original file's metadata over the fulla output file:

exiftool -overwrite_original -tagsfromfile %-.5f.%e \
example_corr.tif


Finally, if you're really ambitious and have Perl programming skills, you could use the Perl Image::ExifTool package to determine the focal length and f-stop for the image and then do a table lookup to determine which of the fulla option parameters to use. I've done a rudimentary job of this just for the subset of camera settings I almost always use for the Canon G9.

If all these seems like a lot of trouble to correct the occasional image, you're right. It's most worthwhile if you routinely have large numbers of images you wish to optimize; then the use of fulla in batch or script files makes more sense.

If you only do occasional corrections, want something a bit easier to deal with, or want a commercial solution, stay tuned. Next up we'll glance at a couple of alternatives for correcting images that don't require all the up-front work we've been slogging through here.

Vignetting Revisited

After enduring a little confusion and frustration in correcting some images from my Canon G9 camera, I investigated a little more and found ...