5 #include <mln/core/image/image2d.hh>
6 #include <mln/core/image/dmorph/image_if.hh>
7 #include <mln/core/alias/neighb2d.hh>
9 #include <mln/data/fill.hh>
11 #include <mln/labeling/blobs.hh>
12 #include <mln/labeling/compute.hh>
13 #include <mln/labeling/blobs.hh>
15 #include <mln/data/compare.hh>
17 #include <mln/util/array.hh>
19 #include <mln/value/label_8.hh>
21 #include <mln/accu/math/count.hh>
23 #include <mln/pw/all.hh>
25 #include <tests/data.hh>
26 #include <doc/tools/sample_utils.hh>
31 template <
typename I,
typename N>
33 my_algorithm(const Image<I>& ima_,
34 const Neighborhood<N>& nbh_)
36 trace::entering(
"my_algorithm");
38 const I& ima = exact(ima_);
39 const N& nbh = exact(nbh_);
40 mln_precondition(ima.is_valid());
41 mln_precondition(nbh.is_valid());
45 mln_ch_value(I,V) lbl = labeling::blobs(ima, nbh, nlabels);
47 count = labeling::compute(accu::meta::math::count(),
51 mln_concrete(I) output;
53 data::fill(output, literal::one);
55 for (
unsigned i = 1; i <= nlabels; ++i)
57 data::fill((output | (pw::value(lbl) == pw::cst(i))).rw(),
60 trace::exiting("my_algorithm");
73 template <
typename I,
typename N>
75 my_algorithm(const
Image<I>& ima_,
80 trace::entering(
"my_algorithm");
84 const I& ima = exact(ima_);
85 const N& nbh = exact(nbh_);
86 mln_precondition(ima.is_valid());
87 mln_precondition(nbh.is_valid());
93 mln_ch_value(I,V) lbl = labeling::blobs(ima, nbh, nlabels);
95 count = labeling::compute(accu::meta::math::count(),
101 mln_concrete(I) output;
103 data::fill(output, literal::one);
107 for (
unsigned i = 1; i <= nlabels; ++i)
109 data::fill((output | (pw::value(lbl) == pw::cst(i))).rw(),
114 trace::exiting("my_algorithm");
124 mln_assertion(sandbox::my_algorithm(test,
mln::c4())
125 == mln::my_algorithm(test,
mln::c4()));