Main Content

localtonemap

Render HDR image for viewing while enhancing local contrast

Description

RGB = localtonemap(HDR) converts the high dynamic range (HDR) image HDR to a low dynamic range (LDR) image, RGB, suitable for display. localtonemap uses a process called tone mapping while preserving the local contrast of the image.

example

RGB = localtonemap(HDR,Name=Value) controls various aspects of the tone mapping using name-value arguments.

Examples

collapse all

Load a high dynamic range image.

HDR = hdrread('office.hdr');

Apply local tone mapping with a small amount of dynamic range compression.

RGB = localtonemap(HDR, 'RangeCompression', 0.1);

Display the resulting tone-mapped image.

imshow(RGB)

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

Repeat the operation but, this time, accentuate the details in the image.

RGB = localtonemap(HDR, ...
                  'RangeCompression', 0.1, ...
                  'EnhanceContrast', 0.5);

Display the resulting tone-mapped image with increased details.

imshow(RGB)

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

Input Arguments

collapse all

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

Data Types: single

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: RGB = localtonemap(HDR,RangeCompression=0.5) sets the range compression to 0.5.

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

Example: RGB = localtonemap(HDR,"RangeCompression",0.5)

Amount of compression applied to the dynamic range of the HDR image, specified as a number in the range [0, 1].

ValueDescription
0Minimum compression, which consists in only remapping the middle 99% intensities to a dynamic range of 100:1 followed by gamma correction with an exponent of 1/2.2.
1Maximum compression using local Laplacian filtering.

Amount of local contrast enhancement, specified as a number in the range [0, 1].

ValueDescription
0No change to local contrast
1Maximum local contrast enhancement

Output Arguments

collapse all

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

Algorithms

localtonemap uses local Laplacian filtering in logarithmic space to compress the dynamic range of HDR while preserving or enhancing its local contrast. The 99% middle intensities of the compressed image are then remapped to a fixed 100:1 dynamic range to give the output image a consistent look. localtonemap then applies gamma correction to produce the final image for display.

Version History

Introduced in R2016b