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