$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
with_single_right_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_RIGHT_LINK_DMAX_RATIO_HH
28 # define SCRIBO_PRIMITIVE_LINK_WITH_SINGLE_RIGHT_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/component_set.hh>
45 # include <scribo/core/object_links.hh>
46 
47 # include <scribo/primitive/link/internal/find_link.hh>
48 # include <scribo/primitive/link/internal/link_single_dmax_ratio_base.hh>
49 
50 # include <scribo/primitive/link/compute.hh>
51 # include <scribo/primitive/link/internal/dmax_default.hh>
52 
53 
54 namespace scribo
55 {
56 
57  namespace primitive
58  {
59 
60  namespace link
61  {
62 
76  template <typename L, typename F>
77  inline
78  object_links<L>
79  with_single_right_link_dmax_ratio(const component_set<L>& components,
80  const DMax_Functor<F>& dmax_f,
81  anchor::Type anchor);
82 
83 
86  template <typename L>
87  inline
88  object_links<L>
89  with_single_right_link_dmax_ratio(const component_set<L>& components,
90  float dmax_ratio,
91  anchor::Type anchor);
92 
95  template <typename L>
96  inline
97  object_links<L>
98  with_single_right_link_dmax_ratio(const component_set<L>& components,
99  float dmax_ratio);
100 
101 
105  template <typename L>
106  inline
107  object_links<L>
108  with_single_right_link_dmax_ratio(const component_set<L>& components);
109 
110 
111 
112 # ifndef MLN_INCLUDE_ONLY
113 
114 
115  namespace internal
116  {
117 
118  // Functor
119 
120  template <typename L, typename F>
121  class single_right_dmax_ratio_functor
122  : public link_single_dmax_ratio_base<L, F,
123  single_right_dmax_ratio_functor<L,F> >
124  {
125  typedef single_right_dmax_ratio_functor<L, F> self_t;
126  typedef link_single_dmax_ratio_base<L, F, self_t> super_;
127 
128  public:
129  typedef mln_site(L) P;
130 
131  single_right_dmax_ratio_functor(const component_set<L>& components,
132  const DMax_Functor<F>& dmax_f)
133  : super_(components, anchor::Horizontal, exact(dmax_f))
134  {
135  }
136 
137  void compute_next_site_(P& p)
138  {
139  ++p.col();
140  }
141 
142  };
143 
144  } // end of namespace scribo::primitive::link::internal
145 
146 
147 
148  // Facades
149 
150 
151  template <typename L, typename F>
152  inline
153  object_links<L>
154  with_single_right_link_dmax_ratio(const component_set<L>& components,
155  const DMax_Functor<F>& dmax_f,
156  anchor::Type anchor)
157  {
158  mln_trace("scribo::primitive::link::with_single_right_link_dmax_ratio");
159 
160  mln_precondition(components.is_valid());
161 
162  internal::single_right_dmax_ratio_functor<L, F>
163  functor(components, dmax_f);
164 
165  object_links<L> output = compute(functor, anchor);
166 
167  return output;
168  }
169 
170  template <typename L>
171  inline
172  object_links<L>
173  with_single_right_link_dmax_ratio(const component_set<L>& components,
174  float dmax_ratio,
175  anchor::Type anchor)
176  {
177  return
179  internal::dmax_default(dmax_ratio),
180  anchor);
181  }
182 
183 
184 
185  template <typename L>
186  inline
187  object_links<L>
188  with_single_right_link_dmax_ratio(const component_set<L>& components,
189  float dmax_ratio)
190  {
191  return with_single_right_link_dmax_ratio(components,
192  dmax_ratio,
193  anchor::MassCenter);
194  }
195 
196 
197  template <typename L>
198  inline
199  object_links<L>
200  with_single_right_link_dmax_ratio(const component_set<L>& components)
201  {
202  return with_single_right_link_dmax_ratio(components, 3);
203  }
204 
205 
206 # endif // ! MLN_INCLUDE_ONLY
207 
208  } // end of namespace scribo::primitive::link
209 
210  } // end of namespace scribo::primitive
211 
212 } // end of namespace scribo
213 
214 #endif // ! SCRIBO_PRIMITIVE_LINK_WITH_SINGLE_RIGHT_LINK_DMAX_RATIO_HH