Merge pull request #13478 from terfendail:medianblur_fix

pull/13484/head
Alexander Alekhin 6 years ago
commit 3d5cebb3ac
  1. 8
      modules/imgproc/src/median_blur.cpp
  2. 11
      modules/imgproc/test/test_filter.cpp

@ -282,10 +282,10 @@ medianBlur_8u_O1( const Mat& _src, Mat& _dst, int ksize )
for ( ; luc[c][k] < j+r+1; ++luc[c][k] )
{
#if CV_SIMD256
v_fine += v256_load(px + 16 * MIN(luc[c][k], n - 1)) - v256_load(px + 16 * MAX(luc[c][k] - 2 * r - 1, 0));
v_fine = v_fine + v256_load(px + 16 * MIN(luc[c][k], n - 1)) - v256_load(px + 16 * MAX(luc[c][k] - 2 * r - 1, 0));
#elif CV_SIMD128
v_finel += v_load(px + 16 * MIN(luc[c][k], n - 1) ) - v_load(px + 16 * MAX(luc[c][k] - 2 * r - 1, 0));
v_fineh += v_load(px + 16 * MIN(luc[c][k], n - 1) + 8) - v_load(px + 16 * MAX(luc[c][k] - 2 * r - 1, 0) + 8);
v_finel = v_finel + v_load(px + 16 * MIN(luc[c][k], n - 1) ) - v_load(px + 16 * MAX(luc[c][k] - 2 * r - 1, 0));
v_fineh = v_fineh + v_load(px + 16 * MIN(luc[c][k], n - 1) + 8) - v_load(px + 16 * MAX(luc[c][k] - 2 * r - 1, 0) + 8);
#else
for (int ind = 0; ind < 16; ++ind)
H[c].fine[k][ind] += px[16 * MIN(luc[c][k], n - 1) + ind] - px[16 * MAX(luc[c][k] - 2 * r - 1, 0) + ind];
@ -321,11 +321,11 @@ medianBlur_8u_O1( const Mat& _src, Mat& _dst, int ksize )
CV_Assert( b < 16 );
}
}
}
#if CV_SIMD
vx_cleanup();
#endif
}
}
#undef HOP
#undef COP

@ -2200,4 +2200,15 @@ TEST(Imgproc_Filter2D, dftFilter2d_regression_10683)
EXPECT_LE(cvtest::norm(dst, expected, NORM_INF), 2);
}
TEST(Imgproc_MedianBlur, hires_regression_13409)
{
Mat src(2048, 2048, CV_8UC1), dst_hires, dst_ref;
randu(src, 0, 256);
medianBlur(src, dst_hires, 9);
medianBlur(src(Rect(512, 512, 1024, 1024)), dst_ref, 9);
ASSERT_EQ(0.0, cvtest::norm(dst_hires(Rect(516, 516, 1016, 1016)), dst_ref(Rect(4, 4, 1016, 1016)), NORM_INF));
}
}} // namespace

Loading…
Cancel
Save