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 #include <oln/lrde/efigi/io.hh>
00036
00037
00038 void usage(char* argv[])
00039 {
00040 std::cerr << "generic max-tree computation with salembier's flooding"
00041 << " (float version)." << std::endl
00042 << "usage: " << argv[0] << " input.pfm c" << std::endl;
00043 exit(1);
00044 }
00045
00046
00047 int main(int argc, char* argv[])
00048 {
00049 if (argc != 3)
00050 usage(argv);
00051
00052 using namespace oln;
00053 typedef image2d<float> image_t;
00054
00055 image_t input = efigi::load_pfm(argv[1]);
00056 assert (input.has_impl());
00057
00058 int c = atoi(argv[2]);
00059 if (not (c == 2 or c == 4 or c == 8))
00060 usage(argv);
00061
00062 neighborhood2d nbh;
00063 if (c == 2)
00064 nbh.add(dpoint2d(0, 1));
00065 else
00066 nbh = c == 4 ? neighb_c4() : neighb_c8();
00067
00068 typedef lrde::ufmt::generic_salembier<image_t> algorithm_t;
00069
00070 algorithm_t run(input, nbh);
00071 utils::timer t;
00072 t.start();
00073 run.go();
00074 t.stop();
00075 std::cout << "n level roots = " << run.n_level_roots() << std::endl
00076 << "elapsed time = " << t.last_time() << std::endl;
00077 }