$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_aligned.hh
1 // Copyright (C) 2009, 2010, 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_LINK_WITH_SINGLE_LEFT_LINK_DMAX_RATIO_ALIGNED_HH
28 # define SCRIBO_PRIMITIVE_LINK_WITH_SINGLE_LEFT_LINK_DMAX_RATIO_ALIGNED_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/dmax_default.hh>
48 # include <scribo/primitive/link/internal/find_link.hh>
49 # include <scribo/primitive/link/internal/link_single_dmax_ratio_aligned_base.hh>
50 
51 # include <scribo/primitive/link/compute.hh>
52 
53 # include <scribo/filter/internal/component_aligned.hh>
54 
55 
56 namespace scribo
57 {
58 
59  namespace primitive
60  {
61 
62  namespace link
63  {
64 
86  template <typename L, typename F>
87  inline
88  object_links<L>
90  const component_set<L>& components,
91  const DMax_Functor<F>& dmax_f,
92  float min_angle, float max_angle,
93  anchor::Type anchor);
94 
98  //
99  template <typename L>
100  inline
101  object_links<L>
103  const component_set<L>& components,
104  float dmax_ratio,
105  float min_angle, float max_angle);
106 
107 
111  //
112  template <typename L>
113  inline
114  object_links<L>
116  const component_set<L>& components);
117 
118 
119 
120 # ifndef MLN_INCLUDE_ONLY
121 
122 
123  namespace internal
124  {
125 
126  // Functor
127 
128 
129  template <typename L, typename F>
130  class single_left_dmax_ratio_aligned_functor
131  : public link_single_dmax_ratio_aligned_base<L, F, single_left_dmax_ratio_aligned_functor<L,F> >
132  {
133  typedef single_left_dmax_ratio_aligned_functor<L,F> self_t;
134  typedef link_single_dmax_ratio_aligned_base<L, F, self_t> super_;
135 
136  public:
137  typedef mln_site(L) P;
138 
139  single_left_dmax_ratio_aligned_functor(
140  const component_set<L>& components,
141  const DMax_Functor<F>& dmax_f,
142  float min_angle,
143  float max_angle,
144  anchor::Type anchor)
145  : super_(components, dmax_f, min_angle,
146  max_angle, anchor)
147  {
148  }
149 
150  void compute_next_site_(P& p)
151  {
152  --p.col();
153  }
154 
155  };
156 
157  } // end of namespace scribo::primitive::link::internal
158 
159 
160 
161  // Facades
162 
163 
164  template <typename L, typename F>
165  inline
166  object_links<L>
168  const component_set<L>& components,
169  const DMax_Functor<F>& dmax_f,
170  float min_angle, float max_angle,
171  anchor::Type anchor)
172  {
173  mln_trace("scribo::primitive::link::with_single_left_link_dmax_ratio_aligned");
174 
175  mln_precondition(components.is_valid());
176 
177  internal::single_left_dmax_ratio_aligned_functor<L,F>
178  functor(components, dmax_f, min_angle, max_angle, anchor);
179 
180  object_links<L> output = compute(functor, anchor);
181 
182  return output;
183  }
184 
185 
186 
187  template <typename L>
188  inline
189  object_links<L>
191  const component_set<L>& components,
192  float dmax_ratio,
193  float min_angle, float max_angle)
194  {
195  return
197  internal::dmax_default(dmax_ratio),
198  min_angle,
199  max_angle,
200  anchor::MassCenter);
201  }
202 
203 
204  template <typename L>
205  inline
206  object_links<L>
208  const component_set<L>& components)
209  {
210  return
211  with_single_left_link_dmax_ratio_aligned(components, 3, 3, 10);
212  }
213 
214 
215 # endif // ! MLN_INCLUDE_ONLY
216 
217  } // end of namespace scribo::primitive::link
218 
219  } // end of namespace scribo::primitive
220 
221 } // end of namespace scribo
222 
223 #endif // ! SCRIBO_PRIMITIVE_LINK_WITH_SINGLE_LEFT_LINK_DMAX_RATIO_ALIGNED_HH