提交 ab2c21e7 编写于 作者: A Alexander Alekhin

Merge pull request #11531 from alalek:issue_11518

...@@ -251,13 +251,15 @@ void Cloning::initVariables(const Mat &destination, const Mat &binaryMask) ...@@ -251,13 +251,15 @@ void Cloning::initVariables(const Mat &destination, const Mat &binaryMask)
//init of the filters used in the dst //init of the filters used in the dst
const int w = destination.cols; const int w = destination.cols;
filter_X.resize(w - 2); filter_X.resize(w - 2);
double scale = CV_PI / (w - 1);
for(int i = 0 ; i < w-2 ; ++i) for(int i = 0 ; i < w-2 ; ++i)
filter_X[i] = 2.0f * std::cos(static_cast<float>(CV_PI) * (i + 1) / (w - 1)); filter_X[i] = 2.0f * (float)std::cos(scale * (i + 1));
const int h = destination.rows; const int h = destination.rows;
filter_Y.resize(h - 2); filter_Y.resize(h - 2);
scale = CV_PI / (h - 1);
for(int j = 0 ; j < h - 2 ; ++j) for(int j = 0 ; j < h - 2 ; ++j)
filter_Y[j] = 2.0f * std::cos(static_cast<float>(CV_PI) * (j + 1) / (h - 1)); filter_Y[j] = 2.0f * (float)std::cos(scale * (j + 1));
} }
void Cloning::computeDerivatives(const Mat& destination, const Mat &patch, const Mat &binaryMask) void Cloning::computeDerivatives(const Mat& destination, const Mat &patch, const Mat &binaryMask)
......
...@@ -53,7 +53,7 @@ namespace opencv_test { namespace { ...@@ -53,7 +53,7 @@ namespace opencv_test { namespace {
#define SAVE(x) #define SAVE(x)
#endif #endif
static const double numerical_precision = 1000.; static const double numerical_precision = 0.05; // 95% of pixels should have exact values
TEST(Photo_SeamlessClone_normal, regression) TEST(Photo_SeamlessClone_normal, regression)
{ {
...@@ -82,8 +82,10 @@ TEST(Photo_SeamlessClone_normal, regression) ...@@ -82,8 +82,10 @@ TEST(Photo_SeamlessClone_normal, regression)
SAVE(result); SAVE(result);
double error = cvtest::norm(reference, result, NORM_L1); double errorINF = cvtest::norm(reference, result, NORM_INF);
EXPECT_LE(error, numerical_precision); EXPECT_LE(errorINF, 1);
double errorL1 = cvtest::norm(reference, result, NORM_L1);
EXPECT_LE(errorL1, reference.total() * numerical_precision) << "size=" << reference.size();
} }
TEST(Photo_SeamlessClone_mixed, regression) TEST(Photo_SeamlessClone_mixed, regression)
...@@ -113,9 +115,10 @@ TEST(Photo_SeamlessClone_mixed, regression) ...@@ -113,9 +115,10 @@ TEST(Photo_SeamlessClone_mixed, regression)
Mat reference = imread(reference_path); Mat reference = imread(reference_path);
ASSERT_FALSE(reference.empty()) << "Could not load reference image " << reference_path; ASSERT_FALSE(reference.empty()) << "Could not load reference image " << reference_path;
double error = cvtest::norm(reference, result, NORM_L1); double errorINF = cvtest::norm(reference, result, NORM_INF);
EXPECT_LE(error, numerical_precision); EXPECT_LE(errorINF, 1);
double errorL1 = cvtest::norm(reference, result, NORM_L1);
EXPECT_LE(errorL1, reference.total() * numerical_precision) << "size=" << reference.size();
} }
TEST(Photo_SeamlessClone_featureExchange, regression) TEST(Photo_SeamlessClone_featureExchange, regression)
...@@ -145,9 +148,10 @@ TEST(Photo_SeamlessClone_featureExchange, regression) ...@@ -145,9 +148,10 @@ TEST(Photo_SeamlessClone_featureExchange, regression)
Mat reference = imread(reference_path); Mat reference = imread(reference_path);
ASSERT_FALSE(reference.empty()) << "Could not load reference image " << reference_path; ASSERT_FALSE(reference.empty()) << "Could not load reference image " << reference_path;
double error = cvtest::norm(reference, result, NORM_L1); double errorINF = cvtest::norm(reference, result, NORM_INF);
EXPECT_LE(error, numerical_precision); EXPECT_LE(errorINF, 1);
double errorL1 = cvtest::norm(reference, result, NORM_L1);
EXPECT_LE(errorL1, reference.total() * numerical_precision) << "size=" << reference.size();
} }
TEST(Photo_SeamlessClone_colorChange, regression) TEST(Photo_SeamlessClone_colorChange, regression)
...@@ -171,9 +175,10 @@ TEST(Photo_SeamlessClone_colorChange, regression) ...@@ -171,9 +175,10 @@ TEST(Photo_SeamlessClone_colorChange, regression)
Mat reference = imread(reference_path); Mat reference = imread(reference_path);
ASSERT_FALSE(reference.empty()) << "Could not load reference image " << reference_path; ASSERT_FALSE(reference.empty()) << "Could not load reference image " << reference_path;
double error = cvtest::norm(reference, result, NORM_L1); double errorINF = cvtest::norm(reference, result, NORM_INF);
EXPECT_LE(error, numerical_precision); EXPECT_LE(errorINF, 1);
double errorL1 = cvtest::norm(reference, result, NORM_L1);
EXPECT_LE(errorL1, reference.total() * numerical_precision) << "size=" << reference.size();
} }
TEST(Photo_SeamlessClone_illuminationChange, regression) TEST(Photo_SeamlessClone_illuminationChange, regression)
...@@ -195,9 +200,12 @@ TEST(Photo_SeamlessClone_illuminationChange, regression) ...@@ -195,9 +200,12 @@ TEST(Photo_SeamlessClone_illuminationChange, regression)
SAVE(result); SAVE(result);
Mat reference = imread(reference_path); Mat reference = imread(reference_path);
double error = cvtest::norm(reference, result, NORM_L1); ASSERT_FALSE(reference.empty()) << "Could not load reference image " << reference_path;
EXPECT_LE(error, numerical_precision);
double errorINF = cvtest::norm(reference, result, NORM_INF);
EXPECT_LE(errorINF, 1);
double errorL1 = cvtest::norm(reference, result, NORM_L1);
EXPECT_LE(errorL1, reference.total() * numerical_precision) << "size=" << reference.size();
} }
TEST(Photo_SeamlessClone_textureFlattening, regression) TEST(Photo_SeamlessClone_textureFlattening, regression)
...@@ -221,9 +229,10 @@ TEST(Photo_SeamlessClone_textureFlattening, regression) ...@@ -221,9 +229,10 @@ TEST(Photo_SeamlessClone_textureFlattening, regression)
Mat reference = imread(reference_path); Mat reference = imread(reference_path);
ASSERT_FALSE(reference.empty()) << "Could not load reference image " << reference_path; ASSERT_FALSE(reference.empty()) << "Could not load reference image " << reference_path;
double error = cvtest::norm(reference, result, NORM_L1); double errorINF = cvtest::norm(reference, result, NORM_INF);
EXPECT_LE(error, numerical_precision); EXPECT_LE(errorINF, 1);
double errorL1 = cvtest::norm(reference, result, NORM_L1);
EXPECT_LE(errorL1, reference.total() * numerical_precision) << "size=" << reference.size();
} }
}} // namespace }} // namespace
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册