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

Function run_test2

dlib/test/max_sum_submatrix.cpp:104–141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102
103 template <typename T>
104 void run_test2()
105 {
106 matrix<T> mat(100,100);
107 mat = 1;
108 std::vector<rectangle> res = max_sum_submatrix(mat, 0, 0);
109
110 DLIB_TEST(res.size() == 0);
111 res = max_sum_submatrix(mat, 1, 0);
112 DLIB_TEST(res.size() == 1);
113 DLIB_TEST(res[0] == get_rect(mat));
114 res = max_sum_submatrix(mat, 3, 0);
115 DLIB_TEST(res.size() == 1);
116 DLIB_TEST(res[0] == get_rect(mat));
117 res = max_sum_submatrix(mat, 3, 10);
118 DLIB_TEST(res.size() == 1);
119 DLIB_TEST(res[0] == get_rect(mat));
120
121 res = max_sum_submatrix(mat, 3, mat.size());
122 DLIB_TEST(res.size() == 0);
123
124 mat = -1;
125 res = max_sum_submatrix(mat, 1, 0);
126 DLIB_TEST(res.size() == 0);
127
128 const rectangle rect1 = rectangle(10,10,40,40);
129 const rectangle rect2 = rectangle(35,35,80,80);
130
131 set_subm(mat, rect1) = 2;
132 set_subm(mat, rect2) = 1;
133 res = max_sum_submatrix(mat, 3, 0);
134 DLIB_TEST(res.size() == 2);
135 DLIB_TEST(res[0] == rect2);
136 DLIB_TEST(res[1] == rect1);
137
138 res = max_sum_submatrix(mat, 3, 2*rect1.area() - 2*(rect1.intersect(rect2)).area());
139 DLIB_TEST(res.size() == 1);
140 DLIB_TEST(res[0] == rect2);
141 }
142
143// ----------------------------------------------------------------------------------------
144

Callers

nothing calls this directly

Calls 7

max_sum_submatrixFunction · 0.85
get_rectFunction · 0.85
set_submFunction · 0.85
rectangleClass · 0.50
sizeMethod · 0.45
areaMethod · 0.45
intersectMethod · 0.45

Tested by

no test coverage detected