$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
objects_h_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_H_THICK_HH
28 # define SCRIBO_FILTER_OBJECTS_H_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 
59  //
60  template <typename I, typename N, typename V>
61  inline
62  mln_concrete(I)
63  objects_h_thick(const Image<I>& input_,
64  const Neighborhood<N>& nbh_,
65  const V& label_type,
66  unsigned max_thickness);
67 
68 
77  //
78  template <typename L>
79  inline
80  component_set<L>
81  objects_h_thick(const component_set<L>& comps,
82  unsigned max_thickness);
83 
84 
85 
86 # ifndef MLN_INCLUDE_ONLY
87 
88 
89  namespace internal
90  {
91 
94  template <typename L>
95  struct h_thick_object_filter
96  : Function_v2b< h_thick_object_filter<L> >
97  {
98 
103  //
104  h_thick_object_filter(const component_set<L>& comps,
105  unsigned max_thickness)
106  : comps_(comps), max_thickness_(max_thickness)
107  {
108  }
109 
113  //
114  h_thick_object_filter(unsigned max_thickness)
115  : max_thickness_(max_thickness)
116  {
117  }
118 
120  //
121  void update_objects(const component_set<L>& comps)
122  {
123  comps_ = comps;
124  }
125 
130  bool operator()(const mln_value(L)& l) const
131  {
132  if (l == literal::zero)
133  return false;
134  return comps_(l).bbox().width() < max_thickness_;
135  }
136 
137 
139  component_set<L> comps_;
140 
142  unsigned max_thickness_;
143  };
144 
145 
146  } // end of namespace scribo::filter::internal
147 
148 
149  template <typename I, typename N, typename V>
150  inline
151  mln_concrete(I)
152  objects_thick(const Image<I>& input_,
153  const Neighborhood<N>& nbh_,
154  const V& label_type,
155  unsigned max_thickness)
156  {
157  mln_trace("scribo::filter::objects_h_thick");
158 
159  const I& input = exact(input_);
160  const N& nbh = exact(nbh_);
161 
162  mln_precondition(input.is_valid());
163  mln_precondition(nbh.is_valid());
164 
165  internal::h_thick_object_filter<V> functor(max_thickness);
166  mln_concrete(I)
167  output = internal::compute(input, nbh, label_type, functor);
168 
169  return output;
170  }
171 
172 
173  template <typename L>
174  inline
175  component_set<L>
176  objects_h_thick(const component_set<L>& comps,
177  unsigned max_thickness)
178  {
179  mln_trace("scribo::filter::objects_h_thick");
180 
181  internal::h_thick_object_filter<L> functor(comps, max_thickness);
182  component_set<L> output = internal::compute(comps, functor);
183 
184  return output;
185  }
186 
187 # endif // ! MLN_INCLUDE_ONLY
188 
189  } // end of namespace scribo::filter
190 
191 } // end of namespace scribo
192 
193 
194 #endif // ! SCRIBO_FILTER_OBJECTS_H_THICK_HH