$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
bboxes_image.hh
1 // Copyright (C) 2009, 2010, 2011 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_BBOXES_IMAGE_HH
28 # define SCRIBO_DEBUG_BBOXES_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/util/array.hh>
38 # include <mln/io/ppm/save.hh>
39 # include <mln/literal/colors.hh>
40 
41 # include <scribo/core/line_set.hh>
42 # include <scribo/draw/bounding_boxes.hh>
43 
44 
45 namespace scribo
46 {
47 
48  namespace debug
49  {
50 
51  using namespace mln;
52 
53 
57  //
58  template <typename I>
59  mln_ch_value(I, value::rgb8)
60  bboxes_image(const Image<I>& input,
61  const mln::util::array< box<mln_site(I)> >& bboxes,
62  const value::rgb8& value);
63 
67  //
68  template <typename I, typename L>
69  mln_ch_value(I, value::rgb8)
70  bboxes_image(const Image<I>& input,
71  const line_set<L>& lines,
72  const value::rgb8& value);
73 
78  //
79  template <typename I, typename L>
80  inline
81  mln_ch_value(I, value::rgb8)
82  bboxes_image(const Image<I>& input,
83  const line_set<L>& lines);
84 
88  //
89  template <typename I, typename L>
90  inline
91  mln_ch_value(I, value::rgb8)
92  bboxes_image(const Image<I>& input,
93  const component_set<L>& comps,
94  const value::rgb8& value);
95 
96 # ifndef MLN_INCLUDE_ONLY
97 
98  template <typename I>
99  inline
100  mln_ch_value(I, value::rgb8)
101  bboxes_image(const Image<I>& input,
102  const mln::util::array< box<mln_site(I)> >& bboxes,
103  const value::rgb8& value)
104  {
105  mln_trace("scribo::debug::bboxes_image");
106  mln_precondition(exact(input).is_valid());
107 
108  mln_ch_value(I,value::rgb8) tmp = data::convert(value::rgb8(), input);
109  draw::bounding_boxes(tmp, bboxes, value);
110 
111  return tmp;
112  }
113 
114 
115  template <typename I, typename L>
116  inline
117  mln_ch_value(I, value::rgb8)
118  bboxes_image(const Image<I>& input,
119  const line_set<L>& lines,
120  const value::rgb8& value)
121  {
122  mln_trace("scribo::debug::bboxes_image");
123  mln_precondition(exact(input).is_valid());
124 
125  mln_ch_value(I, value::rgb8)
126  output = data::convert(value::rgb8(), input);
127 
128  for_all_lines(l, lines)
129  if (! lines(l).is_hidden())
130  mln::draw::box(output, lines(l).bbox(), value);
131 
132  return output;
133  }
134 
135 
136  template <typename I, typename L>
137  inline
138  mln_ch_value(I, value::rgb8)
139  bboxes_image(const Image<I>& input,
140  const line_set<L>& lines)
141  {
142  return bboxes_image(input, lines, literal::red);
143  }
144 
145 
146  template <typename I, typename L>
147  inline
148  mln_ch_value(I, value::rgb8)
149  bboxes_image(const Image<I>& input,
150  const component_set<L>& comps,
151  const value::rgb8& value)
152  {
153  mln_trace("scribo::debug::bboxes_image");
154  mln_precondition(exact(input).is_valid());
155 
156  mln_ch_value(I, value::rgb8)
157  output = data::convert(value::rgb8(), input);
158 
159  for_all_comps(c, comps)
160  if (comps(c).is_valid())
161  mln::draw::box(output, comps(c).bbox(), value);
162 
163  return output;
164  }
165 
166 
167 # endif // ! MLN_INCLUDE_ONLY
168 
169  } // end of namespace scribo::debug
170 
171 } // end of namespace scribo
172 
173 
174 #endif // ! SCRIBO_DEBUG_BBOXES_IMAGE_HH