Milena (Olena)
User documentation 2.0a Id
|
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_MAKE_P_VERTICES_WITH_MASS_CENTERS_HH 00027 # define MLN_MAKE_P_VERTICES_WITH_MASS_CENTERS_HH 00028 00034 00035 00036 # include <mln/core/concept/image.hh> 00037 # include <mln/core/concept/graph.hh> 00038 # include <mln/core/site_set/p_vertices.hh> 00039 00040 # include <mln/labeling/compute.hh> 00041 00042 # include <mln/accu/center.hh> 00043 00044 # include <mln/fun/i2v/array.hh> 00045 00046 00047 namespace mln 00048 { 00049 00050 namespace make 00051 { 00052 00063 // 00064 template <typename W, typename G> 00065 inline 00066 p_vertices<G, fun::i2v::array<mln_site(W)> > 00067 p_vertices_with_mass_centers(const Image<W>& wst_, 00068 const Graph<G>& g_); 00069 00070 00071 # ifndef MLN_INCLUDE_ONLY 00072 00073 00074 template <typename W, typename G> 00075 inline 00076 p_vertices<G, fun::i2v::array<mln_site(W)> > 00077 p_vertices_with_mass_centers(const Image<W>& wst_, 00078 const Graph<G>& g_) 00079 { 00080 trace::entering("make::p_vertices_with_mass_centers"); 00081 00082 const W& wst = exact(wst_); 00083 const G& g = exact(g_); 00084 mln_precondition(wst.is_valid()); 00085 mln_precondition(g.is_valid()); 00086 00087 typedef mln_site(W) P; 00088 typedef fun::i2v::array<P> vertex_sites_t; 00089 00090 // nbasins does not include the background label. 00091 mln_value(W) nbasins = g.v_nmax() - 1; 00092 vertex_sites_t vertex_sites; 00093 convert::from_to(labeling::compute(accu::center<P>(), wst, nbasins), 00094 vertex_sites); 00095 00096 p_vertices<G, vertex_sites_t> pv(g, vertex_sites); 00097 00098 trace::exiting("make::p_vertices_with_mass_centers"); 00099 return pv; 00100 } 00101 00102 # endif // ! MLN_INCLUDE_ONLY 00103 00104 } // end of namespace mln::make 00105 00106 } // end of namespace mln 00107 00108 #endif // ! MLN_MAKE_P_VERTICES_WITH_MASS_CENTERS_HH