$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
objects_small.hh
1 // Copyright (C) 2009, 2010, 2011 EPITA Research and Development
2 // Laboratory (LRDE)
3 //
4 // This file is part of Olena.
5 //
6 // Olena is free software: you can redistribute it and/or modify it under
7 // the terms of the GNU General Public License as published by the Free
8 // Software Foundation, version 2 of the License.
9 //
10 // Olena is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with Olena. If not, see <http://www.gnu.org/licenses/>.
17 //
18 // As a special exception, you may use this file as part of a free
19 // software project without restriction. Specifically, if other files
20 // instantiate templates or use macros or inline functions from this
21 // file, or you compile this file and link it with other files to produce
22 // an executable, this file does not by itself cause the resulting
23 // executable to be covered by the GNU General Public License. This
24 // exception does not however invalidate any other reasons why the
25 // executable file might be covered by the GNU General Public License.
26 
27 #ifndef SCRIBO_FILTER_COMPONENTS_SMALL_HH
28 # define SCRIBO_FILTER_COMPONENTS_SMALL_HH
29 
33 
34 
35 # include <mln/core/concept/image.hh>
36 # include <mln/core/concept/neighborhood.hh>
37 # include <mln/core/concept/function.hh>
38 # include <mln/core/image/dmorph/image_if.hh>
39 
40 # include <mln/data/transform.hh>
41 
42 # include <mln/util/array.hh>
43 
44 # include <mln/pw/all.hh>
45 
46 # include <scribo/core/component_set.hh>
47 # include <scribo/fun/v2b/objects_small_filter.hh>
48 # include <scribo/primitive/extract/components.hh>
49 
50 
51 namespace scribo
52 {
53 
54  namespace filter
55  {
56 
57  using namespace mln;
58 
59 
73  //
74  template <typename I, typename N, typename V>
75  mln_concrete(I)
76  components_small(const Image<I>& input,
77  const Neighborhood<N>& nbh,
78  V& nlabels,
79  unsigned min_size);
80 
81 
91  //
92  template <typename L>
93  component_set<L>
94  components_small(const component_set<L>& components,
95  unsigned min_size);
96 
97 
98 # ifndef MLN_INCLUDE_ONLY
99 
100 
101  template <typename I, typename N, typename V>
102  inline
103  mln_concrete(I)
104  components_small(const Image<I>& input_,
105  const Neighborhood<N>& nbh_,
106  V& nlabels,
107  unsigned min_size)
108  {
109  mln_trace("scribo::filter::components_small");
110 
111  const I& input = exact(input_);
112  const N& nbh = exact(nbh_);
113 
114  mln_precondition(input.is_valid());
115  mln_precondition(nbh.is_valid());
116 
117  typedef mln_ch_value(I,V) lbl_t;
118  component_set<lbl_t>
119  lbl = primitive::extract::components(input, nbh, nlabels);
120 
121  typedef fun::v2b::components_small_filter<mln_ch_value(I,V)> func_t;
122  func_t fv2b(lbl, min_size);
123  mln_concrete(I)
124  output = mln::data::transform(lbl.labeled_image(), fv2b);
125  nlabels = fv2b.nlabels_;
126 
127  return output;
128  }
129 
130 
131  template <typename L>
132  inline
133  component_set<L>
134  components_small(const component_set<L>& components,
135  unsigned min_size)
136  {
137  mln_trace("scribo::filter::components_small");
138 
139  mln_precondition(components.is_valid());
140 
141  fun::v2b::components_small_filter<L> f(components, min_size);
142 
143  component_set<L> output = components.duplicate();
144  output.update_tags(f, component::Ignored);
145 
146  return output;
147  }
148 
149 
150 # endif // ! MLN_INCLUDE_ONLY
151 
152  } // end of namespace scribo::filter
153 
154 } // end of namespace scribo
155 
156 #endif // ! SCRIBO_FILTER_COMPONENTS_SMALL_HH