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

crest.hh

00001 // Copyright (C) 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 #ifndef MLN_TOPO_SKELETON_CREST_HH
00027 # define MLN_TOPO_SKELETON_CREST_HH
00028 
00032 
00033 # include <mln/core/concept/image.hh>
00034 # include <mln/core/concept/neighborhood.hh>
00035 # include <mln/data/fill.hh>
00036 
00037 
00038 namespace mln
00039 {
00040 
00041   namespace topo
00042   {
00043 
00044     namespace skeleton
00045     {
00046 
00047 
00056       //
00086       template <typename I, typename D, typename N>
00087       mln_concrete(I)
00088       crest(const Image<I>& input_, const Image<D>& dist_map_,
00089             const Neighborhood<N>& nbh_);
00090 
00091 
00092 
00093 # ifndef MLN_INCLUDE_ONLY
00094 
00095 
00096       template <typename I, typename D, typename N>
00097       mln_concrete(I)
00098       crest(const Image<I>& input_, const Image<D>& dist_map_,
00099             const Neighborhood<N>& nbh_)
00100       {
00101         trace::entering("topo::skeleton::crest");
00102         const I& input = exact(input_);
00103         const D& dist_map = exact(dist_map_);
00104         const N& nbh = exact(nbh_);
00105 
00106         mlc_equal(mln_value(I), bool)::check();
00107         mln_precondition(input.is_valid());
00108         mln_precondition(dist_map.is_valid());
00109         mln_precondition(nbh.is_valid());
00110 
00111         mln_concrete(I) is_crest;
00112         initialize(is_crest, input);
00113         data::fill(is_crest, false);
00114 
00115         mln_piter(I) p(input.domain());
00116         mln_niter(N) n(nbh, p);
00117         for_all(p)
00118         {
00119           if (!input(p) || dist_map(p) < static_cast<mln_value(D)>(0))
00120             continue;
00121 
00122           unsigned nb_eq = 0;
00123           unsigned nb_gt = 0;
00124           unsigned nb_lt = 0;
00125           for_all(n)
00126             if (input.domain().has(n))
00127             {
00128               if (dist_map(n) == dist_map(p))
00129                 ++nb_eq;
00130               else if (dist_map(n) > dist_map(p))
00131                 ++nb_gt;
00132               else
00133                 ++nb_lt;
00134             }
00135 
00136           if ((nb_lt + nb_eq) > 5) // Pixel Superiority index
00137             is_crest(p) = true;
00138         }
00139 
00140         trace::exiting("topo::skeleton::crest");
00141         return is_crest;
00142       }
00143 
00144 
00145 # endif // ! MLN_INCLUDE_ONLY
00146 
00147 
00148     } // end of namespace mln::topo::skeleton
00149 
00150   } // end of namespace mln::topo
00151 
00152 } // end of namespace mln
00153 
00154 #endif // ! MLN_TOPO_SKELETON_CREST_HH

Generated on Thu Sep 8 2011 18:31:44 for Milena (Olena) by  doxygen 1.7.1