mirror of
https://github.com/opencv/opencv.git
synced 2024-11-24 11:10:21 +08:00
suppress GaussianBlur to generate empty images
* sharp Gaussian kernel causes over flow and ends up in blank image
This commit is contained in:
parent
1e0d290f2e
commit
1e74f5850b
@ -445,8 +445,8 @@ PARAM_TEST_CASE(GaussianBlur, cv::cuda::DeviceInfo, cv::Size, MatDepth, Channels
|
||||
CUDA_TEST_P(GaussianBlur, Accuracy)
|
||||
{
|
||||
cv::Mat src = randomMat(size, type);
|
||||
double sigma1 = randomDouble(0.1, 1.0);
|
||||
double sigma2 = randomDouble(0.1, 1.0);
|
||||
double sigma1 = randomDouble(0.0, 1.0);
|
||||
double sigma2 = randomDouble(0.0, 1.0);
|
||||
|
||||
cv::Ptr<cv::cuda::Filter> gauss = cv::cuda::createGaussianFilter(src.type(), -1, ksize, sigma1, sigma2, borderType);
|
||||
|
||||
|
@ -1958,7 +1958,10 @@ public:
|
||||
}
|
||||
else if (kxlen % 2 == 1)
|
||||
{
|
||||
hlineSmoothFunc = hlineSmoothONa_yzy_a;
|
||||
if (kx[(kxlen - 1)/ 2] == FT::one())
|
||||
hlineSmoothFunc = hlineSmooth1N1;
|
||||
else
|
||||
hlineSmoothFunc = hlineSmoothONa_yzy_a;
|
||||
for (int i = 0; i < kxlen / 2; i++)
|
||||
if (!(kx[i] == kx[kxlen - 1 - i]))
|
||||
{
|
||||
|
@ -249,4 +249,15 @@ TEST(GaussianBlur_Bitexact, regression_9863)
|
||||
checkGaussianBlur_8Uvs32F(src8u, src32f, 151, 30);
|
||||
}
|
||||
|
||||
TEST(GaussianBlur_Bitexact, overflow_20792)
|
||||
{
|
||||
Mat src(128, 128, CV_16UC1, Scalar(255));
|
||||
Mat dst;
|
||||
double sigma = theRNG().uniform(0.0, 0.2); // a peaky kernel
|
||||
GaussianBlur(src, dst, Size(7, 7), sigma, 0.9);
|
||||
int count = (int)countNonZero(dst);
|
||||
int nintyPercent = (int)(src.rows*src.cols * 0.9);
|
||||
EXPECT_GT(count, nintyPercent);
|
||||
}
|
||||
|
||||
}} // namespace
|
||||
|
Loading…
Reference in New Issue
Block a user