diff --git a/modules/photo/src/merge.cpp b/modules/photo/src/merge.cpp index 7adfb5ec68..295e03c95f 100644 --- a/modules/photo/src/merge.cpp +++ b/modules/photo/src/merge.cpp @@ -208,7 +208,7 @@ public: if(channels == 3) { weights[i] = weights[i].mul(saturation); } - weights[i] = weights[i].mul(wellexp); + weights[i] = weights[i].mul(wellexp) + 1e-12f; weight_sum += weights[i]; } int maxlevel = static_cast(logf(static_cast(min(size.width, size.height))) / logf(2.0f)); diff --git a/modules/photo/test/test_hdr.cpp b/modules/photo/test/test_hdr.cpp index 82ae25f525..27773fb384 100644 --- a/modules/photo/test/test_hdr.cpp +++ b/modules/photo/test/test_hdr.cpp @@ -166,6 +166,16 @@ TEST(Photo_MergeMertens, regression) merge->process(images, result); result.convertTo(result, CV_8UC3, 255); checkEqual(expected, result, 3, "Mertens"); + + Mat uniform(100, 100, CV_8UC3); + uniform = Scalar(0, 255, 0); + + images.clear(); + images.push_back(uniform); + + merge->process(images, result); + result.convertTo(result, CV_8UC3, 255); + checkEqual(uniform, result, 1e-2f, "Mertens"); } TEST(Photo_MergeDebevec, regression)