opencv3.0 illuminationChange Issue and bug fix [closed]
Hi,
I have find a bug in illuminationChange sample. when I use the illuminationchange sample code to test the function.The result is wrong.
I have tried to fix the bug and it looked as if I were succeeding. The result is as follow:
The bug is in the file sources\modules\photo\src\seamless_cloning.hpp (line 549 and 553), in the functon Cloning::illum_change. The magnitude of the place outside of mask is [0, 0, 0] and if calucalate: pow(mag, -1 * beta, multy_temp); The value of multy_temp will be "-1.#IND".
what I have do is do filter the mag value as follow:
for (int i = 0; i < mag.cols; i++)
{
for (int j = 0; j < mag.rows; j++)
{
if (mag.at<cv::Vec3f>(j, i)[0] == 0)
mag.at<cv::Vec3f>(j, i)[0] = 1e-8;
if (mag.at<cv::Vec3f>(j, i)[1] == 0)
mag.at<cv::Vec3f>(j, i)[1] = 1e-8;
if (mag.at<cv::Vec3f>(j, i)[2] == 0)
mag.at<cv::Vec3f>(j, i)[2] = 1e-8;
}
}
This is my solutionn. There must be some better methods to fix the bug.
could you add a link to the sample ? can't find it.
And provide a fix if you find one through this topic! Thanks in advance!
@berak , There is bug in the api illuminationChange" not the sample. The api can find in http://docs.opencv.org/trunk/modules/photo/doc/cloning.html . The problem is in the Cloning::illum_change functions. https://github.com/Itseez/opencv/blob/master/modules/photo/src/seamless_cloning.hpp
@StevenPuttemans . Adding the code in my question after line 544 can fix the bug. https://github.com/Itseez/opencv/blob/master/modules/photo/src/seamless_cloning.hpp
@vsooda, i know, just wanted to play around with it ;)
you made it pretty obvious already. wherever mag is 0, pow(mag, -something) is INF. well understood.
@berak . Thank you. This is my first time to report bug. The test data are in this page https://github.com/Itseez/opencv_extra/tree/master/testdata/cv/cloning/Illumination_Change . You can simplely read the source image and mask, then call the api illuminationChange. And the show the result. You can also see the test code in https://github.com/Itseez/opencv/blob/master/modules/photo/test/test_cloning.cpp (TEST(Photo_SeamlessClone_illuminationChange, regression))
@vsooda, thanks a lot, i somehow missed that.
(and no fear, even if you're new to it, all of them quite good questions, imho, keep on with it ;)
@berak, thank you. I am using opencv for my researsh recently. If I find any other bug, I will report and fix it.