Itseez/opencv — pull request #2123 by white-pony (2014-01-08 18:02:13+00:00)
Title: Fixed incorrect handling of uniformly filled areas in the MergeMertens

I've added epsilon value to weights in the MergeMertens in order to avoid zero weights for pixels from uniformly filled areas of image. In particular, this is a case for overexposed areas, which are quite common if you do exposure fusion.

If you want to reproduce this problem you can use following code:

```c++
#include
#include
#include

#include
#include

void exposureFusion(std::vector& filesToFuse, cv::Mat& fusedImage)
{
std::cout << "Exposure fusion...\n";
std::vector images;
for(std::size_t ix = 0; ix < filesToFuse.size(); ix++)
{
std::cout << ix <<": " << filesToFuse[ix] << "\n";
images.push_back(cv::imread(filesToFuse[ix]));
}

cv::MergeMertens mergeMertens(1.0f, 1.0f, 0.0f);
mergeMertens.process(images, fusedImage);
}

int main(int argc, char* argv[])
{
if(argc < 4)
{
std::cout << "Usage: ./ExposureFusion input_1 ...input_n output\n";
return 0;
}

std::vector inputFilesToProcess;

for(int ix = 1; ix < argc - 1; ix++)
inputFilesToProcess.push_back(std::string(argv[ix]));

std::string outputFile = std::string(argv[argc - 1]);

if(inputFilesToProcess.size() > 1)
{
cv::Mat fusedImage;

exposureFusion(inputFilesToProcess, fusedImage);
cv::imwrite(outputFile, fusedImage * 255);

std::cout << "Saving fused image: " << outputFile << "\n";
}

return 0;
}
```
and pass uniformly filled (let say with green color) image twice. As output you will get absolutely black image, which is incorrect, as it should be exactly the same as input data.

Thanks!