00001
00002 #include <cstdlib>
00003
00004 #include <ntg/int.hh>
00005 #include <oln/basics2d.hh>
00006 #include <oln/utils/timer.hh>
00007 #include <oln/lrde/ufmt/basic_salembier.hh>
00008
00009
00010
00011 void usage(char* argv[])
00012 {
00013 std::cerr << "usage: " << argv[0] << " input.pgm c" << std::endl;
00014 std::cerr << "basic max-tree computation with salembier's flooding"
00015 << std::endl;
00016
00017 exit(1);
00018 }
00019
00020
00021 int main(int argc, char* argv[])
00022 {
00023 if (argc != 3)
00024 usage(argv);
00025
00026 using namespace oln;
00027 typedef image2d<ntg::int_u8> image_t;
00028
00029 image_t input = load(argv[1]);
00030 assert (input.has_impl());
00031
00032 int c = atoi(argv[2]);
00033 if (not (c == 2 or c == 4 or c == 8))
00034 usage(argv);
00035
00036 typedef lrde::ufmt::basic_salembier<image_t> algorithm_t;
00037
00038 neighborhood2d nbh;
00039 if (c == 2)
00040 nbh.add(dpoint2d(0, 1));
00041 else
00042 nbh = c == 4 ? neighb_c4() : neighb_c8();
00043
00044 algorithm_t run(input, nbh);
00045 utils::timer t;
00046 t.start();
00047 run.go();
00048 t.stop();
00049 std::cout << "n level roots = " << run.n_level_roots() << std::endl
00050 << "elapsed time = " << t.last_time() << std::endl;
00051 }