$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
save_table_image.hh
1 // Copyright (C) 2009, 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_SAVE_TABLE_IMAGE_HH
28 # define SCRIBO_DEBUG_SAVE_TABLE_IMAGE_HH
29 
33 
34 # include <string>
35 
36 # include <mln/core/concept/image.hh>
37 # include <mln/core/image/image2d.hh>
38 # include <mln/data/fill.hh>
39 # include <mln/data/convert.hh>
40 # include <mln/util/array.hh>
41 # include <mln/util/couple.hh>
42 # include <mln/value/rgb8.hh>
43 # include <mln/io/ppm/save.hh>
44 
45 # include <scribo/draw/bounding_boxes.hh>
46 
47 namespace scribo
48 {
49 
50  namespace debug
51  {
52 
53  using namespace mln;
54 
59  //
60  template <typename I>
61  void
62  save_table_image(const Image<I>& input_,
63  mln::util::couple<mln::util::array<box<mln_site(I)> >,
64  mln::util::array<box<mln_site(I)> > > tableboxes,
65  const value::rgb8& bbox_color,
66  const std::string& filename);
67 
73  //
74  template <typename S>
75  void
76  save_table_image(const Site_Set<S>& input_domain,
77  mln::util::couple<mln::util::array<box<mln_site(S)> >,
78  mln::util::array<box<mln_site(S)> > > tableboxes,
79  const value::rgb8& bg_color,
80  const value::rgb8& bbox_color,
81  const std::string& filename);
82 
83 
84 # ifndef MLN_INCLUDE_ONLY
85 
86 
87  template <typename I>
88  void
89  save_table_image(const Image<I>& input_,
90  mln::util::couple<mln::util::array<box<mln_site(I)> >,
91  mln::util::array<box<mln_site(I)> > > tableboxes,
92  const value::rgb8& bbox_color,
93  const std::string& filename)
94  {
95  mln_trace("scribo::debug::save_table_image");
96 // mlc_converts_to(mln_value(I), value::rgb8)::check();
97  const I& input = exact(input_);
98  mln_precondition(input.is_valid());
99 
100  mln_ch_value(I, value::rgb8) out2 = data::convert(value::rgb8(), input);
101  draw::bounding_boxes(out2, tableboxes.first(), bbox_color);
102  draw::bounding_boxes(out2, tableboxes.second(), bbox_color);
103  io::ppm::save(out2, filename);
104 
105  }
106 
107 
108  template <typename S>
109  void
110  save_table_image(const Site_Set<S>& input_domain_,
111  mln::util::couple<mln::util::array<box<mln_site(S)> >,
112  mln::util::array<box<mln_site(S)> > > tableboxes,
113  const value::rgb8& bg_color,
114  const value::rgb8& bbox_color,
115  const std::string& filename)
116  {
117  mln_trace("scribo::debug::save_table_image");
118  const S& input_domain = exact(input_domain_);
119  mln_precondition(input_domain.is_valid());
120 
121  image2d<value::rgb8> out2(input_domain);
122  data::fill(out2, bg_color);
123  draw::bounding_boxes(out2, tableboxes.first(), bbox_color);
124  draw::bounding_boxes(out2, tableboxes.second(), bbox_color);
125  io::ppm::save(out2, filename);
126 
127  }
128 
129 # endif // ! MLN_INCLUDE_ONLY
130 
131  } // end of namespace scribo::debug
132 
133 } // end of namespace scribo
134 
135 
136 #endif // ! SCRIBO_DEBUG_SAVE_TABLE_IMAGE_HH