| 943 | |
| 944 | template <typename T> |
| 945 | void test_gaussian_blur() |
| 946 | { |
| 947 | array2d<T> img(9,11), blurred; |
| 948 | assign_all_pixels(img, 100); |
| 949 | const double sigmas[] = {1, 0.3575067961838845, 0.357506796183885, 18}; |
| 950 | const int max_sizes[] = {1001, 3, 3, 5}; |
| 951 | const int borders[] = {2, 0, 1, 2}; |
| 952 | for (unsigned long i = 0; i < 4; ++i) |
| 953 | { |
| 954 | const rectangle rect = gaussian_blur(img, blurred, sigmas[i], max_sizes[i]); |
| 955 | DLIB_TEST(rect == shrink_rect(get_rect(img), borders[i])); |
| 956 | DLIB_TEST(have_same_dimensions(img, blurred)); |
| 957 | for (long r = 0; r < img.nr(); ++r) |
| 958 | { |
| 959 | for (long c = 0; c < img.nc(); ++c) |
| 960 | { |
| 961 | if (rect.contains(point(c,r))) |
| 962 | { |
| 963 | // Integer output may truncate a floating-point result at sigma=18. |
| 964 | const double tolerance = is_float_type<T>::value ? 1e-4 : 1; |
| 965 | DLIB_TEST(std::abs(static_cast<double>(blurred[r][c])-100) <= tolerance); |
| 966 | } |
| 967 | else |
| 968 | { |
| 969 | DLIB_TEST(blurred[r][c] == 0); |
| 970 | } |
| 971 | } |
| 972 | } |
| 973 | } |
| 974 | } |
| 975 | |
| 976 | void test_gaussian_filter() |
| 977 | { |
nothing calls this directly
no test coverage detected