Milena (Olena)
User documentation 2.0a Id
|
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 #ifndef MLN_GEOM_SEEDS2TILING_ROUNDNESS_HH 00027 # define MLN_GEOM_SEEDS2TILING_ROUNDNESS_HH 00028 00032 00033 # include <map> 00034 00035 # include <mln/core/concept/image.hh> 00036 # include <mln/core/concept/neighborhood.hh> 00037 # include <mln/core/alias/w_window2d_int.hh> 00038 # include <mln/core/site_set/p_priority.hh> 00039 # include <mln/core/site_set/p_queue_fast.hh> 00040 # include <mln/core/routine/duplicate.hh> 00041 # include <mln/accu/stat/mean.hh> 00042 # include <mln/estim/min_max.hh> 00043 # include <mln/algebra/vec.hh> 00044 # include <mln/geom/chamfer.hh> 00045 00046 00047 namespace mln 00048 { 00049 namespace geom 00050 { 00051 00065 template <typename I, typename N> 00066 I 00067 seeds2tiling_roundness (Image<I>& ima_, const w_window2d_int& w_win, 00068 unsigned max, const Neighborhood<N>& nbh_); 00070 00071 00072 # ifndef MLN_INCLUDE_ONLY 00073 00074 namespace impl 00075 { 00076 00077 template <typename I, typename N> 00078 inline 00079 I 00080 seeds2tiling_roundness(Image<I>& ima_, const w_window2d_int& w_win, 00081 unsigned max, const Neighborhood<N>& nbh_) 00082 { 00083 trace::entering("geom::impl::seed2tiling_roundness"); 00084 00085 I& ima = exact(ima_); 00086 const N& nbh = exact(nbh_); 00087 image2d<unsigned> dist = geom::chamfer(ima, w_win, max); 00088 00089 I out = duplicate(ima_); 00090 p_priority<unsigned, p_queue_fast<mln_psite(I)> > q; 00091 00092 // Init. 00093 { 00094 mln_piter(I) p(ima.domain()); 00095 00096 for_all(p) 00097 q.push(max - dist(p), p); 00098 } 00099 00100 00101 // Body: alternative version. 00102 { 00103 while (! q.is_empty()) 00104 { 00105 mln_psite(I) p = q.pop_front(); 00106 00107 if (out(p) != literal::zero) // p has already been processed so ignore 00108 continue; 00109 mln_niter(N) n(nbh, p); 00110 00111 for_all(n) if (ima.has(n)) 00112 if (out(n) != literal::zero) 00113 out(p) = out(n); 00114 } 00115 } 00116 00117 trace::exiting("geom::impl::seed2tiling_roundness"); 00118 return out; 00119 } 00120 00121 } // end of namespace mln::geom::impl 00122 00123 00124 // Facade 00125 template <typename I, typename N> 00126 inline 00127 I 00128 seeds2tiling_roundness(Image<I>& ima_, const w_window2d_int& w_win, 00129 unsigned max, const Neighborhood<N>& nbh) 00130 { 00131 trace::entering("geom::seed2tiling_roundness"); 00132 00133 mln_precondition(exact(ima_).is_valid()); 00134 I output = impl::seeds2tiling_roundness(ima_, w_win, max, nbh); 00135 00136 trace::exiting("geom::seed2tiling_roundness"); 00137 return output; 00138 } 00139 00140 00141 00142 # endif // ! MLN_INCLUDE_ONLY 00143 00144 } // end of namespace mln::geom 00145 00146 } // end of namespace mln 00147 00148 00149 #endif // ! MLN_GEOM_SEEDS2TILING_ROUNDNESS_HH