by the Codermind team. |
Question
«I've read several papers and seen samples written about the tone mapping of HDR images and they all calculate a key for the image by taking the average of the logarithmic luminance value. Why should I average the logarithmic value and not the straight original value ?»
Answer
There are simple and complex answers to that.
Here's the simplest explanation I could come up with :
The fact is that when you sum luminance values, since we're talking HDR images, there are points in the image that are very very much more luminous than the rest of the image (point light, spot, sun, specular highlights and so on). These very much more luminous points will be given a much bigger weight than anything else in your image, resulting in you overestimating the overall key of the image which in turn results in a very dark final image.
If you look at the logarithmic curve, you can see that the order of luminance is still preserved but that at the same time very high numbers get more and more compressed as they get higher. This is frequently used as a trick to represent very high variations that could not be represented on the same linear curve, as in population variations (that tend to be exponential), or stock market variations. This is reflected in our scales for magnitude (but not only in vision, but also sound scales with decibels, seismic scales, etc).
You need to realize though that it wouldn't work if :
- small variations in the high intensities were as important as small variations in the low intensities. Fortunately they are not. If you get a high intensity source, your eye or the camera will adapt to reduce the overall amount of lighting that you perceive by X, reducing at the same time the importance of small variations by a factor of X.
- there were no big variations in the image, all the values are approximately near a central value. As your eyes can distinguish contrast more than absolute intensity, you may need to find other ways to restitute the same amount of contrast (probably a topic in itself).
- there are a few very dark spots (compared to the rest of the image), and since the logarithmic curves gets to infinity as the luminance value tends to zero, you run the risk of giving too much weights to dark spots, resulting in an over bright image. One of the solution is to cut the logarithmic curve beyond a certain point. Pure black points are clamped to a positive luminance.
There are also people suggesting that our vision of brightness itself is based on a logarithmic scale. But it is hard to say, because other studies suggest that our eye is determining brightness of a scene using a power function instead, other studies determine that the numerous elements involved in determining the perceived "brightness" of a scene are too numerous to be put into a simple function such as logarithmic or power function. Ideally a human operator would have control over the shutter speed, or control knobs to generate the final image, but in practice if you're doing a videogame for example where only automatic algorithms are possible, then you have to find one that is "good enough". Video games have an advantage though is that the content can be tweaked, especially the amount of light you put in a scene.
Now all this is arguable, but that should maybe answer your question.
If you want to learn more..
- Photographic exposition in ray tracing
- HDR rendering and antialiasing in Direct3D, OpenGL
- Color banding with 8 bit per channel
- [AMZN] Physically based ray tracing
- [AMZN] High dynamic range digital photography
- [AMZN] High dynamic range imaging




