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