geodesic_erosion.hh

00001 // Copyright (C) 2001, 2002, 2003, 2004, 2006 EPITA Research and
00002 // Development Laboratory
00003 //
00004 // This file is part of the Olena Library.  This library is free
00005 // software; you can redistribute it and/or modify it under the terms
00006 // of the GNU General Public License version 2 as published by the
00007 // Free Software Foundation.
00008 //
00009 // This library 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 this library; see the file COPYING.  If not, write to
00016 // the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017 // Boston, MA 02110-1301, USA.
00018 //
00019 // As a special exception, you may use this file as part of a free
00020 // software library without restriction.  Specifically, if other files
00021 // instantiate templates or use macros or inline functions from this
00022 // file, or you compile this file and link it with other files to
00023 // produce an executable, this file does not by itself cause the
00024 // resulting executable to be covered by the GNU General Public
00025 // License.  This exception does not however invalidate any other
00026 // reasons why the executable file might be covered by the GNU General
00027 // Public License.
00028 
00029 #ifndef OLENA_MORPHO_GEODESIC_EROSION_HH
00030 # define OLENA_MORPHO_GEODESIC_EROSION_HH
00031 
00032 # include <oln/basics.hh>
00033 # include <oln/morpho/stat.hh>
00034 # include <oln/morpho/erosion.hh>
00035 # include <oln/convert/conversion_ng_se.hh>
00036 # include <oln/level/compare.hh>
00037 # include <oln/arith/ops.hh>
00038 # include <mlc/cmp.hh>
00039 
00040 namespace oln {
00041   namespace morpho {
00042 
00086     template<class I1, class I2, class N>
00087     oln_concrete_type(I1)
00088       geodesic_erosion(const abstract::non_vectorial_image<I1> & marker,
00089                        const abstract::non_vectorial_image<I2> & mask,
00090                        const abstract::neighborhood<N>& Ng)
00091     {
00092       mlc::eq<I1::dim, I2::dim>::ensure();
00093       mlc::eq<I1::dim, N::dim>::ensure();
00094       precondition(marker.size() == mask.size());
00095       precondition(level::is_greater_or_equal(marker, mask));
00096       return arith::max_with_ret<oln_concrete_type(I1)>
00097         (erosion(marker, convert::ng_to_cse(Ng)),
00098          mask);
00099     }
00100 
00101     namespace sure {
00149       template<class I1, class I2, class N>
00150       oln_concrete_type(I1)
00151         geodesic_erosion(const abstract::non_vectorial_image<I1> & marker,
00152                          const abstract::non_vectorial_image<I2> & mask,
00153                          const abstract::neighborhood<N>& Ng)
00154       {
00155         mlc::eq<I1::dim, I2::dim>::ensure();
00156         mlc::eq<I1::dim, N::dim>::ensure();
00157         precondition(marker.size() == mask.size());
00158         precondition(level::is_greater_or_equal(marker, mask));
00159 
00160         oln_concrete_type(I1) output(marker.size());
00161         marker.border_adapt_copy(Ng.delta());
00162         oln_iter_type(I1) p(marker);
00163         for_all (p)
00164           output[p] = ntg::max(morpho::min(marker, p, convert::ng_to_cse(Ng)), mask[p]);
00165         return output;
00166       }
00167 
00168     }// sure
00169   } // morpho
00170 } // oln
00171 
00172 #endif // OLENA_MORPHO_GEODESIC_EROSION_HH

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