Unverified Commit 734de34b authored by Alexander Alekhin's avatar Alexander Alekhin Committed by GitHub

Merge pull request #16085 from alalek:imgproc_threshold_to_zero_ipp_bug

* imgproc(IPP): wrong result from threshold(THRESH_TOZERO)

* imgproc(IPP): disable IPP code to pass THRESH_TOZERO test
parent 629d47fc
...@@ -774,6 +774,7 @@ thresh_32f( const Mat& _src, Mat& _dst, float thresh, float maxval, int type ) ...@@ -774,6 +774,7 @@ thresh_32f( const Mat& _src, Mat& _dst, float thresh, float maxval, int type )
} }
setIppErrorStatus(); setIppErrorStatus();
break; break;
#if 0 // details: https://github.com/opencv/opencv/pull/16085
case THRESH_TOZERO: case THRESH_TOZERO:
if (0 <= CV_INSTRUMENT_FUN_IPP(ippiThreshold_LTVal_32f_C1R, src, (int)src_step*sizeof(src[0]), dst, (int)dst_step*sizeof(dst[0]), sz, thresh + FLT_EPSILON, 0)) if (0 <= CV_INSTRUMENT_FUN_IPP(ippiThreshold_LTVal_32f_C1R, src, (int)src_step*sizeof(src[0]), dst, (int)dst_step*sizeof(dst[0]), sz, thresh + FLT_EPSILON, 0))
{ {
...@@ -782,6 +783,7 @@ thresh_32f( const Mat& _src, Mat& _dst, float thresh, float maxval, int type ) ...@@ -782,6 +783,7 @@ thresh_32f( const Mat& _src, Mat& _dst, float thresh, float maxval, int type )
} }
setIppErrorStatus(); setIppErrorStatus();
break; break;
#endif
case THRESH_TOZERO_INV: case THRESH_TOZERO_INV:
if (0 <= CV_INSTRUMENT_FUN_IPP(ippiThreshold_GTVal_32f_C1R, src, (int)src_step*sizeof(src[0]), dst, (int)dst_step*sizeof(dst[0]), sz, thresh, 0)) if (0 <= CV_INSTRUMENT_FUN_IPP(ippiThreshold_GTVal_32f_C1R, src, (int)src_step*sizeof(src[0]), dst, (int)dst_step*sizeof(dst[0]), sz, thresh, 0))
{ {
......
...@@ -434,4 +434,13 @@ BIGDATA_TEST(Imgproc_Threshold, huge) ...@@ -434,4 +434,13 @@ BIGDATA_TEST(Imgproc_Threshold, huge)
ASSERT_EQ((uint64)nz, n / 2); ASSERT_EQ((uint64)nz, n / 2);
} }
TEST(Imgproc_Threshold, regression_THRESH_TOZERO_IPP_16085)
{
Size sz(16, 16);
Mat input(sz, CV_32F, Scalar::all(2));
Mat result;
cv::threshold(input, result, 2.0, 0.0, THRESH_TOZERO);
EXPECT_EQ(0, cv::norm(result, NORM_INF));
}
}} // namespace }} // namespace
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment