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

Function test_integral_image

dlib/test/image.cpp:896–940  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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