• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List

attribute_filter.cc

00001 // Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
00002 //
00003 // This file is part of Olena.
00004 //
00005 // Olena is free software: you can redistribute it and/or modify it under
00006 // the terms of the GNU General Public License as published by the Free
00007 // Software Foundation, version 2 of the License.
00008 //
00009 // Olena is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Olena.  If not, see <http://www.gnu.org/licenses/>.
00016 //
00017 // As a special exception, you may use this file as part of a free
00018 // software project without restriction.  Specifically, if other files
00019 // instantiate templates or use macros or inline functions from this
00020 // file, or you compile this file and link it with other files to produce
00021 // an executable, this file does not by itself cause the resulting
00022 // executable to be covered by the GNU General Public License.  This
00023 // exception does not however invalidate any other reasons why the
00024 // executable file might be covered by the GNU General Public License.
00025 
00026 #include <mln/core/image/image2d.hh>
00027 #include <mln/io/pgm/all.hh>
00028 #include <mln/util/timer.hh>
00029 #include <mln/core/alias/neighb2d.hh>
00030 #include <mln/morpho/attribute/volume.hh>
00031 #include <mln/morpho/attribute/card.hh>
00032 #include <mln/morpho/leveling_filter.hh>
00033 #include <mln/morpho/algebraic_filter.hh>
00034 
00035 #include "tests/data.hh"
00036 
00037 int main(int argc, char** argv)
00038 {
00039   using namespace mln;
00040   using value::int_u8;
00041 
00042   if (argc != 2)
00043     {
00044       std::cout << "Usage: ./connected_filter lambda" << std::endl;
00045       return 0;
00046     }
00047 
00048   typedef mln::image2d<int_u8> I;
00049   I lena;
00050 
00051   float elapsed;
00052   mln::util::timer chrono;
00053   mln::morpho::attribute::volume<I> c;
00054   mln::morpho::attribute::card<I> c2;
00055   int lambda = atoi(argv[1]);
00056 
00057   mln::io::pgm::load(lena, MLN_IMG_DIR "/lena.pgm");
00058   I out;
00059 
00060   std::cout << "Test with card attribute:" << std::endl;
00061   chrono.start();
00062   out = mln::canvas::morpho::attribute_filter(lena, c4(), c2, lambda, true);
00063   elapsed = chrono.stop();
00064   std::cout << "(Full auto) " << elapsed << "s" << std::endl;
00065   mln::io::pgm::save(out, "alg_auto.pgm");
00066 
00067   chrono.start();
00068   out = mln::morpho::algebraic_filter(lena, c4(), c2, lambda, true);
00069   elapsed = chrono.stop();
00070   std::cout << "(Algebraic Auto) " << elapsed << "s" << std::endl;
00071   mln::io::pgm::save(out, "alg_algebraic.pgm");
00072 
00073   chrono.start();
00074   out = mln::canvas::morpho::internal::attribute_filter_dispatch(metal::false_(), lena, c4(), c2, lambda, true);
00075   elapsed = chrono.stop();
00076   std::cout << "(Force Slow) " << elapsed << "s" << std::endl;
00077   mln::io::pgm::save(out, "alg_slow.pgm");
00078 
00079   // Try force algebraic dispatch with wrong accu (volume).
00080   // mln::morpho::algebraic_filter(lena, c4(), c, lambda, true);
00081 
00082   std::cout << "Test with volume attribute:" << std::endl;
00083   chrono.start();
00084   out = mln::canvas::morpho::attribute_filter(lena, c4(), c, lambda, true);
00085   elapsed = chrono.stop();
00086   std::cout << "(Full auto) " << elapsed << "s" << std::endl;
00087   mln::io::pgm::save(out, "lev_auto.pgm");
00088 
00089   chrono.start();
00090   out = mln::morpho::leveling_filter(lena, c4(), c, lambda, true);
00091   elapsed = chrono.stop();
00092   std::cout << "(Leveling Auto) " << elapsed << "s" << std::endl;
00093   mln::io::pgm::save(out, "lev_leveling.pgm");
00094 
00095   chrono.start();
00096   out = mln::canvas::morpho::internal::attribute_filter_dispatch(metal::false_(), lena, c4(), c, lambda, true);
00097   elapsed = chrono.stop();
00098   std::cout << "(Force Slow) " << elapsed << "s" << std::endl;
00099   mln::io::pgm::save(out, "lev_slow.pgm");
00100 
00101   // Try force leveling dispatch with wrong accu (card).
00102   // mln::morpho::leveling_filter(lena, c4(), c2, lambda, true);
00103 
00104 
00105 }

Generated on Tue Oct 4 2011 15:23:25 for Milena (Olena) by  doxygen 1.7.1