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

Function test_interpolate_bilinear

dlib/test/image.cpp:2446–2518  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2444 }
2445
2446 void test_interpolate_bilinear()
2447 {
2448 {
2449 matrix<unsigned char> img_s(2, 2);
2450
2451 img_s(0, 0) = 0;
2452 img_s(0, 1) = 100;
2453 img_s(1, 0) = 100;
2454 img_s(1, 1) = 100;
2455
2456 const_image_view<matrix<unsigned char>> imgv(img_s);
2457
2458 unsigned char result;
2459 {
2460 interpolate_bilinear()(imgv, dlib::vector<double, 2>{ 0.5, 0.0 }, result);
2461 DLIB_TEST(result == 50);
2462 }
2463 {
2464 interpolate_bilinear()(imgv, dlib::vector<double, 2>{ 0.5, 0.5 }, result);
2465 DLIB_TEST(result == 75);
2466 }
2467 }
2468
2469 {
2470 matrix<rgb_pixel> img_s(2, 2);
2471
2472 img_s(0, 0) = { 0, 0, 0 };
2473 img_s(0, 1) = { 10, 20, 30 };
2474 img_s(1, 0) = { 10, 20, 30 };
2475 img_s(1, 1) = { 10, 20, 30 };
2476
2477 const_image_view<matrix<rgb_pixel>> imgv(img_s);
2478
2479 rgb_pixel result;
2480 {
2481 interpolate_bilinear()(imgv, dlib::vector<double, 2>{ 0.5, 0.0 }, result);
2482 DLIB_TEST(result.red == 5);
2483 DLIB_TEST(result.green == 10);
2484 DLIB_TEST(result.blue == 15);
2485 }
2486 {
2487 interpolate_bilinear()(imgv, dlib::vector<double, 2>{ 0.5, 0.5 }, result);
2488 DLIB_TEST(result.red == 7);
2489 DLIB_TEST(result.green == 15);
2490 DLIB_TEST(result.blue == 22);
2491 }
2492 }
2493
2494 {
2495 matrix<lab_pixel> img_s(2, 2);
2496
2497 img_s(0, 0) = { 0, 0, 0 };
2498 img_s(0, 1) = { 100, 20, 30 };
2499 img_s(1, 0) = { 100, 20, 30 };
2500 img_s(1, 1) = { 100, 20, 30 };
2501
2502 const_image_view<matrix<lab_pixel>> imgv(img_s);
2503

Callers 1

perform_testMethod · 0.85

Calls 1

Tested by

no test coverage detected