Convert HDR image to LDR using edge-preserving multiscale decompositions
Compress Dynamic Range of HDR Image Using Edge-Preserving Multiscale Decompositions
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)
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)
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)
HDR — High dynamic range image
m-by-n matrix | m-by-n-by-3 array
High dynamic range image, specified as an m-by-n matrix or an m-by-n-by-3 array.
Specify optional pairs of arguments as
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.
Before R2021a, use commas to separate each name and value, and enclose
Name in quotes.
LDR = tonemapFarbman(HDR,'Saturation',2.1);
RangeCompression — Range compression
0.3 (default) | number in the range [0, 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 — Saturation
1.6 (default) | nonnegative number
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
Exposure — Exposure
3 (default) | positive number
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.
NumberOfScales — Number of scales
3 (default) | positive integer
Number of scales, specified as the comma-separated pair consisting of
'NumberOfScales' and a positive integer. The recommended range
'NumberOfScales' is [1, 5]. The default number of scales is
length( when you specify
'Weights'. Otherwise, the default number of scales is
Weights — Weights of detail layers
[1.5 1.5 1.5] (default) | n-element vector of positive numbers
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, the amount of detail in the output image decreases and
Weights >1, the amount of detail in the output image
 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.