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