Skip to content

Commit 8e0173e

Browse files
authored
Update test_thinning.cpp
1 parent 80f1ca2 commit 8e0173e

File tree

1 file changed

+12
-38
lines changed

1 file changed

+12
-38
lines changed

modules/ximgproc/test/test_thinning.cpp

Lines changed: 12 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,52 +6,26 @@
66

77
namespace opencv_test { namespace {
88

9-
static int createTestImage(Mat1b& src)
10-
{
11-
src = Mat1b::zeros(Size(256, 256));
12-
// Create a corner point that should not be affected.
13-
src(0, 0) = 255;
14-
15-
for (int x = 50; x < src.cols - 50; x += 50)
16-
{
17-
cv::circle(src, Point(x, x/2), 30 + x/2, Scalar(255), 5);
18-
}
19-
int src_pixels = countNonZero(src);
20-
EXPECT_GT(src_pixels, 0);
21-
return src_pixels;
22-
}
23-
249
TEST(ximgproc_Thinning, simple_ZHANGSUEN)
2510
{
26-
Mat1b src;
27-
int src_pixels = createTestImage(src);
11+
string dir = cvtest::TS::ptr()->get_data_path();
12+
Mat src = imread(dir + "cv/ximgproc/sources/08.png", IMREAD_GRAYSCALE);
13+
Mat dst;
14+
thinning(~src, dst, THINNING_ZHANGSUEN);
2815

29-
Mat1b dst;
30-
thinning(src, dst, THINNING_ZHANGSUEN);
31-
int dst_pixels = countNonZero(dst);
32-
EXPECT_LE(dst_pixels, src_pixels);
33-
EXPECT_EQ(dst(0, 0), 255);
34-
35-
#if 0
36-
imshow("src", src); imshow("dst", dst); waitKey();
37-
#endif
16+
src = imread(dir + "cv/ximgproc/results/Thinning_ZHANGSUEN.png", IMREAD_GRAYSCALE);
17+
EXPECT_EQ(0, cvtest::norm(src, dst, NORM_INF));
3818
}
3919

4020
TEST(ximgproc_Thinning, simple_GUOHALL)
4121
{
42-
Mat1b src;
43-
int src_pixels = createTestImage(src);
44-
45-
Mat1b dst;
46-
thinning(src, dst, THINNING_GUOHALL);
47-
int dst_pixels = countNonZero(dst);
48-
EXPECT_LE(dst_pixels, src_pixels);
49-
EXPECT_EQ(dst(0, 0), 255);
22+
string dir = cvtest::TS::ptr()->get_data_path();
23+
Mat src = imread(dir + "cv/ximgproc/sources/08.png", IMREAD_GRAYSCALE);
24+
Mat dst;
25+
thinning(~src, dst, THINNING_GUOHALL);
5026

51-
#if 0
52-
imshow("src", src); imshow("dst", dst); waitKey();
53-
#endif
27+
src = imread(dir + "cv/ximgproc/results/Thinning_GUOHALL.png", IMREAD_GRAYSCALE);
28+
EXPECT_EQ(0, cvtest::norm(src, dst, NORM_INF));
5429
}
5530

56-
5731
}} // namespace

0 commit comments

Comments
 (0)