1 // This is core/vil/algo/tests/test_suppress_non_max.cxx
2 #include <iostream>
3 #include "testlib/testlib_test.h"
4 #ifdef _MSC_VER
5 # include "vcl_msvc_warnings.h"
6 #endif
7 #include <vil/algo/vil_suppress_non_max.h>
8
9 static void
test_suppress_non_max_byte()10 test_suppress_non_max_byte()
11 {
12 std::cout << "******************************\n"
13 << " Testing vil_suppress_non_max\n"
14 << "******************************\n";
15
16 vil_image_view<vxl_byte> image0, dest_im;
17 image0.set_size(10, 10);
18 image0.fill(5);
19
20 image0(3, 7) = 18; // One peak
21 image0(7, 5) = 19; // Another peak
22
23 image0(4, 3) = 20; // Another peak at a plateau
24 image0(4, 4) = 20; // Another peak at a plateau
25
26 vil_suppress_non_max_3x3(image0, dest_im, vxl_byte(3));
27 TEST("Peak at (3,7)", dest_im(3, 7), 18);
28 TEST("Peak at (7,5)", dest_im(7, 5), 19);
29 TEST("Flat Peak at (4,4) removed (sadly)", dest_im(4, 4), 0);
30
31 TEST("No peak at 2,2", dest_im(2, 2), 0);
32 TEST("No peak at 0,1", dest_im(3, 3), 0);
33 }
34
35 static void
test_suppress_non_max()36 test_suppress_non_max()
37 {
38 test_suppress_non_max_byte();
39 }
40
41 TESTMAIN(test_suppress_non_max);
42