Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

makehdr

Create high dynamic range image

Syntax

HDR = makehdr(files)
HDR = makehdr(files,Name,Value,...)

Description

HDR = makehdr(files) creates the single-precision, high dynamic range image HDR from the set of spatially registered, low dynamic-range images listed in the files cell array. These files must contain EXIF exposure metadata. 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 Algorithms.)

example

HDR = makehdr(files,Name,Value,...) creates a high dynamic- range image, where you can use parameters and corresponding values to control various aspects of the image creation. Parameter names can be abbreviated and case does not matter.

Note

You can use only one of the BaseFile, ExposureValues, and RelativeExposure parameters at a time.

Examples

collapse all

Make a high dynamic range (HDR) image from a series of low dynamic range images that share the same f/stop number and have different exposure times.

Load six low dynamic range images. Create a vector of their respective exposure times.

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

Combine the images into an HDR image.

hdr = makehdr(files, 'RelativeExposure', expTimes ./ expTimes(1));

Visualize the HDR image.

rgb = tonemap(hdr);
figure
imshow(rgb)

Input Arguments

collapse all

Set of spatially registered, low dynamic-range images, specified as a cell array of character vectors. The input images can be color or grayscale, and can have a bit-depth of 8 or 16.

Data Types: char | cell

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 single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example:

collapse all

Name of the file to use as the base exposure, specified as a character vector.

Data Types: char

Exposure value of each file in the set, specified as a numeric vector of positive values, with one element for each low dynamic-range image in files. An increase of one exposure value (EV) corresponds to a doubling of exposure, while a decrease of one EV corresponds to a halving of exposure. Any positive value is allowed. Values specified using this parameter override EXIF exposure metadata.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

Relative exposure value of each low dynamic range image in the set, specified as a numeric vector with one element for each low dynamic-range image in files. An image with a relative exposure (RE) of 0.5 has half as much exposure as an image with an RE of 1.0. An RE value of 3 has three times the exposure of an image with an RE of 1. Values specified using this parameter override EXIF exposure metadata.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

Minimum correctly exposed value, specified as a numeric scalar. For each low dynamic-range image, pixels with smaller values are considered underexposed and do not contribute to the final high dynamic-range image. If the value of this parameter is omitted, it is assumed to be 2% of the maximum intensity allowed by the image data type.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

Maximum correctly exposed value, specified as a numeric scalar. For each low dynamic-range image, pixels with larger values are considered overexposed and do not contribute to the final high dynamic-range image. If the value of this parameter is omitted, it is assumed to be 98% of the maximum intensity allowed by the image data type.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

Output Arguments

collapse all

High dynamic-range image, returned as a numeric array.

Data Types: single

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

|

Introduced in R2008a

Was this topic helpful?