$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
objects_large.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_LARGE_HH
28 # define SCRIBO_FILTER_COMPONENTS_LARGE_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 
39 # include <mln/labeling/compute.hh>
40 # include <mln/accu/math/count.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/primitive/extract/components.hh>
48 # include <scribo/fun/v2b/objects_large_filter.hh>
49 
50 namespace scribo
51 {
52 
53  namespace filter
54  {
55 
56  using namespace mln;
57 
58 
71  //
72  template <typename I, typename N, typename V>
73  mln_concrete(I)
74  components_large(const Image<I>& input_,
75  const Neighborhood<N>& nbh_,
76  const V& label_type,
77  unsigned max_size);
78 
88  //
89  template <typename L>
90  inline
91  component_set<L>
92  components_large(const component_set<L>& components,
93  unsigned max_size);
94 
95 
96 # ifndef MLN_INCLUDE_ONLY
97 
98 
99 
100  template <typename I, typename N, typename V>
101  inline
102  mln_concrete(I)
103  components_large(const Image<I>& input_,
104  const Neighborhood<N>& nbh_,
105  V& nlabels,
106  unsigned min_size)
107  {
108  mln_trace("scribo::filter::components_large");
109 
110  const I& input = exact(input_);
111  const N& nbh = exact(nbh_);
112 
113  mln_precondition(input.is_valid());
114  mln_precondition(nbh.is_valid());
115 
116  typedef mln_ch_value(I,V) lbl_t;
117  component_set<lbl_t>
118  lbl = primitive::extract::components(input, nbh, nlabels);
119 
120  typedef fun::v2b::components_large_filter<mln_ch_value(I,V)> func_t;
121  func_t fv2b(lbl, min_size);
122  mln_concrete(I)
123  output = mln::data::transform(lbl.labeled_image(), fv2b);
124  nlabels = fv2b.nlabels_;
125 
126  return output;
127  }
128 
129 
130 
131  template <typename L>
132  inline
133  component_set<L>
134  components_large(const component_set<L>& components,
135  unsigned max_size)
136  {
137  mln_trace("scribo::filter::components_large");
138 
139  mln_precondition(components.is_valid());
140 
141  fun::v2b::components_large_filter<L> f(components, max_size);
142 
143  component_set<L> output = components.duplicate();
144  output.update_tags(f, component::Ignored);
145 
146  return output;
147  }
148 
149 
150 
151 # endif // ! MLN_INCLUDE_ONLY
152 
153  } // end of namespace scribo::filter
154 
155 } // end of namespace scribo
156 
157 #endif // ! SCRIBO_FILTER_COMPONENTS_LARGE_HH