$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
components.hh
1 // Copyright (C) 2009, 2011, 2013 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_PRIMITIVE_EXTRACT_COMPONENTS_HH
28 # define SCRIBO_PRIMITIVE_EXTRACT_COMPONENTS_HH
29 
33 
34 
35 # include <mln/core/concept/neighborhood.hh>
36 # include <mln/core/site_set/box.hh>
37 
38 # include <mln/accu/shape/bbox.hh>
39 # include <mln/accu/center.hh>
40 # include <mln/accu/pair.hh>
41 
42 # include <mln/labeling/value_and_compute.hh>
43 # include <mln/labeling/compute.hh>
44 
45 # include <mln/util/array.hh>
46 # include <mln/util/couple.hh>
47 
48 # include <mln/extension/fill.hh>
49 
50 # include <scribo/core/component_set.hh>
51 # include <scribo/estim/components_features.hh>
52 
53 
54 
55 namespace scribo
56 {
57 
58  namespace primitive
59  {
60 
61  namespace extract
62  {
63 
64  using namespace mln;
65 
79  template <typename I, typename J, typename N, typename V>
80  inline
81  component_set<mln_ch_value(I,V)>
82  components(const Image<I>& input, const Image<J>& binary_input,
83  const Neighborhood<N>& nbh, V& ncomponents,
85 
86 
99  template <typename I, typename N, typename V>
100  inline
101  component_set<mln_ch_value(I,V)>
102  components(const Image<I>& binary_input,
103  const Neighborhood<N>& nbh, V& ncomponents,
105 
106 
107 # ifndef MLN_INCLUDE_ONLY
108 
109  template <typename I, typename J, typename N, typename V>
110  inline
111  component_set<mln_ch_value(I,V)>
112  components(const Image<I>& input, const Image<J>& binary_input,
113  const Neighborhood<N>& nbh, V& ncomponents,
114  component::Type type)
115  {
116  mln_trace("scribo::components");
117 
118  mlc_equal(mln_value(J),bool)::check();
119 // mlc_is_a(V, mln::value::Symbolic)::check();
120  mln_precondition(exact(input).is_valid());
121  mln_precondition(exact(binary_input).is_valid());
122  mln_precondition(exact(nbh).is_valid());
123 
124  typedef mln_ch_value(I,V) L;
125  component_set<L>
126  output = extract::components(binary_input, nbh, ncomponents, type);
127 
128  output = estim::components_features(input, binary_input, output);
129 
130  return output;
131  }
132 
133 
134  template <typename I, typename N, typename V>
135  inline
136  component_set<mln_ch_value(I,V)>
137  components(const Image<I>& binary_input,
138  const Neighborhood<N>& nbh, V& ncomponents,
139  component::Type type)
140  {
141  mln_trace("scribo::components");
142 
143  mlc_equal(mln_value(I),bool)::check();
144 // mlc_is_a(V, mln::value::Symbolic)::check();
145  mln_precondition(exact(binary_input).is_valid());
146  mln_precondition(exact(nbh).is_valid());
147 
148 
149  typedef mln_ch_value(I,V) L;
150  typedef mln::accu::shape::bbox<mln_site(L)> bbox_accu_t;
151  typedef mln::accu::center<mln_site(L)> center_accu_t;
152  typedef mln::accu::pair<bbox_accu_t, center_accu_t> pair_accu_t;
153 
154  // Setting extension value.
155  extension::fill(binary_input, false);
156 
157  mln::util::couple<L,
158  mln::util::couple<
159  mln::util::array<mln_result(pair_accu_t)>,
160  mln::util::array<pair_accu_t> > >
161  results = labeling::value_and_compute(binary_input, true, nbh,
162  ncomponents,
163  pair_accu_t());
164 
165  component_set<L>
166  output(results.first(), ncomponents, results.second().second(), type);
167 
168  return output;
169  }
170 
171 
172 # endif // ! MLN_INCLUDE_ONLY
173 
174  } // end of namespace scribo::primitive::extract
175 
176  } // end of namespace scribo::primitive
177 
178 } // end of namespace scribo
179 
180 
181 #endif // ! SCRIBO_PRIMITIVE_EXTRACT_COMPONENTS_HH