generic_salembier_float.cc

00001 // Copyright (C) 2006  EPITA Research and Development Laboratory
00002 //
00003 // This file is part of the Olena Library.  This library is free
00004 // software; you can redistribute it and/or modify it under the terms
00005 // of the GNU General Public License version 2 as published by the
00006 // Free Software Foundation.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU General Public License
00014 // along with this library; see the file COPYING.  If not, write to
00015 // the Free Software Foundation, 51 Franklin Street, Fifth Floor,
00016 // Boston, Boston, MA 02110-1301, USA.
00017 //
00018 // As a special exception, you may use this file as part of a free
00019 // software library without restriction.  Specifically, if other files
00020 // instantiate templates or use macros or inline functions from this
00021 // file, or you compile this file and link it with other files to
00022 // produce an executable, this file does not by itself cause the
00023 // resulting executable to be covered by the GNU General Public
00024 // License.  This exception does not however invalidate any other
00025 // reasons why the executable file might be covered by the GNU General
00026 // Public License.
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 }

Generated on Tue Feb 20 20:19:43 2007 for Olena by  doxygen 1.5.1