| 2268 | |
| 2269 | template<typename interpolation_type = interpolate_bilinear> |
| 2270 | void test_resize_image_with_interpolation() |
| 2271 | { |
| 2272 | { |
| 2273 | matrix<unsigned char> img_s(2, 2); |
| 2274 | matrix<unsigned char> img_d(3, 3); |
| 2275 | |
| 2276 | img_s(0, 0) = 0; |
| 2277 | img_s(0, 1) = 100; |
| 2278 | img_s(1, 0) = 100; |
| 2279 | img_s(1, 1) = 100; |
| 2280 | |
| 2281 | resize_image(img_s, img_d, interpolation_type()); |
| 2282 | DLIB_TEST((img_d(0, 0) == 0)); |
| 2283 | DLIB_TEST((img_d(0, 1) == 50)); |
| 2284 | DLIB_TEST((img_d(1, 2) == 100)); |
| 2285 | DLIB_TEST((img_d(2, 2) == 100)); |
| 2286 | } |
| 2287 | |
| 2288 | { |
| 2289 | matrix<rgb_pixel> img_s(2, 2); |
| 2290 | matrix<rgb_pixel> img_d(3, 3); |
| 2291 | |
| 2292 | img_s(0, 0) = { 0, 0, 0 }; |
| 2293 | img_s(0, 1) = { 10, 20, 30 }; |
| 2294 | img_s(1, 0) = { 10, 20, 30 }; |
| 2295 | img_s(1, 1) = { 10, 20, 30 }; |
| 2296 | |
| 2297 | resize_image(img_s, img_d, interpolation_type()); |
| 2298 | DLIB_TEST((img_d(0, 0) == rgb_pixel{ 0, 0, 0 })); |
| 2299 | DLIB_TEST((img_d(0, 1) == rgb_pixel{ 5, 10, 15 })); |
| 2300 | DLIB_TEST((img_d(1, 2) == rgb_pixel{ 10, 20, 30 })); |
| 2301 | DLIB_TEST((img_d(2, 2) == rgb_pixel{ 10, 20, 30 })); |
| 2302 | } |
| 2303 | |
| 2304 | { |
| 2305 | matrix<lab_pixel> img_s(2, 2); |
| 2306 | matrix<lab_pixel> img_d(3, 3); |
| 2307 | |
| 2308 | img_s(0, 0) = { 0, 0, 0 }; |
| 2309 | img_s(0, 1) = { 100, 20, 30 }; |
| 2310 | img_s(1, 0) = { 100, 20, 30 }; |
| 2311 | img_s(1, 1) = { 100, 20, 30 }; |
| 2312 | |
| 2313 | resize_image(img_s, img_d, interpolation_type()); |
| 2314 | DLIB_TEST((img_d(0, 0) == lab_pixel{ 0, 0, 0 })); |
| 2315 | DLIB_TEST((img_d(0, 1) == lab_pixel{ 50, 10, 15 })); |
| 2316 | DLIB_TEST((img_d(1, 2) == lab_pixel{ 100, 20, 30 })); |
| 2317 | DLIB_TEST((img_d(2, 2) == lab_pixel{ 100, 20, 30 })); |
| 2318 | } |
| 2319 | |
| 2320 | } |
| 2321 | |
| 2322 | void test_null_rotate_image_with_interpolation() |
| 2323 | { |
nothing calls this directly
no test coverage detected