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