MCPcopy Create free account
hub / github.com/davisking/dlib / test_gaussian_blur

Function test_gaussian_blur

dlib/test/image.cpp:945–974  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers

nothing calls this directly

Calls 10

assign_all_pixelsFunction · 0.85
gaussian_blurFunction · 0.85
get_rectFunction · 0.85
absFunction · 0.85
shrink_rectFunction · 0.50
have_same_dimensionsFunction · 0.50
pointClass · 0.50
nrMethod · 0.45
ncMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected