Tone Mapping

Tone Mapping Operators

The dynamic range of an image is the ratio between the brightest and the darkest pixel value. Conventional displays are only capable of reproducing a relatively small dynamic range; when the brightness values of a high dynamic range radiance map are scaled such that its maximum value matches the display's maximum brightness, dark tones will be indistinguishable.

The purpose of tone mapping is to compress the dynamic range of an image, i.e. to reduce its contrast, raising the brightness of dark tones so that they can be displayed along with bright tones. However, a simple contrast reduction, for example by a gamma correction, also means an undesirable reduction of the already low contrast of fine details within the image. Tone mapping operators should therefore selectively reduce the contrast of only some of the brightness variations in the input radiance map: typically, large-scale, high-contrast brightness changes are caused by different illumination within the photographed scene and should be identified and reduced by the tone mapping operator, while smaller-scale low-contrast details stemming from the texture or reflectance changes of photographed objects should not be affected.

Of a wide range of proposed tone mapping operators, we have chosen to implement the following two in our project:

Layer Separation using Bilateral Filtering

This method described in [Durand and Dorsey 2002] separates the radiance map into a base layer, obtained by blurring the image, and a detail layer which is the difference between the radiance map and the base layer. The base layer, assumed to contain most of the high contrast that needs to be reduced, is then compressed using gamma correction and finally added to the unmodified detail layer.

Using a simple low-pass filter (such as G aussian filtering) for the layer separation would cause haloing effects. This is because some high-contrast edges, which are due to illumination differences and are therefore intended to appear only in the base layer, also appear in the detail layer because of their hard (high-frequency) borders. To avoid the problem, this tone mapping operator uses bilateral filtering instead, a filter that smoothes only regions with similar brightness but preserves edges.

Gradient Domain HDR Compression

The operator in [Fattal et al. 2002] works by modifying the gradient field of the radiance map. The magnitudes of gradients within differently downscaled versions of the image are used to determine how much the gradients of the full-scale image are to be attenuated. High-contrast edges between large regions of different brightness, which are usually caused by a large illumination contrast we wish to reduce, have high gradients on all scale levels. This means that the gradient field is greatly attenuated along these edges, resulting in the desired dynamic range reduction, while fine details are preserved.


Visualization of the gradient attenuation factors; dark tones represent strong attenuation

The modified gradients are usually not a gradient field for any real image. Instead, an image whose gradient field is closest (least-squares) to the modified gradients is computed. This is done by solving the Poisson equation.

Implementation Details and Parameters

Color and Output Range

Both tonemapping operators work on the grayscale luminance of radiance map, and use the log domain so that a pixel value difference represents the same contrast over the complete brightness range.

To reconstruct colors afterwards, the ratio between the input RGB channels and the original luminance is multiplied with the tone-mapped luminance. An exponent is applied to that ratio to control how "colorful" the output image appears; this is necessary since the color ratio still has the high contrast of input radiance map which needs to be compressed in parallel to the luminance. This exponent can be set by the user as the color exponent parameter, for example with a value of 0.6.

The range of the final output is linearly scaled and shifted to fill the range that can be displayed on the screen or saved to a low dynamic range output file. An automatic scaling based solely on the minimum and maximum values would be unreliable due to possible single outlying bright or dark pixels. Therefore, the user can use the black position and white position parameters to control how much of the range will be cut off. For example, values of 0.05 and 0.98 for two parameters respectively will cause 5 percent of output image's pixel values to be clipped to the darkest, and 2 percent to the brightest possible value.

Base Layer Separation

For the base layer separation of the first tone mapping operator, three filters are available:

The parameter Spatial Sigma controlling the Gaussian filter is the standard deviation of the kernel, specified relative to the image size, for example 0.01. Bilateral filtering additionally requires the second parameter Intensity Sigma which controls how more or less deviating pixel values are weighed when the image is blurred, i.e. to what extend the bilateral filter "stops" at edges. Large values for this parameter lead to results similar to those using gaussian filtering, while small values cause even low-contrast details to appear in the base layer instead of the detail layer, giving a tone-mapping result similar to a simple gamma correction. A good value for this parameter is around 0.5.

Bilateral Filtering can exhibit artifacts along some strong aliased edges due to the fact that with no or only very few similar brightness values in the vicinity of these edges, the output values are essentially random. For the fast bilateral filter, we have implemented a fixing strategy similar to the one proposed by Durand and Dorsey that replaces these uncertain values using the blurred output values. This feature can be controlled using the Fix Uncertainty parameter, which is the inverse of an exponent applied to the determined uncertainty, or can be set to 0 to disable the feature. A recommended value is 0.1, values too high will again cause small halo artifacts.

After the base layer has been separated, its log-scale values are multiplied with the Base Layer Exponent parameter, equivalent to gamma correction of linear-scale values. A usual value for this parameter is 0.2; lower values result in greater contrast reduction, a value of 1.0 would leave the radiance map unchanged.

Gradient Domain Compression

The gradient domain tone mapping is controlled by the following two parameters which determine how gradients are attenuated:

For solving the Poisson equation, we have implemented a simple "rapid Poisson solver" as described in Numerical Receipes in C [Press et al. 1992]. This involves a Discrete Cosine Transform, for which we employ the FFTW library again.

With some images, we observed an undesirable effect of a strong decrease in brightness along the sides of the resultant image. This may be either a problem inherent to the algorithm because, due to the assumption of Neumann boundary conditions when solving the Poisson equation, the output pixel values are not fixed along the image borders and are therefore free to "run away", or just a bug in our implementation. To remedy the issue, we have implemented the option for an additional post-processing step in the form of base layer contrast reduction using a Gaussian filter as described above. Since a large kernel size (for example with a standard deviation of 0.1 or greater, relative to the image size) can be used, this will usually not cause visible haloing artifacts.


Left: no post-processing; right: post-processing with sigma 0.2 and base layer exponent 0.2
2009/10, Sebastian Negraszus and Daniel Pirch.