Skip to content

Commit 73d4f12

Browse files
committed
Merge pull request opencv#9997 from ElenaGvozdeva:GaussianBlur_bug
2 parents 0eb1bfa + eb136eb commit 73d4f12

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

modules/core/include/opencv2/core/mat.inl.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -508,15 +508,15 @@ Mat::Mat(int _rows, int _cols, int _type, void* _data, size_t _step)
508508
}
509509
else
510510
{
511-
if( rows == 1 ) _step = minstep;
512511
CV_DbgAssert( _step >= minstep );
513512

514513
if (_step % esz1 != 0)
515514
{
516515
CV_Error(Error::BadStep, "Step must be a multiple of esz1");
517516
}
518517

519-
flags |= _step == minstep ? CONTINUOUS_FLAG : 0;
518+
if (_step == minstep || rows == 1)
519+
flags |= CONTINUOUS_FLAG;
520520
}
521521
step[0] = _step;
522522
step[1] = esz;
@@ -541,15 +541,15 @@ Mat::Mat(Size _sz, int _type, void* _data, size_t _step)
541541
}
542542
else
543543
{
544-
if( rows == 1 ) _step = minstep;
545544
CV_DbgAssert( _step >= minstep );
546545

547546
if (_step % esz1 != 0)
548547
{
549548
CV_Error(Error::BadStep, "Step must be a multiple of esz1");
550549
}
551550

552-
flags |= _step == minstep ? CONTINUOUS_FLAG : 0;
551+
if (_step == minstep || rows == 1)
552+
flags |= CONTINUOUS_FLAG;
553553
}
554554
step[0] = _step;
555555
step[1] = esz;

modules/imgproc/test/test_filter.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1982,6 +1982,27 @@ TEST(Imgproc_Blur, borderTypes)
19821982
EXPECT_DOUBLE_EQ(0.0, cvtest::norm(expected_dst, dst, NORM_INF));
19831983
}
19841984

1985+
TEST(Imgproc_GaussianBlur, borderTypes)
1986+
{
1987+
Size kernelSize(3, 3);
1988+
1989+
Mat src_16(16, 16, CV_8UC1, cv::Scalar::all(42)), dst_16;
1990+
Mat src_roi_16 = src_16(Rect(1, 1, 14, 14));
1991+
src_roi_16.setTo(cv::Scalar::all(3));
1992+
1993+
cv::GaussianBlur(src_roi_16, dst_16, kernelSize, 0, 0, BORDER_REPLICATE);
1994+
1995+
EXPECT_EQ(20, dst_16.at<uchar>(0, 0));
1996+
1997+
Mat src(3, 12, CV_8UC1, cv::Scalar::all(42)), dst;
1998+
Mat src_roi = src(Rect(1, 1, 10, 1));
1999+
src_roi.setTo(cv::Scalar::all(2));
2000+
2001+
cv::GaussianBlur(src_roi, dst, kernelSize, 0, 0, BORDER_REPLICATE);
2002+
2003+
EXPECT_EQ(27, dst.at<uchar>(0, 0));
2004+
}
2005+
19852006
TEST(Imgproc_Morphology, iterated)
19862007
{
19872008
RNG& rng = theRNG();

0 commit comments

Comments
 (0)