localtonemap

Render HDR image for viewing while enhancing local contrast

Description

example

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.

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)

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)

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 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: '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.

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].

ValueDescription
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.

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.

Introduced in R2016b