$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
bboxes_enlarged_image.hh
1 // Copyright (C) 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_BBOXES_ENLARGED_IMAGE_HH
28 # define SCRIBO_DEBUG_BBOXES_ENLARGED_IMAGE_HH
29 
33 
34 
35 # include <mln/core/concept/image.hh>
36 # include <mln/data/convert.hh>
37 # include <mln/value/rgb8.hh>
38 # include <mln/literal/colors.hh>
39 # include <mln/draw/box.hh>
40 
41 # include <scribo/core/line_set.hh>
42 
43 # include <scribo/text/look_like_text_lines.hh>
44 
45 
46 namespace scribo
47 {
48 
49  namespace debug
50  {
51 
52  using namespace mln;
53 
54 
76  //
77  template <typename I, typename L>
78  mln_ch_value(I,value::rgb8)
79  bboxes_enlarged_image(const Image<I>& input,
80  const line_set<L>& lines,
81  const value::rgb8& text_value,
82  const value::rgb8& non_text_value);
83 
89  //
90  template <typename I, typename L>
91  mln_ch_value(I,value::rgb8)
92  bboxes_enlarged_image(const Image<I>& input,
93  const line_set<L>& lines);
94 
95 
96 # ifndef MLN_INCLUDE_ONLY
97 
98 
99  template <typename I, typename L>
100  mln_ch_value(I,value::rgb8)
101  bboxes_enlarged_image(const Image<I>& input,
102  const line_set<L>& lines,
103  const value::rgb8& text_value,
104  const value::rgb8& non_text_value)
105  {
106  mln_trace("scribo::debug::bboxes_enlarged_image");
107  mln_precondition(exact(input).is_valid());
108 
109  mln_ch_value(I,value::rgb8) output = data::convert(value::rgb8(), input);
110 
111  for_all_lines(l, lines)
112  if (! lines(l).is_hidden())
113  {
114  if (text::internal::looks_like_a_text_line(lines(l)))
115  mln::draw::box(output, lines(l).ebbox(), text_value);
116  else
117  mln::draw::box(output, lines(l).bbox(), non_text_value);
118  }
119 
120  return output;
121  }
122 
123 
124  template <typename I, typename L>
125  mln_ch_value(I,value::rgb8)
126  bboxes_enlarged_image(const Image<I>& input,
127  const line_set<L>& lines)
128  {
129  return bboxes_enlarged_image(input, lines,
130  literal::green, literal::red);
131  }
132 
133 # endif // ! MLN_INCLUDE_ONLY
134 
135  } // end of namespace scribo::debug
136 
137 } // end of namespace scribo
138 
139 
140 #endif // ! SCRIBO_DEBUG_BBOXES_ENLARGED_IMAGE_HH