26 #ifndef SCRIBO_PRIMITIVE_LINK_INTERNAL_LINK_SINGLE_DMAX_RATIO_ALIGNED_BASE_HH_
27 # define SCRIBO_PRIMITIVE_LINK_INTERNAL_LINK_SINGLE_DMAX_RATIO_ALIGNED_BASE_HH_
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>
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>
51 # include <scribo/debug/logger.hh>
53 # include <scribo/primitive/link/internal/link_single_dmax_ratio_base.hh>
54 # include <scribo/filter/internal/component_aligned.hh>
68 using namespace scribo::debug;
71 template <
typename L,
typename F,
typename E>
78 typedef mln_site(L) P;
86 :
super_(components, anchor::Horizontal,
exact(dmax_f)),
89 min_alpha_rad = (min_angle / 180.0f) *
math::pi;
90 max_alpha_rad = (max_angle / 180.0f) *
math::pi;
92 # ifndef SCRIBO_NDEBUG
102 # endif // ! SCRIBO_NDEBUG
107 start_point_(
unsigned current_object, anchor::Type anchor)
109 return link::internal::compute_anchor(this->components_,
110 current_object, anchor);
116 valid_link_(
unsigned current_object,
117 const P& start_point,
121 if (!super_::valid_link_(current_object, start_point, p, anchor))
127 box<P> b = this->components_(current_object).
bbox();
128 if (p[this->direction_] > b.
pmax()[this->direction_])
129 dist =
math::abs(p[this->direction_] - b.
pmax()[this->direction_]);
132 dist =
math::abs(p[this->direction_] - b.
pmin()[this->direction_]);
135 unsigned ldist = this->components_(current_object).bbox().width() / 2;
139 if (dist < ldist * 3)
142 filter::internal::component_aligned_rad(this->components_,
144 this->labeled_image_(p),
152 filter::internal::component_aligned_rad(this->components_,
154 this->labeled_image_(p),
160 void validate_link_(
unsigned current_object,
161 const P& start_point,
165 super_::validate_link_(current_object, start_point, p, anchor);
167 # ifndef SCRIBO_NDEBUG
168 if (
logger().is_at_level(debug::AuxiliaryResults))
171 p1 = link::internal::compute_anchor(this->components_,
172 current_object, debug_anchor_),
173 p2 = link::internal::compute_anchor(this->components_,
174 this->labeled_image_(p),
180 angle = filter::internal::alignment_angle(this->components_,
182 this->labeled_image_(p),
184 angle = (angle * 180.0f) /
math::pi;
185 angle = angle * 20.0f + 1.0f;
191 # endif // ! SCRIBO_NDEBUG
194 void invalidate_link_(
unsigned current_object,
195 const P& start_point,
199 super_::invalidate_link_(current_object, start_point, p, anchor);
201 # ifndef SCRIBO_NDEBUG
202 if (
logger().is_at_level(debug::AuxiliaryResults))
204 if (this->labeled_image_.domain().has(p) && this->labeled_image_(p) != 0)
207 p1 = link::internal::compute_anchor(this->components_,
208 current_object, debug_anchor_),
209 p2 = link::internal::compute_anchor(this->components_,
210 this->labeled_image_(p),
214 if (this->labeled_image_.domain().has(p2)
222 angle = filter::internal::alignment_angle(this->components_,
224 this->labeled_image_(p),
226 angle = (angle * 180.0f) /
math::pi;
227 angle = angle * 20.0f + 1.0f;
234 # endif // ! SCRIBO_NDEBUG
241 anchor::Type debug_anchor_;
248 # ifndef MLN_INCLUDE_ONLY
251 # endif // ! MLN_INCLUDE_ONLY
263 #endif // SCRIBO_PRIMITIVE_LINK_INTERNAL_LINK_SINGLE_DMAX_RATIO_ALIGNED_BASE_HH_