Main Content

tonemapfarbman

Convert HDR image to LDR using edge-preserving multiscale decompositions

Description

LDR = tonemapfarbman(HDR) converts the high dynamic range (HDR) image to a low dynamic range (LDR) image, suitable for display, using a process called edge-preserving decompositions for multiscale tone and detail manipulation.

example

LDR = tonemapfarbman(HDR,Name=Value) uses one or more name-value arguments to control various aspects of the tone mapping.

Examples

collapse all

Load a high dynamic range (HDR) image into the workspace.

HDR = hdrread('office.hdr');

Convert the HDR image to a low dynamic range (LDR) image using the basic tone mapping function tonemap. Display the result. The LDR image has an acceptable dynamic range but colors are muted.

LDR = tonemap(HDR);
imshow(LDR)

Figure contains an axes object. The hidden axes object contains an object of type image.

Repeat the conversion using the tonemapfarbman function with default argument values. Display the result. Colors appear more saturated than in the LDR image created using the tonemap function. However, the image is bright and has poor contrast, such as in the shadow of the tree. The brightness and poor contrast indicate that the default value of 'Exposure' is too large.

RGB = tonemapfarbman(HDR);
imshow(RGB)

Figure contains an axes object. The hidden axes object contains an object of type image.

Repeat the conversion using the tonemapfarbman function with a lower value of 'Exposure' to darken the image. Display the result. The image contrast is improved. The image also shows a decrease in the clipping of pixel values in bright regions, such as the sky, road, and monitor.

RGB2 = tonemapfarbman(HDR,'Exposure',1.5);
imshow(RGB2)

Figure contains an axes object. The hidden axes object contains an object of type image.

Input Arguments

collapse all

High dynamic range image, specified as an m-by-n matrix or an m-by-n-by-3 array of nonnegative numbers.

Data Types: single | double

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: LDR = tonemapFarbman(HDR,Saturation=2.1) sets the saturation as 2.1.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: LDR = tonemapFarbman(HDR,"Saturation",2.1)

Range compression, specified as a number in the range [0, 1]. A value of 1 represents maximum compression and a value of 0 represents minimum compression.

Saturation, specified as a nonnegative number. The recommended range for Saturation is [0, 5]. As the saturation value increases, colors become more rich and intense. As the saturation value decreases, colors fade away to gray. The Saturation argument does not affect grayscale HDR images.

Exposure, specified as a positive number. The recommended range for Exposure is (0, 5]. As this value decreases, the exposure length decreases, so the image darkens. As this value increases, the exposure length increases, so the image brightens.

Number of scales, specified as a positive integer. The recommended range for NumberOfScales is [1, 5]. The default number of scales is length(Weights) when you specify Weights. Otherwise, the default number of scales is 3.

Weights of detail layers, specified as an n-element vector of positive numbers, where n is the number of scales specified by NumberOfScales. The recommended range of each element in Weights is (0, 3]. The default value of Weights is an n-element numeric vector with all elements set to 1.5. For Weights <1, the amount of detail in the output image decreases and Weights >1, the amount of detail in the output image increases.

Output Arguments

collapse all

Low dynamic range image, returned as a numeric array of the same size as HDR.

Data Types: uint8

Tips

  • This function uses an anisotropic diffusion filter, imdiffusefilt, for the approximation of the weighted least squares filter, as proposed by Farbman et al. [1]

References

[1] Farbman, Z., R. Fattal, D. Lischinski, and R. Szeliski. "Edge-Preserving Decompositions for Multi-Scale Tone and Detail Manipulation." ACM Transactions on Graphics. Vol. 27, Number 3, August 2008, pp. 1–10.

Version History

Introduced in R2018b