This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

tonemapfarbman

Convert HDR image to LDR using edge-preserving multiscale decompositions

Syntax

LDR = tonemapfarbman(HDR)
LDR = tonemapfarbman(HDR,Name,Value)

Description

example

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.

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

Examples

collapse all

Load a high dynamic range (HDR) image into the workspace. Convert the HDR image to a low dynamic range (LDR) image using the basic tone mapping function tonemap. Display the result.

HDR = hdrread('office.hdr');
LDR = tonemap(HDR);
imshow(LDR)

The LDR image is displayed with an acceptable dynamic range, but colors are muted.

Convert the HDR image to an LDR image using edge-preserving multiscale decompositions. Display the result.

RGB = tonemapfarbman(HDR);
imshow(RGB)

Colors appear more saturated, but the image is bright and has poor contrast. This brightness and contrast indicate that the default value of 'Exposure' is too large. The poor contrast is especially evident in the shadow of the tree.

Repeat the conversion with a lower value of 'Exposure' to darken the image. Display the result.

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

The image contrast is improved. Also, the image shows a decrease in the clipping of pixel values in bright regions, such as the sky, road, and monitor.

Input Arguments

collapse all

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

Data Types: single | double

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: LDR = tonemapFarbman(HDR,'Saturation',2.1);

Range compression, specified as the comma-separated pair consisting of 'RangeCompression' and 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 the comma-separated pair consisting of 'Saturation' and 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 the comma-separated pair consisting of 'Exposure' and 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 the comma-separated pair consisting of 'NumberOfScales' and 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 the comma-separated pair consisting of 'Weights' and 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, specified 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.

Introduced in R2018b