$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
decision_image.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_DEBUG_DECISION_IMAGE_HH
28 # define SCRIBO_DEBUG_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/draw/box.hh>
40 # include <mln/draw/line.hh>
41 
42 # include <scribo/core/tag/anchor.hh>
43 # include <scribo/core/object_groups.hh>
44 # include <scribo/primitive/link/internal/compute_anchor.hh>
45 
46 
47 namespace scribo
48 {
49 
50  namespace debug
51  {
52 
53  using namespace mln;
54 
55 
72  template <typename I, typename L>
73  mln_ch_value(I,value::rgb8)
74  decision_image(const Image<I>& input,
75  const object_groups<L>& groups,
76  const object_groups<L>& filtered_groups,
77  anchor::Type anchor);
78 
94  template <typename I, typename L>
95  mln_ch_value(I,value::rgb8)
96  decision_image(const Image<I>& input,
97  const object_links<L>& links,
98  const object_links<L>& filtered_links,
99  anchor::Type anchor);
100 
101 
102 # ifndef MLN_INCLUDE_ONLY
103 
104  template <typename I, typename L>
105  mln_ch_value(I,value::rgb8)
106  decision_image(const Image<I>& input_,
107  const object_groups<L>& groups,
108  const object_groups<L>& filtered_groups)
109  {
110  mln_trace("scribo::debug::decision_image");
111  const I& input = exact(input_);
112 
113  const component_set<L>& components = groups.components();
114 
115  mln_precondition(input.is_valid());
116  mln_precondition(groups.is_valid());
117  mln_precondition(filtered_groups.is_valid());
119 
120  mln_ch_value(I,value::rgb8)
121  decision_image = data::convert(value::rgb8(), input);
122 
123  for (unsigned i = 1; i < groups.size(); ++i)
124  if (groups(i) != filtered_groups(i))
125  mln::draw::box(decision_image, components(i).bbox(),
126  literal::red);
127  else
128  mln::draw::box(decision_image, components(i).bbox(),
129  literal::green);
130 
131  return decision_image;
132  }
133 
134 
135  template <typename I, typename L>
136  mln_ch_value(I,value::rgb8)
137  decision_image(const Image<I>& input_,
138  const object_links<L>& links,
139  const object_links<L>& filtered_links,
140  anchor::Type anchor)
141  {
142  mln_trace("scribo::debug::decision_image");
143  const I& input = exact(input_);
144 
145  const component_set<L>& comps = links.components();
146 
147  mln_precondition(input.is_valid());
148  mln_precondition(links.is_valid());
149  mln_precondition(filtered_links.is_valid());
151 
152  mln_ch_value(I,value::rgb8)
153  decision_image = data::convert(value::rgb8(), input);
154 
155  for_all_comps(i, comps)
156  mln::draw::box(decision_image, comps(i).bbox(), literal::blue);
157 
158  for_all_links(i, links)
159  {
160 
161  if (links.is_linked(i))
162  {
163  mln_site(L)
164  p1 = primitive::link::internal::compute_anchor(comps, i, anchor),
165  p2 = primitive::link::internal::compute_anchor(comps, links(i),
166  anchor);
167 
168  value::rgb8 value = literal::green;
169  if (links(i) != filtered_links(i))
170  value = literal::red;
171  mln::draw::line(decision_image, p1, p2, value);
172  }
173  }
174 
175  return decision_image;
176  }
177 
178 
179 
180 # endif // ! MLN_INCLUDE_ONLY
181 
182  } // end of namespace scribo::debug
183 
184 } // end of namespace scribo
185 
186 
187 #endif // ! SCRIBO_DEBUG_DECISION_IMAGE_HH