| 1113 | |
| 1114 | template <typename T> |
| 1115 | void test_filtering(bool use_abs, unsigned long scale ) |
| 1116 | { |
| 1117 | print_spinner(); |
| 1118 | dlog << LINFO << "test_filtering(" << use_abs << "," << scale << ")"; |
| 1119 | array2d<T> img, img2, img3; |
| 1120 | img.set_size(10,11); |
| 1121 | |
| 1122 | assign_all_pixels(img, 10); |
| 1123 | |
| 1124 | matrix<int,3,5> filter2; |
| 1125 | filter2 = 1,1,1,1,1, |
| 1126 | 1,1,1,1,1, |
| 1127 | 1,1,1,1,1; |
| 1128 | |
| 1129 | assign_all_pixels(img2,3); |
| 1130 | rectangle brect = spatially_filter_image(img, img2, filter2); |
| 1131 | DLIB_TEST(brect == shrink_rect(get_rect(img), filter2.nc()/2, filter2.nr()/2)); |
| 1132 | |
| 1133 | const rectangle rect(2,1,img.nc()-3,img.nr()-2); |
| 1134 | |
| 1135 | for (long r = 0; r<img2.nr(); ++r) |
| 1136 | { |
| 1137 | for (long c = 0; c<img2.nc(); ++c) |
| 1138 | { |
| 1139 | if (rect.contains(c,r)) |
| 1140 | { |
| 1141 | DLIB_TEST_MSG(img2[r][c] == 150, (int)img2[r][c]); |
| 1142 | } |
| 1143 | else |
| 1144 | { |
| 1145 | DLIB_TEST_MSG(img2[r][c] == 0,(int)img2[r][c]); |
| 1146 | } |
| 1147 | } |
| 1148 | } |
| 1149 | |
| 1150 | |
| 1151 | assign_all_pixels(img2,3); |
| 1152 | assign_all_pixels(img3,3); |
| 1153 | brect = spatially_filter_image(img, img2, filter2); |
| 1154 | DLIB_TEST(brect == shrink_rect(get_rect(img), filter2.nc()/2, filter2.nr()/2)); |
| 1155 | |
| 1156 | matrix<int,1,5> row_filter; |
| 1157 | matrix<int,1,3> col_filter; |
| 1158 | |
| 1159 | row_filter = 1,1,1,1,1; |
| 1160 | col_filter = 1,1,1; |
| 1161 | |
| 1162 | spatially_filter_image_separable(img, img3, row_filter, col_filter); |
| 1163 | |
| 1164 | DLIB_TEST(mat(img2) == mat(img3)); |
| 1165 | |
| 1166 | |
| 1167 | dlib::rand rnd; |
| 1168 | |
| 1169 | for (int i = 0; i < 30; ++i) |
| 1170 | { |
| 1171 | for (long r = 0; r < img.nr(); ++r) |
| 1172 | { |
nothing calls this directly
no test coverage detected