|
6 | 6 |
|
7 | 7 | namespace opencv_test { namespace {
|
8 | 8 |
|
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 |
| - |
24 | 9 | TEST(ximgproc_Thinning, simple_ZHANGSUEN)
|
25 | 10 | {
|
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); |
28 | 15 |
|
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)); |
38 | 18 | }
|
39 | 19 |
|
40 | 20 | TEST(ximgproc_Thinning, simple_GUOHALL)
|
41 | 21 | {
|
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); |
50 | 26 |
|
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)); |
54 | 29 | }
|
55 | 30 |
|
56 |
| - |
57 | 31 | }} // namespace
|
0 commit comments