Table Of Contents

Previous topic

Denoising

Next topic

Decolorization

HDR imaging

This section describes high dynamic range imaging algorithms namely tonemapping, exposure alignment, camera calibration with multiple exposures and exposure fusion.

Tonemap

class Tonemap : public Algorithm

Base class for tonemapping algorithms - tools that are used to map HDR image to 8-bit range.

Tonemap::process

Tonemaps image

C++: void Tonemap::process(InputArray src, OutputArray dst)
Parameters:
  • src – source image - 32-bit 3-channel Mat
  • dst – destination image - 32-bit 3-channel Mat with values in [0, 1] range

createTonemap

Creates simple linear mapper with gamma correction

C++: Ptr<Tonemap> createTonemap(float gamma=1.0f)
Parameters:
  • gamma

    positive value for gamma correction. Gamma value of 1.0 implies no correction, gamma equal to 2.2f is suitable for most displays.

    Generally gamma > 1 brightens the image and gamma < 1 darkens it.

TonemapDrago

class TonemapDrago : public Tonemap

Adaptive logarithmic mapping is a fast global tonemapping algorithm that scales the image in logarithmic domain.

Since it’s a global operator the same function is applied to all the pixels, it is controlled by the bias parameter.

Optional saturation enhancement is possible as described in [FL02].

For more information see [DM03].

createTonemapDrago

Creates TonemapDrago object

C++: Ptr<TonemapDrago> createTonemapDrago(float gamma=1.0f, float saturation=1.0f, float bias=0.85f)
Parameters:
  • gamma – gamma value for gamma correction. See createTonemap()
  • saturation – positive saturation enhancement value. 1.0 preserves saturation, values greater than 1 increase saturation and values less than 1 decrease it.
  • bias – value for bias function in [0, 1] range. Values from 0.7 to 0.9 usually give best results, default value is 0.85.

TonemapDurand

class TonemapDurand : public Tonemap

This algorithm decomposes image into two layers: base layer and detail layer using bilateral filter and compresses contrast of the base layer thus preserving all the details.

This implementation uses regular bilateral filter from opencv.

Saturation enhancement is possible as in ocv:class:TonemapDrago.

For more information see [DD02].

createTonemapDurand

Creates TonemapDurand object

C++: Ptr<TonemapDurand> createTonemapDurand(float gamma=1.0f, float contrast=4.0f, float saturation=1.0f, float sigma_space=2.0f, float sigma_color=2.0f)
Parameters:
  • gamma – gamma value for gamma correction. See createTonemap()
  • contrast – resulting contrast on logarithmic scale, i. e. log(max / min), where max and min are maximum and minimum luminance values of the resulting image.
  • saturation – saturation enhancement value. See createTonemapDrago()
  • sigma_space – bilateral filter sigma in color space
  • sigma_color – bilateral filter sigma in coordinate space

TonemapReinhard

class TonemapReinhard : public Tonemap

This is a global tonemapping operator that models human visual system.

Mapping function is controlled by adaptation parameter, that is computed using light adaptation and color adaptation.

For more information see [RD05].

createTonemapReinhard

Creates TonemapReinhard object

C++: Ptr<TonemapReinhard> createTonemapReinhard(float gamma=1.0f, float intensity=0.0f, float light_adapt=1.0f, float color_adapt=0.0f)
Parameters:
  • gamma – gamma value for gamma correction. See createTonemap()
  • intensity – result intensity in [-8, 8] range. Greater intensity produces brighter results.
  • light_adapt – light adaptation in [0, 1] range. If 1 adaptation is based only on pixel value, if 0 it’s global, otherwise it’s a weighted mean of this two cases.
  • color_adapt – chromatic adaptation in [0, 1] range. If 1 channels are treated independently, if 0 adaptation level is the same for each channel.

TonemapMantiuk

class TonemapMantiuk : public Tonemap

This algorithm transforms image to contrast using gradients on all levels of gaussian pyramid, transforms contrast values to HVS response and scales the response. After this the image is reconstructed from new contrast values.

For more information see [MM06].

createTonemapMantiuk

Creates TonemapMantiuk object

