makehdr

Create high dynamic range image

Syntax

HDR = makehdr(files)
HDR = makehdr(files, param1, val1,...)

Description

HDR = makehdr(files) creates the single-precision, high dynamic range image from the set of spatially registered low dynamic range images listed in the files cell array. makehdr uses the middle exposure between the brightest and darkest images as the base exposure for the high dynamic range calculations. (This value does not need to appear in any particular file. For more information about calculating this middle exposure value, see Algorithm.)

    Note:   When you call makehdr with this syntax, the low dynamic range image files must contain exif exposure metadata.

HDR = makehdr(files, param1, val1,...) creates a high dynamic range image from the low dynamic range images in files, specifying parameters and corresponding values that control various aspects of the image creation. Parameter names can be abbreviated and case does not matter.

    Note:   Only one of the BaseFile, ExposureValues, and RelativeExposure parameters may be used at a time.

ParameterDescription
'BaseFile'Character array containing the name of the file to use as the base exposure.
'ExposureValues'Vector of exposure values, with one element for each low dynamic range image in the cell array files. An increase in one exposure value (EV) corresponds to a doubling of exposure, while a decrease in one EV corresponds to a halving of exposure. Any positive value is allowed. This parameter overrides EXIF exposure metadata.
'RelativeExposure'Vector of relative exposure values, with one element for each low dynamic range image in the cell array files. An image with a relative exposure (RE) of 0.5 has half as much exposure as an image with an RE of 1. An RE value of 3 has three times the exposure of an image with an RE of 1. This parameter overrides EXIF exposure metadata.
'MinimumLimit'Numeric scalar value in the range [0 255] that specifies the minimum correctly exposed value. For each low dynamic range image, pixels with smaller values are considered underexposed and will not contribute to the final high dynamic range image.
'MaximumLimit'Numeric scalar value in the range [0 255] that specifies the maximum correctly exposed value. For each low dynamic range image, pixels with larger values are considered overexposed and will not contribute to the final high dynamic range image.

Examples

Make a high dynamic range image from a series of six low dynamic range images that share the same f/stop number and have different exposure times. Use tonemap to visualize the HDR image.

files = {'office_1.jpg', 'office_2.jpg', 'office_3.jpg', ...
         'office_4.jpg', 'office_5.jpg', 'office_6.jpg'};
expTimes = [0.0333, 0.1000, 0.3333, 0.6250, 1.3000, 4.0000];
 
hdr = makehdr(files, 'RelativeExposure', expTimes ./ expTimes(1));
rgb = tonemap(hdr);
figure; imshow(rgb)

More About

expand all

Algorithms

The makehdr function calculates the middle exposure by computing the exposure values (EV) for each image, based on the aperture and shutter speed metadata stored in the files or specified using the 'Exposurevalues' parameter. The EV of a middle image (hypothetical or actual) is used as the base exposure. Thus, the middle exposure is an average of the highest and lowest EV, not of actual brightness (because of the nonlinear, geometric nature of EV).

References

[1] Reinhard, et al. "High Dynamic Range Imaging." 2006. Ch. 4.

See Also

|

Was this topic helpful?