Merge pull request #11531 from alalek:issue_11518

pull/11546/head
Alexander Alekhin 7 years ago
commit ab2c21e7c1
  1. 6
      modules/photo/src/seamless_cloning_impl.cpp
  2. 43
      modules/photo/test/test_cloning.cpp

@ -251,13 +251,15 @@ void Cloning::initVariables(const Mat &destination, const Mat &binaryMask)
//init of the filters used in the dst
const int w = destination.cols;
filter_X.resize(w - 2);
double scale = CV_PI / (w - 1);
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;
filter_Y.resize(h - 2);
scale = CV_PI / (h - 1);
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)

@ -53,7 +53,7 @@ namespace opencv_test { namespace {
#define SAVE(x)
#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)
{
@ -82,8 +82,10 @@ TEST(Photo_SeamlessClone_normal, regression)
SAVE(result);
double error = cvtest::norm(reference, result, NORM_L1);
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_mixed, regression)
@ -113,9 +115,10 @@ TEST(Photo_SeamlessClone_mixed, regression)
Mat reference = imread(reference_path);
ASSERT_FALSE(reference.empty()) << "Could not load reference image " << reference_path;
double error = cvtest::norm(reference, result, NORM_L1);
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_featureExchange, regression)
@ -145,9 +148,10 @@ TEST(Photo_SeamlessClone_featureExchange, regression)
Mat reference = imread(reference_path);
ASSERT_FALSE(reference.empty()) << "Could not load reference image " << reference_path;
double error = cvtest::norm(reference, result, NORM_L1);
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_colorChange, regression)
@ -171,9 +175,10 @@ TEST(Photo_SeamlessClone_colorChange, regression)
Mat reference = imread(reference_path);
ASSERT_FALSE(reference.empty()) << "Could not load reference image " << reference_path;
double error = cvtest::norm(reference, result, NORM_L1);
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_illuminationChange, regression)
@ -195,9 +200,12 @@ TEST(Photo_SeamlessClone_illuminationChange, regression)
SAVE(result);
Mat reference = imread(reference_path);
double error = cvtest::norm(reference, result, NORM_L1);
EXPECT_LE(error, numerical_precision);
ASSERT_FALSE(reference.empty()) << "Could not load reference image " << reference_path;
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)
@ -221,9 +229,10 @@ TEST(Photo_SeamlessClone_textureFlattening, regression)
Mat reference = imread(reference_path);
ASSERT_FALSE(reference.empty()) << "Could not load reference image " << reference_path;
double error = cvtest::norm(reference, result, NORM_L1);
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();
}
}} // namespace

Loading…
Cancel
Save