00001
00002 #include <cstdlib>
00003
00004 #include <ntg/int.hh>
00005 #include <oln/basics2d.hh>
00006 #include <oln/lrde/ufmt/sp_maxtree.hh>
00007 #include <oln/lrde/ufmt/log.hh>
00008 #include <oln/lrde/ufmt/utils.hh>
00009
00010
00011
00012 void usage(char* argv[])
00013 {
00014 std::cerr << "usage: " << argv[0] << " input.pgm c" << std::endl;
00015 std::cerr << "max-tree computation with union-find:" << std::endl;
00016 std::cerr << " s. sorting for high or no- quant (loop is 'for p')" << std::endl;
00017 std::cerr << " p. image<point>" << std::endl;
00018 std::cerr << " . no level compression!!!" << std::endl;
00019 exit(1);
00020 }
00021
00022
00023 int main(int argc, char* argv[])
00024 {
00025 if (argc != 3)
00026 usage(argv);
00027
00028 using namespace oln;
00029 typedef image2d<ntg::int_u8> image_t;
00030
00031 image_t raw_input = load(argv[1]);
00032 image2d<float> input = lrde::ufmt::to_float_with_noise(raw_input);
00033
00034 int c = atoi(argv[2]);
00035 if (not (c == 4 or c == 8))
00036 usage(argv);
00037
00038 typedef lrde::ufmt::sp_maxtree< image2d<float> > algorithm_t;
00039
00040 algorithm_t run(input,
00041 c == 4 ? neighb_c4() : neighb_c8());
00042 run.go<void>();
00043
00044
00045
00046
00047 std::cout << "n level roots = " << n_level_roots(run) << std::endl;
00048 }