$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
first_routine.cc
1 
2 
3 
4 // \{
5 #include <mln/core/image/image2d.hh>
6 #include <mln/core/image/dmorph/image_if.hh>
7 #include <mln/core/alias/neighb2d.hh>
8 
9 #include <mln/data/fill.hh>
10 
11 #include <mln/labeling/blobs.hh>
12 #include <mln/labeling/compute.hh>
13 #include <mln/labeling/blobs.hh>
14 
15 #include <mln/data/compare.hh>
16 
17 #include <mln/util/array.hh>
18 
19 #include <mln/value/label_8.hh>
20 
21 #include <mln/accu/math/count.hh>
22 
23 #include <mln/pw/all.hh>
24 
25 #include <doc/tools/sample_utils.hh>
26 
27 namespace mln
28 {
29 
30  template <typename I, typename N>
31  mln_concrete(I)
32  my_algorithm(const Image<I>& ima_,
33  const Neighborhood<N>& nbh_)
34  {
35  mln_trace("my_algorithm");
36 
37  const I& ima = exact(ima_);
38  const N& nbh = exact(nbh_);
39  mln_precondition(ima.is_valid());
40  mln_precondition(nbh.is_valid());
41 
42  typedef value::label_8 V;
43  V nlabels;
44  mln_ch_value(I,V) lbl = labeling::blobs(ima, nbh, nlabels);
47  lbl,
48  nlabels);
49 
50  mln_concrete(I) output;
51  initialize(output, ima);
52  data::fill(output, literal::one);
53 
54  for (unsigned i = 1; i <= nlabels; ++i)
55  if (count[i] < 10u)
56  data::fill((output | (pw::value(lbl) == pw::cst(i))).rw(),
58 
59  return output;
60  }
61 
62 } // end of namespace mln
63 // \}
64 
65 namespace sandbox
66 {
67 
68  using namespace mln;
69 
70  // \{
71  template <typename I, typename N>
72  mln_concrete(I)
73  my_algorithm(const Image<I>& ima_,
74  const Neighborhood<N>& nbh_)
75  // \}
76  {
77  // \{
78  mln_trace("my_algorithm");
79  // \}
80 
81  // \{
82  const I& ima = exact(ima_);
83  const N& nbh = exact(nbh_);
84  mln_precondition(ima.is_valid());
85  mln_precondition(nbh.is_valid());
86  // \}
87 
88  // \{
89  typedef value::label_8 V;
90  V nlabels;
91  mln_ch_value(I,V) lbl = labeling::blobs(ima, nbh, nlabels);
94  lbl,
95  nlabels);
96  // \}
97 
98  // \{
99  mln_concrete(I) output;
100  initialize(output, ima);
101  data::fill(output, literal::one);
102  // \}
103 
104  // \{
105  for (unsigned i = 1; i <= nlabels; ++i)
106  if (count[i] < 10u)
107  data::fill((output | (pw::value(lbl) == pw::cst(i))).rw(),
108  literal::zero);
109  // \}
110 
111  // \{
112  return output;
113  // \}
114  }
115 
116 } // end of namespace mln
117 
118 int main()
119 {
120  mln::image2d<bool> test(2,2);
121  mln_assertion(sandbox::my_algorithm(test, mln::c4())
122  == mln::my_algorithm(test, mln::c4()));
123 }