$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
link_single_dmax_ratio_aligned_delta_base.hh
1 // Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
2 //
3 // This file is part of Olena.
4 //
5 // Olena is free software: you can redistribute it and/or modify it under
6 // the terms of the GNU General Public License as published by the Free
7 // Software Foundation, version 2 of the License.
8 //
9 // Olena is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with Olena. If not, see <http://www.gnu.org/licenses/>.
16 //
17 // As a special exception, you may use this file as part of a free
18 // software project without restriction. Specifically, if other files
19 // instantiate templates or use macros or inline functions from this
20 // file, or you compile this file and link it with other files to produce
21 // an executable, this file does not by itself cause the resulting
22 // executable to be covered by the GNU General Public License. This
23 // exception does not however invalidate any other reasons why the
24 // executable file might be covered by the GNU General Public License.
25 
26 #ifndef SCRIBO_PRIMITIVE_LINK_INTERNAL_LINK_SINGLE_DMAX_RATIO_ALIGNED_DELTA_BASE_HH_
27 # define SCRIBO_PRIMITIVE_LINK_INTERNAL_LINK_SINGLE_DMAX_RATIO_ALIGNED_DELTA_BASE_HH_
28 
33 
34 
35 # include <mln/accu/center.hh>
36 # include <mln/labeling/compute.hh>
37 # include <mln/math/abs.hh>
38 # include <mln/math/max.hh>
39 # include <mln/util/array.hh>
40 # include <mln/value/rgb8.hh>
41 # include <mln/draw/line.hh>
42 # include <mln/literal/colors.hh>
43 # include <mln/norm/l1.hh>
44 
45 # include <scribo/core/macros.hh>
46 # include <scribo/core/tag/anchor.hh>
47 # include <scribo/core/component_set.hh>
48 # include <scribo/core/object_links.hh>
49 # include <scribo/core/concept/dmax_functor.hh>
50 
51 # include <scribo/debug/logger.hh>
52 
53 # include <scribo/primitive/link/internal/link_single_dmax_ratio_base.hh>
54 # include <scribo/filter/internal/component_aligned.hh>
55 
56 
57 namespace scribo
58 {
59 
60  namespace primitive
61  {
62 
63  namespace link
64  {
65 
66  namespace internal
67  {
68  using namespace scribo::debug;
69 
70 
71  template <typename L, typename F, typename E>
73  : public link_single_dmax_ratio_base<L, F, E>
74  {
76 
77  public:
78  typedef mln_site(L) P;
79 
82  const DMax_Functor<F>& dmax_f,
83  int delta_pixel,
84  anchor::Direction delta_direction)
85  : super_(components, anchor::Horizontal, exact(dmax_f)),
86  delta_pixel_(delta_pixel), delta_direction_(delta_direction)
87  {
88 
89  }
90 
91 
92  mln_site(L)
93  start_point_(unsigned current_object, anchor::Type anchor)
94  {
95  return link::internal::compute_anchor(this->components_,
96  current_object, anchor);
97  }
98 
99 
100  inline
101  bool
102  valid_link_(unsigned current_object,
103  const P& start_point,
104  const P& p,
105  anchor::Type anchor)
106  {
107  if (!super_::valid_link_(current_object, start_point, p, anchor))
108  return false;
109 
110  // We can assume that the current site 'p' points to an
111  // object different from the background.
112 
113  mln_site(L)
114  p1 = compute_anchor(this->components_, current_object, anchor),
115  p2 = compute_anchor(this->components_, this->labeled_image_(p),
116  anchor);
117 
118  return std::abs(p1[this->delta_direction_]
119  - p2[this->delta_direction_]) <= delta_pixel_;
120  }
121 
122 
123  void validate_link_(unsigned current_object,
124  const P& start_point,
125  const P& p,
126  anchor::Type anchor)
127  {
128  super_::validate_link_(current_object, start_point, p, anchor);
129  }
130 
131  void invalidate_link_(unsigned current_object,
132  const P& start_point,
133  const P& p,
134  anchor::Type anchor)
135  {
136  super_::invalidate_link_(current_object, start_point, p, anchor);
137  }
138 
139  int delta_pixel_;
140  anchor::Direction delta_direction_;
141  };
142 
143 
144 # ifndef MLN_INCLUDE_ONLY
145 
146 
147 # endif // ! MLN_INCLUDE_ONLY
148 
149 
150  } // end of namespace scribo::primitive::link::internal
151 
152  } // end of namespace scribo::primitive::link
153 
154  } // end of namespace scribo::primitive
155 
156 } // end of namespace scribo
157 
158 
159 #endif // SCRIBO_PRIMITIVE_LINK_INTERNAL_LINK_SINGLE_DMAX_RATIO_ALIGNED_DELTA_BASE_HH_