00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
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
00093 {
00094 mln_piter(I) p(ima.domain());
00095
00096 for_all(p)
00097 q.push(max - dist(p), p);
00098 }
00099
00100
00101
00102 {
00103 while (! q.is_empty())
00104 {
00105 mln_psite(I) p = q.pop_front();
00106
00107 if (out(p) != literal::zero)
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 }
00122
00123
00124
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 }
00145
00146 }
00147
00148
00149 #endif // ! MLN_GEOM_SEEDS2TILING_ROUNDNESS_HH