C++: Ptr<TonemapMantiuk> createTonemapMantiuk(float gamma=1.0f, float scale=0.7f, float saturation=1.0f)
Parameters:
  • gamma – gamma value for gamma correction. See createTonemap()
  • scale – contrast scale factor. HVS response is multiplied by this parameter, thus compressing dynamic range. Values from 0.6 to 0.9 produce best results.
  • saturation – saturation enhancement value. See createTonemapDrago()

AlignExposures

class AlignExposures : public Algorithm

The base class for algorithms that align images of the same scene with different exposures

AlignExposures::process

Aligns images

C++: void AlignExposures::process(InputArrayOfArrays src, std::vector<Mat>& dst, InputArray times, InputArray response)
Parameters:
  • src – vector of input images
  • dst – vector of aligned images
  • times – vector of exposure time values for each image
  • response – 256x1 matrix with inverse camera response function for each pixel value, it should have the same number of channels as images.

AlignMTB

class AlignMTB : public AlignExposures

This algorithm converts images to median threshold bitmaps (1 for pixels brighter than median luminance and 0 otherwise) and than aligns the resulting bitmaps using bit operations.

It is invariant to exposure, so exposure values and camera response are not necessary.

In this implementation new image regions are filled with zeros.

For more information see [GW03].

AlignMTB::process

Short version of process, that doesn’t take extra arguments.

C++: void AlignMTB::process(InputArrayOfArrays src, std::vector<Mat>& dst)
Parameters:
  • src – vector of input images
  • dst – vector of aligned images

AlignMTB::calculateShift

Calculates shift between two images, i. e. how to shift the second image to correspond it with the first.

C++: Point AlignMTB::calculateShift(InputArray img0, InputArray img1)
Parameters:
  • img0 – first image
  • img1 – second image

AlignMTB::shiftMat

Helper function, that shift Mat filling new regions with zeros.

C++: void AlignMTB::shiftMat(InputArray src, OutputArray dst, const Point shift)
Parameters:
  • src – input image
  • dst – result image
  • shift – shift value

AlignMTB::computeBitmaps

Computes median threshold and exclude bitmaps of given image.

C++: void AlignMTB::computeBitmaps(InputArray img, OutputArray tb, OutputArray eb)
Parameters:
  • img – input image
  • tb – median threshold bitmap
  • eb – exclude bitmap

createAlignMTB

Creates AlignMTB object

C++: Ptr<AlignMTB> createAlignMTB(int max_bits=6, int exclude_range=4, bool cut=true)
Parameters:
  • max_bits – logarithm to the base 2 of maximal shift in each dimension. Values of 5 and 6 are usually good enough (31 and 63 pixels shift respectively).
  • exclude_range – range for exclusion bitmap that is constructed to suppress noise around the median value.
  • cut – if true cuts images, otherwise fills the new regions with zeros.

CalibrateCRF

class CalibrateCRF : public Algorithm

The base class for camera response calibration algorithms.

CalibrateCRF::process

Recovers inverse camera response.

C++: void CalibrateCRF::process(InputArrayOfArrays src, OutputArray dst, InputArray times)
Parameters:
  • src – vector of input images
  • dst – 256x1 matrix with inverse camera response function
  • times – vector of exposure time values for each image

CalibrateDebevec

class CalibrateDebevec : public CalibrateCRF

Inverse camera response function is extracted for each brightness value by minimizing an objective function as linear system. Objective function is constructed using pixel values on the same position in all images, extra term is added to make the result smoother.

For more information see [DM97].

createCalibrateDebevec

Creates CalibrateDebevec object

C++: createCalibrateDebevec(int samples=70, float lambda=10.0f, bool random=false)
Parameters:
  • samples – number of pixel locations to use
  • lambda – smoothness term weight. Greater values produce smoother results, but can alter the response.
  • random – if true sample pixel locations are chosen at random, otherwise the form a rectangular grid.

CalibrateRobertson

class CalibrateRobertson : public CalibrateCRF

Inverse camera response function is extracted for each brightness value by minimizing an objective function as linear system. This algorithm uses all image pixels.

For more information see [RB99].

createCalibrateRobertson

Creates CalibrateRobertson object

