| Image Processing Toolbox™ | ![]() |
| On this page… |
|---|
Reading a High Dynamic Range Image Creating a High Dynamic Range Image |
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.
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 Viewing a 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);
If you try to view a HDR image using imshow, the image does not display correctly.

To view an HDR image, you must first convert the data to a dynamic range that can be displayed correctly on a computer. Use the tonemap function to perform this conversion. tonemap converts the high dynamic range 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
After converting the HDR image, try to display the image again.
imshow(rgb);

To write a high dynamic range image from the MATLAB workspace into a file, use the hdrwrite function.
hdrwrite(hdr,'filename');
![]() | Working with Interfile Files | Displaying and Exploring Images | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |