From de23eed3c3cfe6f1cae3b18b209e41732bd65d82 Mon Sep 17 00:00:00 2001 From: Davis King Date: Tue, 5 Nov 2013 19:53:55 -0500 Subject: [PATCH] Added more filtering unit tests --- dlib/test/image.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/dlib/test/image.cpp b/dlib/test/image.cpp index c9fe4a05a..cb2dffbdb 100644 --- a/dlib/test/image.cpp +++ b/dlib/test/image.cpp @@ -1091,6 +1091,48 @@ namespace } } + void test_small_filter() + { + array2d img(3,3), out; + assign_all_pixels(img, 1); + matrix filt(2,2); + filt = 1; + + spatially_filter_image(img, out, filt); + + DLIB_TEST(out[0][0] == 4); + DLIB_TEST(out[0][1] == 4); + DLIB_TEST(out[0][2] == 0); + + DLIB_TEST(out[1][0] == 4); + DLIB_TEST(out[1][1] == 4); + DLIB_TEST(out[1][2] == 0); + + DLIB_TEST(out[2][0] == 0); + DLIB_TEST(out[2][1] == 0); + DLIB_TEST(out[2][2] == 0); + + matrix rfilt(2,1), cfilt(2,1); + rfilt = 1; + cfilt = 1; + + assign_all_pixels(out, 9); + spatially_filter_image_separable(img, out, rfilt, cfilt); + + DLIB_TEST(out[0][0] == 4); + DLIB_TEST(out[0][1] == 4); + DLIB_TEST(out[0][2] == 0); + + DLIB_TEST(out[1][0] == 4); + DLIB_TEST(out[1][1] == 4); + DLIB_TEST(out[1][2] == 0); + + DLIB_TEST(out[2][0] == 0); + DLIB_TEST(out[2][1] == 0); + DLIB_TEST(out[2][2] == 0); + + } + void test_zero_border_pixels( ) { @@ -1586,6 +1628,7 @@ namespace void perform_test ( ) { + test_small_filter(); image_test(); test_integral_image(); test_integral_image(); @@ -1634,6 +1677,7 @@ namespace test_filtering2(7,7,rnd); test_filtering2(7,5,rnd); } + } } a;