From d84360e7f3490b806ea682bcc2bf4517b2163035 Mon Sep 17 00:00:00 2001 From: keeper121 Date: Sun, 16 Feb 2020 19:33:25 +0300 Subject: [PATCH] Merge pull request #16497 from keeper121:master * Fix NN resize with dimentions > 4 * add test check for nn resize with channels > 4 * Change types from float to double * Del unnecessary test file. Move nn test to test_imgwarp. Add 5 channels test only. --- modules/imgproc/src/resize.cpp | 2 +- modules/imgproc/test/test_imgwarp.cpp | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/modules/imgproc/src/resize.cpp b/modules/imgproc/src/resize.cpp index 43458cc153..f510018400 100644 --- a/modules/imgproc/src/resize.cpp +++ b/modules/imgproc/src/resize.cpp @@ -1045,7 +1045,7 @@ public: { const int* _tS = (const int*)(S + x_ofs[x]); int* _tD = (int*)D; - for( int k = 0; k < pix_size4; k++ ) + for( int k = 0; k <= pix_size4; k++ ) _tD[k] = _tS[k]; } } diff --git a/modules/imgproc/test/test_imgwarp.cpp b/modules/imgproc/test/test_imgwarp.cpp index 232f374548..ffd5ecca95 100644 --- a/modules/imgproc/test/test_imgwarp.cpp +++ b/modules/imgproc/test/test_imgwarp.cpp @@ -1721,6 +1721,21 @@ TEST(Resize, lanczos4_regression_16192) EXPECT_EQ(cvtest::norm(dst, expected, NORM_INF), 0) << dst(Rect(0,0,8,8)); } +TEST(Resize, nearest_regression_15075) +{ + const int C = 5; + const int i1 = 5, j1 = 5; + Size src_size(12, 12); + Size dst_size(11, 11); + + cv::Mat src = cv::Mat::zeros(src_size, CV_8UC(C)), dst; + for (int j = 0; j < C; j++) + src.col(i1).row(j1).data[j] = 1; + + cv::resize(src, dst, dst_size, 0, 0, INTER_NEAREST); + EXPECT_EQ(C, cvtest::norm(dst, NORM_L1)) << src.size; +} + TEST(Imgproc_Warp, multichannel) { static const int inter_types[] = {INTER_NEAREST, INTER_AREA, INTER_CUBIC,