mirror of
https://github.com/opencv/opencv.git
synced 2024-11-28 13:10:12 +08:00
fixing bug #3345
This commit is contained in:
parent
4ce684e61c
commit
b036fc756a
@ -718,7 +718,7 @@ void cv::boxFilter( InputArray _src, OutputArray _dst, int ddepth,
|
||||
ddepth = sdepth;
|
||||
_dst.create( src.size(), CV_MAKETYPE(ddepth, cn) );
|
||||
Mat dst = _dst.getMat();
|
||||
if( borderType != BORDER_CONSTANT && normalize )
|
||||
if( borderType != BORDER_CONSTANT && normalize && (borderType & BORDER_ISOLATED) != 0 )
|
||||
{
|
||||
if( src.rows == 1 )
|
||||
ksize.height = 1;
|
||||
|
@ -1886,3 +1886,33 @@ protected:
|
||||
};
|
||||
|
||||
TEST(Imgproc_Filtering, supportedFormats) { CV_FilterSupportedFormatsTest test; test.safe_run(); }
|
||||
|
||||
TEST(Imgproc_Blur, borderTypes)
|
||||
{
|
||||
Size kernelSize(3, 3);
|
||||
|
||||
/// ksize > src_roi.size()
|
||||
Mat src(3, 3, CV_8UC1, cv::Scalar::all(255)), dst;
|
||||
Mat src_roi = src(Rect(1, 1, 1, 1));
|
||||
src_roi.setTo(cv::Scalar::all(0));
|
||||
|
||||
// should work like !BORDER_ISOLATED
|
||||
blur(src_roi, dst, kernelSize, Point(-1, -1), BORDER_REPLICATE);
|
||||
EXPECT_EQ(227, dst.at<uchar>(0, 0));
|
||||
|
||||
// should work like BORDER_ISOLATED
|
||||
blur(src_roi, dst, kernelSize, Point(-1, -1), BORDER_ISOLATED);
|
||||
EXPECT_EQ(0, dst.at<uchar>(0, 0));
|
||||
|
||||
/// ksize <= src_roi.size()
|
||||
src = Mat(5, 5, CV_8UC1, cv::Scalar(255));
|
||||
src_roi = src(Rect(1, 1, 3, 3));
|
||||
src_roi.setTo(0);
|
||||
src.at<uchar>(2, 2) = 255;
|
||||
|
||||
// should work like !BORDER_ISOLATED
|
||||
blur(src_roi, dst, kernelSize, Point(-1, -1), BORDER_REPLICATE);
|
||||
Mat expected_dst =
|
||||
(Mat_<uchar>(3, 3) << 170, 113, 170, 113, 28, 113, 170, 113, 170);
|
||||
EXPECT_EQ(9 * 255, cv::sum(expected_dst == dst).val[0]);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user