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

Function test_integral_image

dlib/test/image.cpp:898–942  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

896
897 template <typename T, typename pixel_type>
898 void test_integral_image (
899 )
900 {
901 dlib::rand rnd;
902
903 array2d<pixel_type> img;
904 integral_image_generic<T> int_img;
905
906 int_img.load(img);
907 DLIB_TEST(int_img.nr() == 0);
908 DLIB_TEST(int_img.nc() == 0);
909
910 // make 5 random images
911 for (int i = 0; i < 5; ++i)
912 {
913 print_spinner();
914 img.set_size(rnd.get_random_16bit_number()%200+1, rnd.get_random_16bit_number()%200+1);
915
916 for (long r = 0; r < img.nr(); ++r)
917 {
918 for (long c = 0; c < img.nc(); ++c)
919 {
920 img[r][c] = (int)rnd.get_random_8bit_number() - 100;
921 }
922 }
923
924 int_img.load(img);
925 DLIB_TEST(int_img.nr() == img.nr());
926 DLIB_TEST(int_img.nc() == img.nc());
927
928 // make 200 random rectangles
929 for (int j = 0; j < 500; ++j)
930 {
931 point p1(rnd.get_random_32bit_number()%img.nc(), rnd.get_random_32bit_number()%img.nr());
932 point p2(rnd.get_random_32bit_number()%img.nc(), rnd.get_random_32bit_number()%img.nr());
933 rectangle rect(p1,p2);
934 DLIB_TEST(int_img.get_sum_of_area(rect) == sum(subm(matrix_cast<T>(mat(img)), rect)));
935 rect = rectangle(p1,p1);
936 DLIB_TEST(int_img.get_sum_of_area(rect) == sum(subm(matrix_cast<T>(mat(img)), rect)));
937 }
938
939 }
940
941
942 }
943
944 template <typename T>
945 void test_gaussian_blur()

Callers

nothing calls this directly

Calls 13

print_spinnerFunction · 0.85
submFunction · 0.85
get_sum_of_areaMethod · 0.80
sumFunction · 0.50
matFunction · 0.50
rectangleClass · 0.50
loadMethod · 0.45
nrMethod · 0.45
ncMethod · 0.45

Tested by

no test coverage detected