HDR Imagery – AKA, Making The World Look Plastic

At any rate, that’s all I’ve been able to do. Perhaps somebody more skilled/dedicated can do better?

In conjunction with the Lyst project, I’ve started work again on HDR photography. After all, it’s a game that suites itself to High Dynamic Range photography – the players want to be able to see all the details.

Standard images are taken at a single “exposure value”, which is a combination of shutter speed and f-number. Obviously, a very fast shutter speed (1/120th of a second) will make a very dark picture, whereas a very slow shutter speed (1 second) will make a much lighter picture. Usually in photography we try to find a happy middle that gives us the right amount of light in the picture. Here’s an example of three such pictures that I took of my lab:

HDR Original Images

Let’s look at the printer under my desk (in the bottom-center of the image, yes that’s a printer). In the center image, the printer is almost entirely obscured by the shadow the desk casts. In the image on the right, the medium image, the printer is visible but is still dark. However, the image on the left clearly shows the printer. If I wanted to take a picture of the printer, I would use the exposure value from the left image.

Now look at the two windows in the image. Obviously, they’re too bright in the left image. They’re also a little bit bright in the right-hand image. So we pick the center, darker image as the best picture for the windows – they’re not painfully bright like the other two images.

And, for a third┬ácomparison, look at the door and the flyer taped to it. The left-hand image is too bright, and washes out the flyer taped to the door. The center image is so dark that it’s difficult to read the flyer on a standard monitor. The remaining image is the happy middle for the flyer, and if I had set the focus to it, you could easily read it.

Normally, we would have to pick an exposure value to optimize for one of these areas. HDR is a technique for merging these three images into one image, which clearly shows all of the areas, none too bright and none too dark.

But how?

The conceptual approach is that we want to take the bright areas from the dark image (like the windows), the medium areas from the medium image (like the flyer), and the dark areas from the bright image (the printer), and merge these areas together. Image masks come to mind here – if we created a mask that selected for the areas we’ve identified above, in their respective images, then we could simply add the resulting images to form a single image that is contrast balanced.

The first step is, of course, to find the mask. For example, on the bright image, we eventually want a mask that allows dark areas through but not the bright areas. We could simply threshold, but we might have issues picking the right threshold value, so we run it through an equation that teases apart the bright areas of the image slightly so that it’s easier to find a good threshold value. The function we use happens to be a finely-tuned logistic function. The arguments are tweaked to affect how much of the image is pulled from the dark image, how much is from the bright image, and how much is from the medium image. Note that I actually don’t threshold the image – I simply apply this stretching function. Here’s the mask after the stretching function:

light_mask

 

Dark areas are where the light image will show through, and light areas are where it will be blocked. Sorry about the aliasing – it was reduced with a nearest-neighbor algorithm.

The next steps are trivial: We apply the masks to the three images, then add them. The resulting image is our HDR result:

Lab in HDR

Not as bad as it could be. It dims the bright areas, brightens the dark areas, and deals with the middle areas.

I’m currently experimenting with equalizing the image, which increases the color saturation dramatically but also reverses some of the advantages of HDR.

At some point, I’ll release a script which can batch process a directory of files, and allow things like (understandable) controls for the user.

Also, stay tuned for my thoughts about HP Code Wars (yesterday! Yay!) and my new HP Envy:

HP Envy Install Screen

… Microsoft doesn’t like it when robots setup their computers.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *