$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
text_color_image.hh
1 // Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
2 //
3 // This file is part of Olena.
4 //
5 // Olena is free software: you can redistribute it and/or modify it under
6 // the terms of the GNU General Public License as published by the Free
7 // Software Foundation, version 2 of the License.
8 //
9 // Olena is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with Olena. If not, see <http://www.gnu.org/licenses/>.
16 //
17 // As a special exception, you may use this file as part of a free
18 // software project without restriction. Specifically, if other files
19 // instantiate templates or use macros or inline functions from this
20 // file, or you compile this file and link it with other files to produce
21 // an executable, this file does not by itself cause the resulting
22 // executable to be covered by the GNU General Public License. This
23 // exception does not however invalidate any other reasons why the
24 // executable file might be covered by the GNU General Public License.
25 
26 #ifndef SCRIBO_DEBUG_TEXT_COLOR_IMAGE_HH
27 # define SCRIBO_DEBUG_TEXT_COLOR_IMAGE_HH
28 
32 
33 # include <mln/core/image/image2d.hh>
34 # include <mln/value/rgb8.hh>
35 # include <mln/data/fill.hh>
36 # include <mln/literal/white.hh>
37 # include <mln/util/array.hh>
38 
39 # include <mln/pw/all.hh>
40 # include <mln/core/image/dmorph/image_if.hh>
41 
42 # include <scribo/core/macros.hh>
43 # include <scribo/core/document.hh>
44 
45 namespace scribo
46 {
47 
48  namespace debug
49  {
50  using namespace mln;
51 
56  template <typename L>
58  text_color_image(const document<L>& doc);
59 
60 
61 # ifndef MLN_INCLUDE_ONLY
62 
63  template <typename L>
65  text_color_image(const document<L>& doc)
66  {
68  initialize(debug, doc.binary_image());
69  data::fill(debug, literal::white);
70 
71  const paragraph_set<L>& parset = doc.paragraphs();
72  const line_set<L>& lines = doc.lines();
73  const component_set<L>& comp_set = lines.components();
74  const L& lbl = comp_set.labeled_image();
75 
76  for_all_paragraphs(p, parset)
77  {
78  const mln::util::array<line_id_t>& line_ids = parset(p).line_ids();
79 
80  for_all_paragraph_lines(lid, line_ids)
81  {
82  line_id_t l = line_ids(lid);
83  const mln::util::array<component_id_t>& comps = lines(l).component_ids();
84 
85  for_all_elements(e, comps)
86  {
87  unsigned comp_id = comps(e);
88  data::fill(((debug | comp_set(comp_id).bbox()).rw() | (pw::value(lbl) == pw::cst(comp_id))).rw(),
89  parset(p).color());
90  }
91 
92  }
93  }
94 
95  return debug;
96  }
97 
98 # endif // ! MLN_INCLUDE_ONLY
99 
100  } // end of namespace scribo::debug
101 
102 } // end of namespace scribo
103 
104 #endif // ! SCRIBO_DEBUG_TEXT_COLOR_IMAGE_HH