Monday, September 19, 2011

How do pseudo or fake HDR programs like Photomatix work?

Question

There are a few programs that can produce HDR-like results from only one input image. How do these work?

Answer

First of all it's important to understand the difference between HDR and tonemapping. HDR is a technique to capture images which contain a huge variety of brightness information. However most people lack high dynamic range monitors to show this information. If you simply scale the large range of brightnesses down to a smaller range, you end up with an image with very little contrast.

Tonemapping is a technique to maximise local contrast. Imagine you're adjusting the contrast of an image, after a certain point, as you increase contrast the darkest and lightest areas will hit pure black/white and you'll start to lose detail. Now imagine adjusting the contrast of each quarter of the image separately. You'll probably be able to push the contrast that much higher as the darkest and lightest parts of each quarter are not as far apart to begin with as the darkest and lightest parts of the whole image.

Now there's one further point to appreciate: dynamic range and noise are like opposites of each other. Technically they are inversely proportional to each other - the higher the noise the lower the dynamic range, and vice versa. So you can tonemap (increase local contrast) of any image, but if you start with a low dynamic range image, the tonemapped image will contain more noise.

The ability to produce "fake HDR images" is nothing to do with the extra range you get in raw images. It's because tonemapping has nothing to do with HDR. You can shove a standard 8 bit JPEG into photomatix, and you'll still get a similar result, just with more noise.


This is an image produced from three exposures using Photomatix:

Here I've taken the darkest RAW file and pulled up the shadows massively in Lightroom using the "fill light" slider:

Here I've taken the middle 8-bit JPEG image and loaded it straight into Photomatix (proving you don't need 12-14 bits to produce "HDR" images):

Three different sets of source data. Three different methods. Three rather similar results. There is no "HDR" - only tonemapping and local contrast adjustment. Source dynamic range only influences the level of noise in the final image, not what you can produce.


Here's another example to cement what I've said and help people get their heads round the relationship between HDR images and tonemapping. Here is the result of blending three exposures together:

It contains detail in both the sky, and in the shadow area of the pillars. If you had a high dynamic range image it would look amazing. As is is I've had to compress that large range down to fit within the low dynamic range of your typical monitor. This compression/scaling means the brightness values are very close together, leaving little contrast and a dull looking image.

Now let's increase the contrast globally:

Looks better, but we've lost all the detail in the sky, and a lot of detail in the shadows. Going back to the original, I divided the image up into 24 squares and increased the contrast in each square individually. This is the meaning of the term local in local contrast enhancement:

Now we have detail in the sky and the clouds. What's more it's starting to look a little "HDR" like! Some squares still have too much contrast, resulting in clipping of the highlights/shadows. If you made the squares smaller and smoothed the transition you'd eventually end up with a tonemapped image.

HDR/Tonemapping software (like Photomatix) uses a lot of fancy algorithms with lots of parameters to adjust but fundamentally all it does is local contrast enhancement.

No comments:

Post a Comment