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.
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:
- Gaussian filtering, which results in the expected haloing artifacts. We compute the convolution of the luminance map with the Gaussian kernel efficiently by multiplying them in the frequency domain, using the FFTW library to compute the forward and backward Fast Fourier Transforms.
- Normal (slow) bilateral filtering.
- Fast bilateral filtering, as proposed by Durand and Dorsey. This also uses Gaussian filtering of downscaled intermediate images over several iterations, again using Fast Fourier Transform.
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:- Alpha is the magnitude of gradients that are not modified, while larger and smaller gradients are attenuated or magnified, respectively. This value is set relative to the average gradient magnitude on each scale level. An advisable value for this parameter is 0.3, although it heavily depends on the input image. Larger values result in more gradients falling below the threshold and thus being magnified, leading to more detail contrast within the image.
- Beta controls to what extend gradients are modified. A value of 1.0 means no gradient modification at all, lower values result in a greater large-scale contrast reduction. Recommended values for this parameter are around 0.85.
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.


