Main Content


Render HDR image for viewing while enhancing local contrast



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 its local contrast.

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


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.


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.


Input Arguments

collapse all

HDR image, specified as an m-by-n numeric matrix or m-by-n-by-3 numeric array.

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.

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

Example: 'RangeCompression',0.5

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

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.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

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

0No change to local contrast
1Maximum local contrast enhancement

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Output Arguments

collapse all

Tone-mapped LDR image, returned as a numeric array of the same size as the input image hdr.


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