opencv/modules/photo/doc/hdr_imaging.rst

378 lines
14 KiB
ReStructuredText
Raw Normal View History

2013-07-19 04:23:49 +08:00
HDR imaging
2013-08-06 22:13:34 +08:00
=============
2013-07-19 04:23:49 +08:00
.. highlight:: cpp
2013-08-06 22:13:34 +08:00
This section describes high dynamic range imaging algorithms namely tonemapping, exposure alignment, camera calibration with multiple exposures and exposure fusion.
2013-07-19 04:23:49 +08:00
2013-08-01 19:34:03 +08:00
Tonemap
2013-08-06 21:49:02 +08:00
---------------------------
2013-08-01 19:34:03 +08:00
.. ocv:class:: Tonemap : public Algorithm
2013-07-19 04:23:49 +08:00
2013-08-06 22:13:34 +08:00
Base class for tonemapping algorithms - tools that are used to map HDR image to 8-bit range.
2013-08-01 19:34:03 +08:00
Tonemap::process
2013-08-06 21:49:02 +08:00
---------------------------
2013-08-01 19:34:03 +08:00
Tonemaps image
.. ocv:function:: void Tonemap::process(InputArray src, OutputArray dst)
2013-08-06 21:49:02 +08:00
2013-08-01 19:34:03 +08:00
:param src: source image - 32-bit 3-channel Mat
:param dst: destination image - 32-bit 3-channel Mat with values in [0, 1] range
2013-08-06 00:35:48 +08:00
createTonemap
2013-08-06 21:49:02 +08:00
---------------------------
2013-08-06 00:35:48 +08:00
Creates simple linear mapper with gamma correction
2013-08-01 19:34:03 +08:00
2013-08-06 21:49:02 +08:00
.. ocv:function:: Ptr<Tonemap> createTonemap(float gamma = 1.0f)
2013-08-01 19:34:03 +08:00
2013-08-06 21:49:02 +08:00
:param gamma: positive value for gamma correction. Gamma value of 1.0 implies no correction, gamma equal to 2.2f is suitable for most displays.
2013-08-06 21:49:02 +08:00
Generally gamma > 1 brightens the image and gamma < 1 darkens it.
2013-08-01 19:34:03 +08:00
TonemapDrago
2013-08-06 21:49:02 +08:00
---------------------------
2013-08-01 19:34:03 +08:00
.. ocv:class:: TonemapDrago : public Tonemap
2013-07-19 04:23:49 +08:00
Adaptive logarithmic mapping is a fast global tonemapping algorithm that scales the image in logarithmic domain.
2013-08-06 21:49:02 +08:00
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]_.
2013-08-01 19:34:03 +08:00
createTonemapDrago
2013-08-06 21:49:02 +08:00
---------------------------
2013-08-01 19:34:03 +08:00
Creates TonemapDrago object
.. ocv:function:: Ptr<TonemapDrago> createTonemapDrago(float gamma = 1.0f, float saturation = 1.0f, float bias = 0.85f)
2013-08-01 19:34:03 +08:00
2013-08-06 21:49:02 +08:00
:param gamma: gamma value for gamma correction. See :ocv:func:`createTonemap`
2013-08-06 21:49:02 +08:00
:param saturation: positive saturation enhancement value. 1.0 preserves saturation, values greater than 1 increase saturation and values less than 1 decrease it.
2013-08-06 21:49:02 +08:00
:param 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.
2013-08-01 19:34:03 +08:00
TonemapDurand
2013-08-06 21:49:02 +08:00
---------------------------
2013-08-01 19:34:03 +08:00
.. ocv:class:: TonemapDurand : public Tonemap
2013-07-19 04:23:49 +08:00
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.
2013-07-19 04:23:49 +08:00
2013-08-01 19:34:03 +08:00
This implementation uses regular bilateral filter from opencv.
2013-08-06 21:49:02 +08:00
Saturation enhancement is possible as in ocv:class:`TonemapDrago`.
For more information see [DD02]_.
2013-08-01 19:34:03 +08:00
createTonemapDurand
2013-08-06 21:49:02 +08:00
---------------------------
2013-08-01 19:34:03 +08:00
Creates TonemapDurand object
2013-08-06 21:49:02 +08:00
.. ocv:function:: 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)
2013-08-01 19:34:03 +08:00
2013-08-06 21:49:02 +08:00
:param gamma: gamma value for gamma correction. See :ocv:func:`createTonemap`
2013-08-06 21:49:02 +08:00
:param 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.
2013-08-06 21:49:02 +08:00
:param saturation: saturation enhancement value. See :ocv:func:`createTonemapDrago`
2013-08-06 21:49:02 +08:00
:param sigma_space: bilateral filter sigma in color space
2013-08-06 21:49:02 +08:00
:param sigma_color: bilateral filter sigma in coordinate space
TonemapReinhard
2013-08-06 21:49:02 +08:00
---------------------------
.. ocv:class:: TonemapReinhard : public Tonemap
2013-08-01 19:34:03 +08:00
This is a global tonemapping operator that models human visual system.
2013-08-06 21:49:02 +08:00
Mapping function is controlled by adaptation parameter, that is computed using light adaptation and color adaptation.
For more information see [RD05]_.
2013-08-01 19:34:03 +08:00
createTonemapReinhard
2013-08-06 21:49:02 +08:00
---------------------------
Creates TonemapReinhard object
2013-08-01 19:34:03 +08:00
.. ocv:function:: Ptr<TonemapReinhard> createTonemapReinhard(float gamma = 1.0f, float intensity = 0.0f, float light_adapt = 1.0f, float color_adapt = 0.0f)
2013-08-01 19:34:03 +08:00
2013-08-06 21:49:02 +08:00
:param gamma: gamma value for gamma correction. See :ocv:func:`createTonemap`
2013-08-06 21:49:02 +08:00
:param intensity: result intensity in [-8, 8] range. Greater intensity produces brighter results.
2013-08-06 21:49:02 +08:00
:param 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.
2013-08-06 21:49:02 +08:00
:param color_adapt: chromatic adaptation in [0, 1] range. If 1 channels are treated independently, if 0 adaptation level is the same for each channel.
2013-08-06 00:35:48 +08:00
TonemapMantiuk
2013-08-06 21:49:02 +08:00
---------------------------
2013-08-06 00:35:48 +08:00
.. ocv:class:: TonemapMantiuk : public Tonemap
2013-08-06 21:49:02 +08:00
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]_.
2013-08-06 00:35:48 +08:00
createTonemapMantiuk
2013-08-06 21:49:02 +08:00
---------------------------
2013-08-06 00:35:48 +08:00
Creates TonemapMantiuk object
2013-08-06 21:49:02 +08:00
.. ocv:function:: Ptr<TonemapMantiuk> createTonemapMantiuk(float gamma = 1.0f, float scale = 0.7f, float saturation = 1.0f)
2013-08-06 00:35:48 +08:00
2013-08-06 21:49:02 +08:00
:param gamma: gamma value for gamma correction. See :ocv:func:`createTonemap`
2013-08-06 21:49:02 +08:00
:param 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.
2013-08-06 21:49:02 +08:00
:param saturation: saturation enhancement value. See :ocv:func:`createTonemapDrago`
AlignExposures
2013-08-06 21:49:02 +08:00
---------------------------
.. ocv:class:: AlignExposures : public Algorithm
2013-08-01 19:34:03 +08:00
The base class for algorithms that align images of the same scene with different exposures
AlignExposures::process
2013-08-06 21:49:02 +08:00
---------------------------
2013-08-01 19:34:03 +08:00
Aligns images
.. ocv:function:: void AlignExposures::process(InputArrayOfArrays src, std::vector<Mat>& dst, InputArray times, InputArray response)
2013-08-01 19:34:03 +08:00
:param src: vector of input images
2013-08-01 19:34:03 +08:00
:param dst: vector of aligned images
2013-08-01 19:34:03 +08:00
:param times: vector of exposure time values for each image
2013-08-07 15:15:41 +08:00
:param response: 256x1 matrix with inverse camera response function for each pixel value, it should have the same number of channels as images.
2013-08-01 19:34:03 +08:00
AlignMTB
2013-08-06 21:49:02 +08:00
---------------------------
.. ocv:class:: AlignMTB : public AlignExposures
2013-07-19 04:23:49 +08:00
2013-08-06 21:49:02 +08:00
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.
2013-07-19 04:23:49 +08:00
2013-08-06 21:49:02 +08:00
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]_.
2013-08-01 19:34:03 +08:00
AlignMTB::process
2013-08-06 21:49:02 +08:00
---------------------------
2013-08-01 19:34:03 +08:00
Short version of process, that doesn't take extra arguments.
.. ocv:function:: void AlignMTB::process(InputArrayOfArrays src, std::vector<Mat>& dst)
2013-08-01 19:34:03 +08:00
:param src: vector of input images
2013-08-01 19:34:03 +08:00
:param dst: vector of aligned images
AlignMTB::calculateShift
2013-08-06 21:49:02 +08:00
---------------------------
Calculates shift between two images, i. e. how to shift the second image to correspond it with the first.
2013-08-01 19:34:03 +08:00
.. ocv:function:: Point AlignMTB::calculateShift(InputArray img0, InputArray img1)
2013-08-01 19:34:03 +08:00
:param img0: first image
2013-08-01 19:34:03 +08:00
:param img1: second image
2013-07-19 04:23:49 +08:00
2013-08-01 19:34:03 +08:00
AlignMTB::shiftMat
2013-08-06 21:49:02 +08:00
---------------------------
Helper function, that shift Mat filling new regions with zeros.
2013-08-01 19:34:03 +08:00
.. ocv:function:: void AlignMTB::shiftMat(InputArray src, OutputArray dst, const Point shift)
:param src: input image
2013-08-01 19:34:03 +08:00
:param dst: result image
2013-08-01 19:34:03 +08:00
:param shift: shift value
2013-09-06 18:43:04 +08:00
AlignMTB::computeBitmaps
---------------------------
Computes median threshold and exclude bitmaps of given image.
.. ocv:function:: void AlignMTB::computeBitmaps(InputArray img, OutputArray tb, OutputArray eb)
2013-09-06 18:43:04 +08:00
:param img: input image
2013-09-06 18:43:04 +08:00
:param tb: median threshold bitmap
2013-09-06 18:43:04 +08:00
:param eb: exclude bitmap
2013-08-01 19:34:03 +08:00
createAlignMTB
2013-08-06 21:49:02 +08:00
---------------------------
2013-08-01 19:34:03 +08:00
Creates AlignMTB object
2013-09-06 18:43:04 +08:00
.. ocv:function:: Ptr<AlignMTB> createAlignMTB(int max_bits = 6, int exclude_range = 4, bool cut = true)
2013-08-06 21:49:02 +08:00
:param 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).
2013-08-06 21:49:02 +08:00
:param exclude_range: range for exclusion bitmap that is constructed to suppress noise around the median value.
2013-09-06 22:21:59 +08:00
:param cut: if true cuts images, otherwise fills the new regions with zeros.
CalibrateCRF
2013-08-06 21:49:02 +08:00
---------------------------
.. ocv:class:: CalibrateCRF : public Algorithm
2013-08-01 19:34:03 +08:00
The base class for camera response calibration algorithms.
CalibrateCRF::process
2013-08-06 21:49:02 +08:00
---------------------------
2013-08-07 15:15:41 +08:00
Recovers inverse camera response.
2013-08-01 19:34:03 +08:00
.. ocv:function:: void CalibrateCRF::process(InputArrayOfArrays src, OutputArray dst, InputArray times)
2013-08-01 19:34:03 +08:00
:param src: vector of input images
2013-08-07 15:15:41 +08:00
:param dst: 256x1 matrix with inverse camera response function
2013-08-01 19:34:03 +08:00
:param times: vector of exposure time values for each image
2013-08-01 19:34:03 +08:00
CalibrateDebevec
2013-08-06 21:49:02 +08:00
---------------------------
.. ocv:class:: CalibrateDebevec : public CalibrateCRF
2013-08-01 19:34:03 +08:00
2013-08-06 21:49:02 +08:00
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]_.
2013-08-01 19:34:03 +08:00
createCalibrateDebevec
2013-08-06 21:49:02 +08:00
---------------------------
2013-08-01 19:34:03 +08:00
Creates CalibrateDebevec object
2013-09-06 18:43:04 +08:00
.. ocv:function:: createCalibrateDebevec(int samples = 70, float lambda = 10.0f, bool random = false)
2013-08-01 19:34:03 +08:00
:param samples: number of pixel locations to use
2013-08-06 21:49:02 +08:00
:param lambda: smoothness term weight. Greater values produce smoother results, but can alter the response.
2013-09-06 22:21:59 +08:00
:param random: if true sample pixel locations are chosen at random, otherwise the form a rectangular grid.
2013-09-06 22:21:59 +08:00
CalibrateRobertson
---------------------------
.. ocv:class:: CalibrateRobertson : public CalibrateCRF
2013-09-06 22:21:59 +08:00
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
.. ocv:function:: createCalibrateRobertson(int max_iter = 30, float threshold = 0.01f)
:param max_iter: maximal number of Gauss-Seidel solver iterations.
2013-09-06 22:21:59 +08:00
:param threshold: target difference between results of two successive steps of the minimization.
MergeExposures
2013-08-06 21:49:02 +08:00
---------------------------
.. ocv:class:: MergeExposures : public Algorithm
2013-08-01 19:34:03 +08:00
The base class algorithms that can merge exposure sequence to a single image.
MergeExposures::process
2013-08-06 21:49:02 +08:00
---------------------------
2013-08-01 19:34:03 +08:00
Merges images.
.. ocv:function:: void MergeExposures::process(InputArrayOfArrays src, OutputArray dst, InputArray times, InputArray response)
2013-08-01 19:34:03 +08:00
:param src: vector of input images
2013-08-01 19:34:03 +08:00
:param dst: result image
2013-08-01 19:34:03 +08:00
:param times: vector of exposure time values for each image
2013-08-07 15:15:41 +08:00
:param response: 256x1 matrix with inverse camera response function for each pixel value, it should have the same number of channels as images.
2013-08-01 19:34:03 +08:00
MergeDebevec
2013-08-06 21:49:02 +08:00
---------------------------
.. ocv:class:: MergeDebevec : public MergeExposures
2013-08-01 19:34:03 +08:00
2013-09-06 18:49:19 +08:00
The resulting HDR image is calculated as weighted average of the exposures considering exposure values and camera response.
2013-08-06 21:49:02 +08:00
For more information see [DM97]_.
2013-08-01 19:34:03 +08:00
createMergeDebevec
2013-08-06 21:49:02 +08:00
---------------------------
2013-08-01 19:34:03 +08:00
Creates MergeDebevec object
2013-08-06 19:41:32 +08:00
.. ocv:function:: Ptr<MergeDebevec> createMergeDebevec()
2013-08-01 19:34:03 +08:00
MergeMertens
2013-08-06 21:49:02 +08:00
---------------------------
.. ocv:class:: MergeMertens : public MergeExposures
2013-08-01 19:34:03 +08:00
2013-08-06 21:49:02 +08:00
Pixels are weighted using contrast, saturation and well-exposedness measures, than images are combined using laplacian pyramids.
2013-08-06 22:13:34 +08:00
The resulting image weight is constructed as weighted average of contrast, saturation and well-exposedness measures.
2013-08-06 21:49:02 +08:00
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.
2013-08-01 19:34:03 +08:00
2013-08-06 21:49:02 +08:00
For more information see [MK07]_.
2013-08-01 19:34:03 +08:00
MergeMertens::process
2013-08-06 21:49:02 +08:00
---------------------------
2013-08-01 19:34:03 +08:00
Short version of process, that doesn't take extra arguments.
.. ocv:function:: void MergeMertens::process(InputArrayOfArrays src, OutputArray dst)
:param src: vector of input images
2013-08-01 19:34:03 +08:00
:param dst: result image
createMergeMertens
2013-08-06 21:49:02 +08:00
---------------------------
2013-08-01 19:34:03 +08:00
Creates MergeMertens object
.. ocv:function:: Ptr<MergeMertens> createMergeMertens(float contrast_weight = 1.0f, float saturation_weight = 1.0f, float exposure_weight = 0.0f)
2013-08-06 22:13:34 +08:00
:param contrast_weight: contrast measure weight. See :ocv:class:`MergeMertens`.
2013-08-06 22:13:34 +08:00
:param saturation_weight: saturation measure weight
2013-08-06 22:13:34 +08:00
:param exposure_weight: well-exposedness measure weight
2013-09-06 22:21:59 +08:00
MergeRobertson
---------------------------
.. ocv:class:: MergeRobertson : public MergeExposures
2013-09-06 22:21:59 +08:00
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
.. ocv:function:: Ptr<MergeRobertson> createMergeRobertson()
2013-08-06 21:49:02 +08:00
References
2014-04-11 13:19:35 +08:00
---------------------------
2013-08-06 21:49:02 +08:00
2013-08-06 22:13:34 +08:00
.. [DM03] F. Drago, K. Myszkowski, T. Annen, N. Chiba, "Adaptive Logarithmic Mapping For Displaying High Contrast Scenes", Computer Graphics Forum, 2003, 22, 419 - 426.
2013-08-06 21:49:02 +08:00
2013-08-06 22:13:34 +08:00
.. [FL02] R. Fattal, D. Lischinski, M. Werman, "Gradient Domain High Dynamic Range Compression", Proceedings OF ACM SIGGRAPH, 2002, 249 - 256.
2013-08-06 21:49:02 +08:00
.. [DD02] F. Durand and Julie Dorsey, "Fast Bilateral Filtering for the Display of High-Dynamic-Range Images", ACM Transactions on Graphics, 2002, 21, 3, 257 - 266.
2013-08-06 21:49:02 +08:00
2013-08-06 22:13:34 +08:00
.. [RD05] E. Reinhard, K. Devlin, "Dynamic Range Reduction Inspired by Photoreceptor Physiology", IEEE Transactions on Visualization and Computer Graphics, 2005, 11, 13 - 24.
2013-08-06 21:49:02 +08:00
2013-08-06 22:13:34 +08:00
.. [MM06] R. 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.
2013-08-06 21:49:02 +08:00
2013-08-06 22:13:34 +08:00
.. [GW03] G. Ward, "Fast, Robust Image Registration for Compositing High Dynamic Range Photographs from Handheld Exposures", Journal of Graphics Tools, 2003, 8, 17 - 30.
2013-08-06 21:49:02 +08:00
2013-08-06 22:13:34 +08:00
.. [DM97] P. Debevec, J. Malik, "Recovering High Dynamic Range Radiance Maps from Photographs", Proceedings OF ACM SIGGRAPH, 1997, 369 - 378.
2013-08-06 21:49:02 +08:00
2013-08-06 22:13:34 +08:00
.. [MK07] T. Mertens, J. Kautz, F. Van Reeth, "Exposure Fusion", Proceedings of the 15th Pacific Conference on Computer Graphics and Applications, 2007, 382 - 390.
2013-09-06 22:21:59 +08:00
.. [RB99] M. Robertson , S. Borman , R. Stevenson , "Dynamic range improvement through multiple exposures ", Proceedings of the Int. Conf. on Image Processing , 1999, 159 - 163.