$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
alignment_decision_image.hh
1 // Copyright (C) 2009, 2011, 2013 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_DEBUG_ALIGNMENT_DECISION_IMAGE_HH
28 # define SCRIBO_DEBUG_ALIGNMENT_DECISION_IMAGE_HH
29 
33 
34 # include <mln/core/concept/image.hh>
35 # include <mln/data/convert.hh>
36 # include <mln/value/rgb8.hh>
37 # include <mln/literal/colors.hh>
38 # include <mln/util/array.hh>
39 # include <mln/util/couple.hh>
40 
41 # include <scribo/core/component_set.hh>
42 # include <scribo/core/object_groups.hh>
43 # include <scribo/draw/bounding_boxes.hh>
44 
45 # include <scribo/primitive/link/internal/compute_anchor.hh>
46 
47 namespace scribo
48 {
49 
50  namespace debug
51  {
52 
53  using namespace mln;
54 
70  template <typename I, typename L>
73  const object_links<L>& links,
74  const object_links<L>& filtered_links,
75  const anchor::Type& anchor);
76 
77 
78 # ifndef MLN_INCLUDE_ONLY
79 
80  template <typename I, typename L>
82  alignment_decision_image(const Image<I>& input_,
83  const object_links<L>& links,
84  const object_links<L>& filtered_links,
85  const anchor::Type& anchor)
86  {
87  mln_trace("scribo::debug::alignment_decision_image");
88  const I& input = exact(input_);
89 
90  const component_set<L>& components = links.components();
91 
92  mln_precondition(input.is_valid());
93  mln_precondition(links.is_valid());
94  mln_precondition(filtered_links.is_valid());
96 
99 
100  for_all_comps(i, components)
101  mln::draw::box(decision_image, components(i).bbox(), literal::blue);
102 
103  typedef mln_site(L) P;
104 
105  for_all_links(i, links)
106  if (links(i) != i)
107  {
108  value::rgb8 value = literal::green;
109  P
110  anchor_i = primitive::link::internal::compute_anchor(components,
111  i, anchor),
112  anchor_li = primitive::link::internal::compute_anchor(components,
113  links(i),
114  anchor);
115 
116  if (links(i) != filtered_links(i))
117  value = literal::red;
118 
119  mln::draw::line(decision_image, anchor_i, anchor_li, value);
120  }
121 
122  return decision_image;
123  }
124 
125 # endif // ! MLN_INCLUDE_ONLY
126 
127  } // end of namespace scribo::debug
128 
129 } // end of namespace scribo
130 
131 
132 #endif // ! SCRIBO_DEBUG_ALIGNMENT_DECISION_IMAGE_HH