Friday, June 1, 2012

Using HDR techniques to correct poor exposure

Wikimedia Commons is a really awesome thing. Almost 13 million images and other files, every one of them free to use for whatever purpose you want. But it falls victim to Sturgeon's Law - 90% of everything is crap.

The good news is, that's okay. With that many files, there's a good change of finding a high-quality one, and even mediocre images are okay for a lot of purposes. Most images used on Wikipedia, for example, are resized to thumbnails between 150 and 300 pixels wide. So an image that's poor at 2048x1536 or 4000x3000 might still be usable at 220x165.

One of the advantages of Commons, though, is that it is a wiki. Almost everything is editable, including images themselves. If you have a technically superior version - an updated map, a larger version of a historic image - then you can upload it to replace the current image.

An aside: I'm not a great photographer. Sometimes, I'm not even a good photographer. But I have a pretty good digital camera, and I'm learning. I've learned to play with shutter speed and f-stop to get better pictures than the automatic setting. I've figured out the right combination (1/1600 second, f/3.4, ISO 400) to get surprisingly decent shots out the window of trains at speed. Through a lot of practice, and by taking multiple shots of a scene to choose the best, I've gotten to a point where I'm reasonably happy with my photography. I even get lucky sometimes and grab a neat shot of a train or click the shutter button at exactly the right time from a moving car.

Mostly, though, I don't take perfect images. So I've learned some tricks of digital manipulation. (Even the two linked above got some tweaking for color and contrast.) I don't add anything that's not there, but I work to turn an imperfect snapshot into a more accurate representation of what was in front of me. Cropping, straightening, recoloring, contrast-enhancing, et cetera.

It's actually a lot of fun, and I've even started performing such edits on images that other people have uploaded. I won't make minor tweaks, but I do make major changes that significantly improve the appearance of an image in an article.

The most frustrating images to improve are badly overexposed and underexposed images. They're just so washed out with white or grey than no automated contrast adjustment can save them. But I've been playing with a technique that sometimes can.

The key is a process that's already out there - HDR tonemapping, where individual low-contrast images can be turned into a higher-contrast composite. The results, when properly done, can be spectacular. Even my middling efforts can generate eye-popping color.

The only problem is, HDR composites require multiple starting images. But what if you use an image editor to create multiple versions of your original? Turns out, it works.

I started with this image by another editor at Commons:

It's not an awful image, but it's not great either. The light rail car and the platforms are washed out, while the trees are shrouded in darkness. First, I used GIMP to create two alternate versions. One is shifted by 100 lighter on the brightness menu, and the other 100 darker:

Then, I fed those two versions plus the original into Luminance HDR, another freeware program which I use for my regular HDR images. With a little tweaking, I got these two output images:

I then went into GIMP and faded the first of those HDR results with the original, obtaining this next image. It's better than either the original or the HDR result, but still imperfect:

Finally, I faded that image with the second HDR result and, with more tweaking, I obtained an image I'm happy with. The contrast is markedly improved, and the colors are realistic again.

It makes an excellent display image for Wikipedia, and it looks a lot better than the original at 300 pixels wide. The HDR process does lose some detail; at full resolution, there's a lot of graininess that wasn't in the original. Fortunately, though, Commons saves all versions on an image that were uploaded. So my version displays on Wikipedia articles, but the original image is still available for download and use as well.

No comments: