$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
links_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_LINKS_DECISION_IMAGE_HH
28 # define SCRIBO_DEBUG_LINKS_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/draw/box.hh>
39 # include <mln/draw/line.hh>
40 
41 # include <scribo/core/object_links.hh>
42 
43 
44 namespace scribo
45 {
46 
47  namespace debug
48  {
49 
50  using namespace mln;
51 
57  template <typename I, typename L>
58  mln_ch_value(I,value::rgb8)
59  links_decision_image(const Image<I>& input_,
60  const object_links<L>& links,
61  const object_links<L>& filtered_links);
62 
63 # ifndef MLN_INCLUDE_ONLY
64 
65  template <typename I, typename L>
66  mln_ch_value(I,value::rgb8)
67  links_decision_image(const Image<I>& input_,
68  const object_links<L>& links,
69  const object_links<L>& filtered_links)
70  {
71  mln_trace("scribo::debug::links_decision_image");
72  const I& input = exact(input_);
73 
74  const component_set<L>& comps = links.components();
75 
76  mln_precondition(input.is_valid());
77  mln_precondition(comps.is_valid());
78  mln_precondition(links.is_valid());
79  mln_precondition(filtered_links.is_valid());
80  mln_precondition(links.size() == filtered_links.size());
82 
83  mln_ch_value(I,value::rgb8)
84  links_decision_image = data::convert(value::rgb8(), input);
85 
86  for_all_comps(i, comps)
87  mln::draw::box(links_decision_image, comps(i).bbox(), literal::blue);
88 
89  for_all_links(i, links)
90  if (links(i) != i)
91  {
92  value::rgb8 value = literal::green;
93  if (links(i) != filtered_links(i))
94  value = literal::red;
95 
96  mln_site(I)
97  p1 = comps(i).mass_center(),
98  p2 = comps(links(i)).mass_center();
99 
100  mln::draw::line(links_decision_image, p1, p2, value);
101  }
102 
103  return links_decision_image;
104  }
105 
106 
107 # endif // ! MLN_INCLUDE_ONLY
108 
109  } // end of namespace scribo::debug
110 
111 } // end of namespace scribo
112 
113 
114 #endif // ! SCRIBO_DEBUG_LINKS_DECISION_IMAGE_HH