$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
objects_v_thick.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_OBJECTS_V_THICK_HH
28 # define SCRIBO_FILTER_OBJECTS_V_THICK_HH
29 
33 
34 # include <mln/core/concept/image.hh>
35 # include <mln/core/concept/neighborhood.hh>
36 
37 # include <scribo/core/component_set.hh>
38 # include <scribo/filter/internal/compute.hh>
39 
40 
41 namespace scribo
42 {
43 
44  namespace filter
45  {
46 
47  using namespace mln;
48 
60  //
61  template <typename I, typename N, typename V>
62  inline
63  mln_concrete(I)
64  objects_v_thick(const Image<I>& input_,
65  const Neighborhood<N>& nbh_,
66  const V& label_type,
67  unsigned max_thickness);
68 
69 
79  //
80  template <typename L>
81  inline
82  component_set<L>
83  objects_v_thick(const component_set<L>& comps,
84  unsigned max_thickness);
85 
86 
87 
88 # ifndef MLN_INCLUDE_ONLY
89 
90 
91  namespace internal
92  {
93 
96  template <typename L>
97  struct v_thick_object_filter
98  : Function_v2b< v_thick_object_filter<L> >
99  {
100 
105  //
106  v_thick_object_filter(const component_set<L>& comps,
107  unsigned max_thickness)
108  : comps_(comps), max_thickness_(max_thickness)
109  {
110  }
111 
115  //
116  v_thick_object_filter(unsigned max_thickness)
117  : max_thickness_(max_thickness)
118  {
119  }
120 
122  //
123  void update_objects(const component_set<L>& comps)
124  {
125  comps_ = comps;
126  }
127 
132  bool operator()(const mln_value(L)& l) const
133  {
134  if (l == literal::zero)
135  return false;
136  return comps_(l).bbox().height() < max_thickness_;
137  }
138 
139 
141  component_set<L> comps_;
142 
144  unsigned max_thickness_;
145  };
146 
147 
148  } // end of namespace scribo::filter::internal
149 
150 
151  template <typename I, typename N, typename V>
152  inline
153  mln_concrete(I)
154  objects_thick(const Image<I>& input_,
155  const Neighborhood<N>& nbh_,
156  const V& label_type,
157  unsigned max_thickness)
158  {
159  mln_trace("scribo::filter::objects_v_thick");
160 
161  const I& input = exact(input_);
162  const N& nbh = exact(nbh_);
163 
164  mln_precondition(input.is_valid());
165  mln_precondition(nbh.is_valid());
166 
167  internal::v_thick_object_filter<V> functor(max_thickness);
168  mln_concrete(I)
169  output = internal::compute(input, nbh, label_type, functor);
170 
171  return output;
172  }
173 
174 
175  template <typename L>
176  inline
177  component_set<L>
178  objects_v_thick(const component_set<L>& comps,
179  unsigned max_thickness)
180  {
181  mln_trace("scribo::filter::objects_v_thick");
182 
183  internal::v_thick_object_filter<L> functor(comps, max_thickness);
184  component_set<L> output = internal::compute(comps, functor);
185 
186  return output;
187  }
188 
189 # endif // ! MLN_INCLUDE_ONLY
190 
191  } // end of namespace scribo::filter
192 
193 } // end of namespace scribo
194 
195 
196 #endif // ! SCRIBO_FILTER_OBJECTS_V_THICK_HH