|
|
|
@ -2015,3 +2015,53 @@ TEST(Imgproc_Morphology, iterated) |
|
|
|
|
ASSERT_EQ(0.0, norm(dst0, dst2, NORM_INF)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TEST(Imgproc_Sobel, borderTypes) |
|
|
|
|
{ |
|
|
|
|
int kernelSize = 3; |
|
|
|
|
|
|
|
|
|
/// ksize > src_roi.size()
|
|
|
|
|
Mat src = (Mat_<uchar>(3, 3) << 1, 2, 3, 4, 5, 6, 7, 8, 9), dst, expected_dst; |
|
|
|
|
Mat src_roi = src(Rect(1, 1, 1, 1)); |
|
|
|
|
src_roi.setTo(cv::Scalar::all(0)); |
|
|
|
|
|
|
|
|
|
// should work like !BORDER_ISOLATED, so the function MUST read values in full matrix
|
|
|
|
|
Sobel(src_roi, dst, CV_16S, 1, 0, kernelSize, 1, 0, BORDER_REPLICATE); |
|
|
|
|
EXPECT_EQ(8, dst.at<short>(0, 0)); |
|
|
|
|
Sobel(src_roi, dst, CV_16S, 1, 0, kernelSize, 1, 0, BORDER_REFLECT); |
|
|
|
|
EXPECT_EQ(8, dst.at<short>(0, 0)); |
|
|
|
|
|
|
|
|
|
// should work like BORDER_ISOLATED
|
|
|
|
|
Sobel(src_roi, dst, CV_16S, 1, 0, kernelSize, 1, 0, BORDER_REPLICATE | BORDER_ISOLATED); |
|
|
|
|
EXPECT_EQ(0, dst.at<short>(0, 0)); |
|
|
|
|
Sobel(src_roi, dst, CV_16S, 1, 0, kernelSize, 1, 0, BORDER_REFLECT | BORDER_ISOLATED); |
|
|
|
|
EXPECT_EQ(0, dst.at<short>(0, 0)); |
|
|
|
|
|
|
|
|
|
/// ksize <= src_roi.size()
|
|
|
|
|
src = Mat(5, 5, CV_8UC1, cv::Scalar(5)); |
|
|
|
|
src_roi = src(Rect(1, 1, 3, 3)); |
|
|
|
|
src_roi.setTo(0); |
|
|
|
|
|
|
|
|
|
// should work like !BORDER_ISOLATED, so the function MUST read values in full matrix
|
|
|
|
|
expected_dst = |
|
|
|
|
(Mat_<short>(3, 3) << -15, 0, 15, -20, 0, 20, -15, 0, 15); |
|
|
|
|
Sobel(src_roi, dst, CV_16S, 1, 0, kernelSize, 1, 0, BORDER_REPLICATE); |
|
|
|
|
EXPECT_EQ(expected_dst.type(), dst.type()); |
|
|
|
|
EXPECT_EQ(expected_dst.size(), dst.size()); |
|
|
|
|
EXPECT_DOUBLE_EQ(0.0, cvtest::norm(expected_dst, dst, NORM_INF)); |
|
|
|
|
Sobel(src_roi, dst, CV_16S, 1, 0, kernelSize, 1, 0, BORDER_REFLECT); |
|
|
|
|
EXPECT_EQ(expected_dst.type(), dst.type()); |
|
|
|
|
EXPECT_EQ(expected_dst.size(), dst.size()); |
|
|
|
|
EXPECT_DOUBLE_EQ(0.0, cvtest::norm(expected_dst, dst, NORM_INF)); |
|
|
|
|
|
|
|
|
|
// should work like !BORDER_ISOLATED, so the function MUST read values in full matrix
|
|
|
|
|
expected_dst = Mat::zeros(3, 3, CV_16SC1); |
|
|
|
|
Sobel(src_roi, dst, CV_16S, 1, 0, kernelSize, 1, 0, BORDER_REPLICATE | BORDER_ISOLATED); |
|
|
|
|
EXPECT_EQ(expected_dst.type(), dst.type()); |
|
|
|
|
EXPECT_EQ(expected_dst.size(), dst.size()); |
|
|
|
|
EXPECT_DOUBLE_EQ(0.0, cvtest::norm(expected_dst, dst, NORM_INF)); |
|
|
|
|
Sobel(src_roi, dst, CV_16S, 1, 0, kernelSize, 1, 0, BORDER_REFLECT | BORDER_ISOLATED); |
|
|
|
|
EXPECT_EQ(expected_dst.type(), dst.type()); |
|
|
|
|
EXPECT_EQ(expected_dst.size(), dst.size()); |
|
|
|
|
EXPECT_DOUBLE_EQ(0.0, cvtest::norm(expected_dst, dst, NORM_INF)); |
|
|
|
|
} |
|
|
|
|