High Dynamic Range Images

Dynamic Range

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, and a tone-map operator for displaying HDR images on a computer monitor.

Read High Dynamic Range Image

To read a high dynamic range image into the MATLAB® workspace, use the hdrread function.

hdr_image = hdrread('office.hdr');

The output image hdr_image is an m-by-n-by-3 image of type single.

whos
  Name        Size            Bytes    Class     Attributes

  hdr_image   665x1000x3      7980000  single

Note, however, that before you can display a high dynamic range image, you must convert it to a dynamic range appropriate to a computer display, a process called tone mapping. Tone mapping algorithms scale the dynamic range down while attempting to preserve the appearance of the original image. For more information, see Display High Dynamic Range Image.

Create High Dynamic Range Image

To create a high dynamic range 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);

Display High Dynamic Range Image

This example shows how to display a high dynamic range (HDR) image. To view an HDR image, you must first convert the data to a dynamic range that can be displayed correctly on a computer.

Read a high dynamic range (HDR) image, using hdrread . If you try to display the HDR image, notice that it does not display correctly.

hdr_image = hdrread('office.hdr');
imshow(hdr_image)

Convert the HDR image to a dynamic range that can be viewed on a computer, using the tonemap function. This function converts the HDR image into an RGB image of class uint8 .

rgb = tonemap(hdr_image);
whos
  Name             Size                  Bytes  Class     Attributes

  hdr_image      665x1000x3            7980000  single              
  rgb            665x1000x3            1995000  uint8               

Display the RGB image.

imshow(rgb)

Write High Dynamic Range Image to File

To write a high dynamic range image from the MATLAB workspace into a file, use the hdrwrite function.

hdrwrite(hdr,'filename');
Was this topic helpful?