$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
with_single_left_link_dmax_ratio.hh
1 // Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
2 // (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_LINK_WITH_SINGLE_LEFT_LINK_DMAX_RATIO_HH
28 # define SCRIBO_PRIMITIVE_LINK_WITH_SINGLE_LEFT_LINK_DMAX_RATIO_HH
29 
34 
35 # include <mln/core/concept/image.hh>
36 # include <mln/core/concept/neighborhood.hh>
37 
38 # include <mln/accu/center.hh>
39 # include <mln/labeling/compute.hh>
40 # include <mln/math/abs.hh>
41 # include <mln/util/array.hh>
42 
43 # include <scribo/core/macros.hh>
44 # include <scribo/core/concept/dmax_functor.hh>
45 # include <scribo/core/component_set.hh>
46 # include <scribo/core/object_links.hh>
47 
48 # include <scribo/primitive/link/internal/find_link.hh>
49 # include <scribo/primitive/link/internal/dmax_default.hh>
50 # include <scribo/primitive/link/internal/link_single_dmax_ratio_base.hh>
51 
52 # include <scribo/primitive/link/compute.hh>
53 
54 
55 namespace scribo
56 {
57 
58  namespace primitive
59  {
60 
61  namespace link
62  {
63 
76  template <typename L, typename F>
77  inline
78  object_links<L>
79  with_single_left_link_dmax_ratio(const component_set<L>& components,
80  const DMax_Functor<F>& dmax_f,
81  anchor::Type anchor);
82 
86  //
87  template <typename L, typename F>
88  inline
89  object_links<L>
90  with_single_left_link_dmax_ratio(const component_set<L>& components,
91  float dmax_ratio,
92  anchor::Type anchor);
93 
94 
97  //
98  template <typename L>
99  inline
100  object_links<L>
101  with_single_left_link_dmax_ratio(const component_set<L>& components,
102  float dmax_ratio);
103 
104 
111  //
112  template <typename L, typename F>
113  inline
114  object_links<L>
115  with_single_left_link_dmax_ratio(const component_set<L>& components);
116 
117 
118 # ifndef MLN_INCLUDE_ONLY
119 
120 
121  namespace internal
122  {
123 
124  // Functor
125 
126  template <typename L, typename F>
127  class single_left_dmax_ratio_functor
128  : public internal::link_single_dmax_ratio_base<L, F,
129  single_left_dmax_ratio_functor<L, F> >
130  {
131  typedef single_left_dmax_ratio_functor<L, F> self_t;
132  typedef internal::link_single_dmax_ratio_base<L, F, self_t> super_;
133 
134  public:
135  typedef mln_site(L) P;
136 
137  single_left_dmax_ratio_functor(const component_set<L>& components,
138  const DMax_Functor<F>& dmax_f)
139  : super_(components, anchor::Horizontal, exact(dmax_f))
140  {
141  }
142 
143  void compute_next_site_(P& p)
144  {
145  --p.col();
146  }
147 
148  };
149 
150  } // end of namespace scribo::primitive::link::internal
151 
152 
153 
154  // Facades
155 
156  template <typename L, typename F>
157  inline
158  object_links<L>
159  with_single_left_link_dmax_ratio(const component_set<L>& components,
160  const DMax_Functor<F>& dmax_f,
161  anchor::Type anchor)
162  {
163  mln_trace("scribo::primitive::link::with_single_left_link_dmax_ratio");
164 
165  mln_precondition(components.is_valid());
166 
167  internal::single_left_dmax_ratio_functor<L, F>
168  functor(components, dmax_f);
169 
170  object_links<L> output = compute(functor, anchor);
171 
172  return output;
173  }
174 
175 
176  template <typename L>
177  inline
178  object_links<L>
179  with_single_left_link_dmax_ratio(const component_set<L>& components,
180  float dmax_ratio,
181  anchor::Type anchor)
182  {
183  return
185  internal::dmax_default(dmax_ratio),
186  anchor);
187  }
188 
189 
190  template <typename L>
191  inline
192  object_links<L>
193  with_single_left_link_dmax_ratio(const component_set<L>& components,
194  float dmax_ratio)
195  {
196  return
198  internal::dmax_default(dmax_ratio),
199  anchor::MassCenter);
200  }
201 
202 
203  template <typename L>
204  inline
205  object_links<L>
206  with_single_left_link_dmax_ratio(const component_set<L>& components)
207  {
208  return with_single_left_link_dmax_ratio(components, 3);
209  }
210 
211 
212 # endif // ! MLN_INCLUDE_ONLY
213 
214  } // end of namespace scribo::primitive::link
215 
216  } // end of namespace scribo::primitive
217 
218 } // end of namespace scribo
219 
220 #endif // ! SCRIBO_PRIMITIVE_LINK_WITH_SINGLE_LEFT_LINK_DMAX_RATIO_HH