Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

opencv3.0 illuminationChange Issue (file:sources\modules\photo\src\seamless_cloning.hpp)

Hi,

I have find a bug in illuminationChange sample. when I use the illuminationchange sample code to test the function.The result is wrong. image description

I have tried to fix the bug and it looked as if I were succeeding. The result is as follow: image description

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.

opencv3.0 illuminationChange Issue (file:sources\modules\photo\src\seamless_cloning.hpp)and bug fix

Hi,

I have find a bug in illuminationChange sample. when I use the illuminationchange sample code to test the function.The result is wrong. image description

I have tried to fix the bug and it looked as if I were succeeding. The result is as follow: image description

The bug is in the file sources\modules\photo\src\seamless_cloning.hpp 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.