10:08 Sunday, July 07 2009

the HDR strikes back

I've been playing with the creation of HDR (high dynamic range) images using QtPFSgui for a few weeks with mixed success. I've had a bunch of images that have come out fairly decent (that I've posted), and many others that have looked absolutely horrible. Part of the initial problem was finding the right settings on my camera to generate enough images with broad range of exposures. However, once I got that sorted out, I was still not consistently getting good results. Last night I solved another piece of the puzzle. QtPFSgui provides two methods of aligning the images ("Auto align images"). Getting perfect, or near perfect alignment of the images is crucial when creating HDR's, or you end up with shadows or ghosting in the image that make it look out of focus or altogether crappy. Now if you're using a tripod and there's no movement in the image (even leaves blowing in the wind counts as movement), then you generally won't need to bother with post-processing alignment). However, if you don't have a tripod, or there's any movement, then alignment is absolutely required for good results.
The first, default, method of alignment in QtPFSgui is to use hugin's align_image_stack tool. This would be great, except that it crashes immediately when called from within QtPFSgui, and therefore never works at all. As a result, I had been using the secondary method, which does some poor bitmap matching. I finally got sick of this mess, and investigated what could be done about the align_image_stack crashes. Unfortunately, there are no obvious solutions, however someone on the QtPFSgui forum noted that align_image_stack could be run manually, and then the resulting images could be fed into QtPFSgui. I decided to give that a whirl, and it worked perfectly. The only catch is that the images that align_image_stack generates are TIFF images, and they do not include the EXIF data from the originals. Getting TIFFs isn't a problem, as QtPFSgui will gladly import them, however not having any EXIF data is a huge problem. The solution for that is to copy over the EXIF data from the originals into the aligned TIFFs. I did that using 'exiftool' (which is part of perl-Image-ExifTool on Fedora). exiftool has a ridiculous number of options, and digging through its man page is not much fun, but I finally figured out the correct options to perform the copy:

::: {style="text-align: center;"} exiftool -TagsFromFile IMG_${i}.JPG -all:all IMG_${i}.TIF :::

In order to automate the entire process, I whipped up the following (for my camera, one batch of images that I wanted to work with were IMG_2453.JPG through IMG_2460.JPG inclusive):

::: {style="text-align: center;"} align_image_stack -v -a align_ IMG_2453.JPG IMG_2454.JPG IMG_2455.JPG IMG_2456.JPG IMG_2457.JPG IMG_2458.JPG IMG_2459.JPG IMG_2460.JPG a=0 ; for i in $(seq 2453 2460) ; do exiftool -TagsFromFile IMG_${i}.JPG -all:all align_00printf "%02d" ${a}.tif ; let a++ ; done :::

Once this is all done (and it can take a few minutes depending on the speed of your CPU), you should have a bunch of align_*.tif images that you can then feed into QtPFSgui as the 'originals'. Then, do *not* check off the 'Auto Align Images' option, and just proceed as normal.
All of this circles back to what I did yesterday. David had been asking to go into the city to play in Golden Gate park for a few weeks, and I finally agreed to take him. We spent some time in the park in the morning, and then in the afternoon, we drove up to the Presidio to explore Fort Point. We had been a few times before, but David has this odd fascination with the place. As is always the case during the summer, the entire city was socked in with some fairly thick fog, so I wasn't expecting to get any decent pictures. However, as it turned out, I was able to work the fog into the shots, and they turned out really well (in my opinion):

::: {style="text-align: center;"}