diff --git a/doc/tutorials/others/images/ldr.png b/doc/tutorials/others/images/ldr.png index 2e1a188e6b..ac420886fa 100644 Binary files a/doc/tutorials/others/images/ldr.png and b/doc/tutorials/others/images/ldr.png differ diff --git a/modules/photo/src/hdr_common.cpp b/modules/photo/src/hdr_common.cpp index 5e4bea9d85..83e1686c38 100644 --- a/modules/photo/src/hdr_common.cpp +++ b/modules/photo/src/hdr_common.cpp @@ -65,10 +65,15 @@ Mat triangleWeights() Mat w(LDR_SIZE, 1, CV_32F); int half = LDR_SIZE / 2; int maxVal = LDR_SIZE - 1; - for (int i = 0; i < LDR_SIZE; i++) - w.at(i) = (i < half) + float epsilon = 1e-6f; + for (int i = 0; i < LDR_SIZE; i++){ + float val = (i < half) ? static_cast(i) : static_cast(maxVal - i); + if (val < epsilon) + val = epsilon; + w.at(i) = val; + } return w; } diff --git a/modules/photo/src/tonemap.cpp b/modules/photo/src/tonemap.cpp index 0c9275040b..da6c1389c0 100644 --- a/modules/photo/src/tonemap.cpp +++ b/modules/photo/src/tonemap.cpp @@ -65,6 +65,7 @@ public: CV_INSTRUMENT_REGION(); Mat src = _src.getMat(); + max(src, Scalar::all(1e-6), src); CV_Assert(!src.empty()); CV_Assert(_src.dims() == 2 && _src.type() == CV_32FC3); _dst.create(src.size(), CV_32FC3); diff --git a/samples/python/tutorial_code/photo/hdr_imaging/hdr_imaging.py b/samples/python/tutorial_code/photo/hdr_imaging/hdr_imaging.py index a5403d3cca..6ab7cf1a0a 100644 --- a/samples/python/tutorial_code/photo/hdr_imaging/hdr_imaging.py +++ b/samples/python/tutorial_code/photo/hdr_imaging/hdr_imaging.py @@ -40,7 +40,7 @@ hdr = merge_debevec.process(images, times, response) ## [Make HDR image] ## [Tonemap HDR image] -tonemap = cv.createTonemap(2.2) +tonemap = cv.createTonemapDrago(2.2) ldr = tonemap.process(hdr) ## [Tonemap HDR image]