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