C++: createCalibrateRobertson(int max_iter=30, float threshold=0.01f)
Parameters:
  • max_iter – maximal number of Gauss-Seidel solver iterations.
  • threshold – target difference between results of two successive steps of the minimization.

MergeExposures

class MergeExposures : public Algorithm

The base class algorithms that can merge exposure sequence to a single image.

MergeExposures::process

Merges images.

C++: void MergeExposures::process(InputArrayOfArrays src, OutputArray dst, InputArray times, InputArray response)
Parameters:
  • src – vector of input images
  • dst – result image
  • times – vector of exposure time values for each image
  • response – 256x1 matrix with inverse camera response function for each pixel value, it should have the same number of channels as images.

MergeDebevec

class MergeDebevec : public MergeExposures

The resulting HDR image is calculated as weighted average of the exposures considering exposure values and camera response.

For more information see [DM97].

createMergeDebevec

Creates MergeDebevec object

C++: Ptr<MergeDebevec> createMergeDebevec()

MergeMertens

class MergeMertens : public MergeExposures

Pixels are weighted using contrast, saturation and well-exposedness measures, than images are combined using laplacian pyramids.

The resulting image weight is constructed as weighted average of contrast, saturation and well-exposedness measures.

The resulting image doesn’t require tonemapping and can be converted to 8-bit image by multiplying by 255, but it’s recommended to apply gamma correction and/or linear tonemapping.

For more information see [MK07].

MergeMertens::process

Short version of process, that doesn’t take extra arguments.

C++: void MergeMertens::process(InputArrayOfArrays src, OutputArray dst)
Parameters:
  • src – vector of input images
  • dst – result image

createMergeMertens

Creates MergeMertens object

C++: Ptr<MergeMertens> createMergeMertens(float contrast_weight=1.0f, float saturation_weight=1.0f, float exposure_weight=0.0f)
Parameters:
  • contrast_weight – contrast measure weight. See MergeMertens.
  • saturation_weight – saturation measure weight
  • exposure_weight – well-exposedness measure weight

MergeRobertson

class MergeRobertson : public MergeExposures

The resulting HDR image is calculated as weighted average of the exposures considering exposure values and camera response.

For more information see [RB99].

createMergeRobertson

Creates MergeRobertson object

C++: Ptr<MergeRobertson> createMergeRobertson()

References

[DM03]
  1. Drago, K. Myszkowski, T. Annen, N. Chiba, “Adaptive Logarithmic Mapping For Displaying High Contrast Scenes”, Computer Graphics Forum, 2003, 22, 419 - 426.
[FL02]
  1. Fattal, D. Lischinski, M. Werman, “Gradient Domain High Dynamic Range Compression”, Proceedings OF ACM SIGGRAPH, 2002, 249 - 256.
[DD02]
  1. Durand and Julie Dorsey, “Fast Bilateral Filtering for the Display of High-Dynamic-Range Images”, ACM Transactions on Graphics, 2002, 21, 3, 257 - 266.
[RD05]
  1. Reinhard, K. Devlin, “Dynamic Range Reduction Inspired by Photoreceptor Physiology”, IEEE Transactions on Visualization and Computer Graphics, 2005, 11, 13 - 24.
[MM06]
  1. Mantiuk, K. Myszkowski, H.-P. Seidel, “Perceptual Framework for Contrast Processing of High Dynamic Range Images”, ACM Transactions on Applied Perception, 2006, 3, 3, 286 - 308.
[GW03]
  1. Ward, “Fast, Robust Image Registration for Compositing High Dynamic Range Photographs from Handheld Exposures”, Journal of Graphics Tools, 2003, 8, 17 - 30.
[DM97](1, 2)
  1. Debevec, J. Malik, “Recovering High Dynamic Range Radiance Maps from Photographs”, Proceedings OF ACM SIGGRAPH, 1997, 369 - 378.
[MK07]
  1. Mertens, J. Kautz, F. Van Reeth, “Exposure Fusion”, Proceedings of the 15th Pacific Conference on Computer Graphics and Applications, 2007, 382 - 390.
[RB99](1, 2)
  1. Robertson , S. Borman , R. Stevenson , “Dynamic range improvement through multiple exposures ”, Proceedings of the Int. Conf. on Image Processing , 1999, 159 - 163.