$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
line_info_image.hh
1 // Copyright (C) 2010, 2011 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_LINE_INFO_IMAGE_HH
28 # define SCRIBO_DEBUG_LINE_INFO_IMAGE_HH
29 
33 
34 # include <mln/core/concept/image.hh>
35 # include <mln/core/alias/point2d.hh>
36 # include <mln/value/rgb8.hh>
37 # include <mln/data/convert.hh>
38 
39 # include <mln/draw/box.hh>
40 # include <mln/draw/line.hh>
41 
42 # include <mln/literal/colors.hh>
43 
44 # include <scribo/core/line_set.hh>
45 
46 
47 namespace scribo
48 {
49 
50  namespace debug
51  {
52 
53  using namespace mln;
54 
55 
60  template <typename I, typename L>
61  mln_ch_value(I,value::rgb8)
62  line_info_image(const Image<I>& input, const line_set<L>& line);
63 
64 
65 # ifndef MLN_INCLUDE_ONLY
66 
67 
68  template <typename I, typename L>
69  mln_ch_value(I,value::rgb8)
70  line_info_image(const Image<I>& input, const line_set<L>& line)
71  {
72  mln_trace("scribo::debug::line_info_image");
73 
74  mln_ch_value(I,value::rgb8) output = data::convert(value::rgb8(), input);
75 
76  for_all_lines(l, line)
77  {
78  if (! line(l).is_textline())
79  continue;
80 
81  // Bounding box.
82  mln::draw::box(output, line(l).bbox(), literal::green);
83 
84  // baseline
85  mln::draw::line(output,
86  point2d(line(l).baseline(),
87  line(l).bbox().pmin().col()),
88  point2d(line(l).baseline(),
89  line(l).bbox().pmax().col()),
90  literal::red);
91 
92  // baseline
93  mln::draw::line(output,
94  point2d(line(l).meanline(),
95  line(l).bbox().pmin().col()),
96  point2d(line(l).meanline(),
97  line(l).bbox().pmax().col()),
98  literal::cyan);
99 
100  // Ascent
101  mln::draw::line(output,
102  point2d(line(l).baseline() - line(l).a_height() + 1,
103  line(l).bbox().pmin().col()),
104  point2d(line(l).baseline() - line(l).a_height() + 1,
105  line(l).bbox().pmax().col()),
106  literal::violet);
107 
108  // Descent
109  mln::draw::line(output,
110  point2d(line(l).baseline() - line(l).d_height() + 1,
111  line(l).bbox().pmin().col()),
112  point2d(line(l).baseline() - line(l).d_height() + 1,
113  line(l).bbox().pmax().col()),
114  literal::orange);
115  }
116 
117  return output;
118  }
119 
120 
121 # endif // ! MLN_INCLUDE_ONLY
122 
123  } // end of namespace scribo::debug
124 
125 } // end of namespace scribo
126 
127 #endif // ! SCRIBO_DEBUG_LINE_INFO_IMAGE_HH