$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
save_comp_diff.hh
1 // Copyright (C) 2009, 2010, 2011 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_COMP_DIFF_HH
28 # define SCRIBO_DEBUG_SAVE_COMP_DIFF_HH
29 
33 
34 # include <mln/core/image/image2d.hh>
35 # include <mln/core/concept/image.hh>
36 # include <mln/data/fill.hh>
37 # include <mln/labeling/colorize.hh>
38 # include <mln/value/rgb8.hh>
39 # include <mln/io/ppm/save.hh>
40 # include <mln/literal/black.hh>
41 # include <mln/literal/colors.hh>
42 # include <mln/pw/all.hh>
43 # include <mln/core/image/dmorph/image_if.hh>
44 
45 # include <scribo/core/macros.hh>
46 # include <scribo/core/component_set.hh>
47 
48 namespace scribo
49 {
50 
51  namespace debug
52  {
53 
54  using namespace mln;
55 
64  template <typename L, typename L2>
65  void
66  save_comp_diff(const component_set<L>& comps_ref,
67  const component_set<L2>& comps_new,
68  const std::string& filename);
69 
70 
71 # ifndef MLN_INCLUDE_ONLY
72 
73 
74  template <typename L, typename L2>
75  void
76  save_comp_diff(const component_set<L>& comps_ref,
77  const component_set<L2>& comps_new,
78  const std::string& filename)
79  {
80  mln_trace("scribo::debug::save_comp_diff");
81 
82  image2d<value::rgb8> output;
83  initialize(output, comps_ref.labeled_image());
84 
85  data::fill(output, literal::black);
86 
87  for_all_comps(i, comps_ref)
88  data::fill(((output | comps_ref(i).bbox()).rw()
89  | (pw::value(comps_ref.labeled_image()) == i)).rw(),
90  literal::red);
91 
92  for_all_comps(i, comps_new)
93  data::fill(((output | comps_new(i).bbox()).rw()
94  | (pw::value(comps_new.labeled_image()) == i)).rw(),
95  literal::green);
96 
97  io::ppm::save(output, filename);
98 
99  }
100 
101 
102 # endif // ! MLN_INCLUDE_ONLY
103 
104 
105  } // end of namespace scribo::debug
106 
107 } // end of namespace scribo
108 
109 #endif // ! SCRIBO_DEBUG_SAVE_COMP_DIFF_HH