mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 15:53:03 +04:00
Merge pull request #21258 from eplankin:fix_threshold_to_zero_ipp_bug
Fixed threshold(THRESH_TOZERO) at imgproc(IPP) * Fixed #16085: imgproc(IPP): wrong result from threshold(THRESH_TOZERO) * 1. Added test cases with float where all bits of mantissa equal 1, min and max float as inputs 2. Used nextafterf instead of cast to hex * Used float value in test instead of hex and casts * Changed input value in test
This commit is contained in:
@@ -443,4 +443,34 @@ TEST(Imgproc_Threshold, regression_THRESH_TOZERO_IPP_16085)
|
||||
EXPECT_EQ(0, cv::norm(result, NORM_INF));
|
||||
}
|
||||
|
||||
TEST(Imgproc_Threshold, regression_THRESH_TOZERO_IPP_21258)
|
||||
{
|
||||
Size sz(16, 16);
|
||||
float val = nextafterf(16.0f, 0.0f); // 0x417fffff, all bits in mantissa are 1
|
||||
Mat input(sz, CV_32F, Scalar::all(val));
|
||||
Mat result;
|
||||
cv::threshold(input, result, val, 0.0, THRESH_TOZERO);
|
||||
EXPECT_EQ(0, cv::norm(result, NORM_INF));
|
||||
}
|
||||
|
||||
TEST(Imgproc_Threshold, regression_THRESH_TOZERO_IPP_21258_Min)
|
||||
{
|
||||
Size sz(16, 16);
|
||||
float min_val = -std::numeric_limits<float>::max();
|
||||
Mat input(sz, CV_32F, Scalar::all(min_val));
|
||||
Mat result;
|
||||
cv::threshold(input, result, min_val, 0.0, THRESH_TOZERO);
|
||||
EXPECT_EQ(0, cv::norm(result, NORM_INF));
|
||||
}
|
||||
|
||||
TEST(Imgproc_Threshold, regression_THRESH_TOZERO_IPP_21258_Max)
|
||||
{
|
||||
Size sz(16, 16);
|
||||
float max_val = std::numeric_limits<float>::max();
|
||||
Mat input(sz, CV_32F, Scalar::all(max_val));
|
||||
Mat result;
|
||||
cv::threshold(input, result, max_val, 0.0, THRESH_TOZERO);
|
||||
EXPECT_EQ(0, cv::norm(result, NORM_INF));
|
||||
}
|
||||
|
||||
}} // namespace
|
||||
|
||||
Reference in New Issue
Block a user