Dynamic range refers to the range of brightness levels, from dark to light. The dynamic range of real-world scenes can be quite high. High dynamic range (HDR) images attempt to capture the whole tonal range of real-world scenes (called scene-referred), using 32-bit floating-point values to store each color channel. HDR images contain a high level of detail, close to the range of human vision. The toolbox includes functions for reading, creating, and writing HDR images. The toolbox also includes tone-map operators for creating low dynamic range (LDR) images from HDR images for processing and display.
To read an HDR image into the MATLAB® workspace, use the
hdr_image = hdrread('office.hdr');
The output image
hdr_image is an
m-by-n-by-3 image of data type
Name Size Bytes Class Attributes hdr_image 665x1000x3 7980000 single
The range of data exceeds the range [0, 1] expected of LDR data.
hdr_range = [min(hdr_image(:)) max(hdr_image(:))]
hdr_range = 1×2 single row vector 0 3.2813
Many toolbox functions assume that images of data type
double are LDR images with data in the range [0, 1]. Since HDR data is
not bound to the range [0, 1] and can contain
Inf values, you must
examine the behavior of each function carefully when working with HDR data.
Some functions clip values outside the expected range before continuing to process the data. These functions can return unexpected results because clipping causes a loss of information.
Some functions expect data in the range [0, 1] but do not adjust the data before processing it. These functions can return incorrect results.
Some functions expect real data. If your HDR image contains values of
Inf, then these functions can return unexpected results.
Some functions have no limitations for the range of input data. These functions accept and process HDR data correctly.
To work with functions that require LDR data, you can reduce the dynamic range of an
image using a process called tone mapping. Tone mapping scales HDR
data to the range [0, 1] while attempting to preserve the appearance of the original image.
Tone mapping functions such as
localtonemap give more accurate results than
simple linear rescaling such as performed by the
function. However, note that tone mapping incurs a loss of subtle information and
To display HDR images, you must perform tone mapping. For an example, see Display High Dynamic Range Image.
To create an HDR image from a group of low dynamic range images, use the
makehdr function. Note that the low dynamic range images must be spatially
registered and the image files must contain EXIF metadata. Specify the low dynamic range
images in a cell array.
hdr_image = makehdr(files);
To write an HDR image from the workspace into a file, use the