Milena (Olena)  User documentation 2.0a Id
 All Classes Namespaces Functions Variables Typedefs Enumerator Groups Pages
debug/superpose.hh
1 // Copyright (C) 2009 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 MLN_DEBUG_SUPERPOSE_HH
27 # define MLN_DEBUG_SUPERPOSE_HH
28 
32 
33 # include <mln/core/concept/image.hh>
34 # include <mln/core/image/dmorph/image_if.hh>
35 # include <mln/value/concept/scalar.hh>
36 # include <mln/value/concept/symbolic.hh>
37 # include <mln/value/rgb8.hh>
38 # include <mln/data/fill.hh>
39 # include <mln/data/convert.hh>
40 # include <mln/pw/all.hh>
41 # include <mln/literal/colors.hh>
42 
43 namespace mln
44 {
45 
46  namespace debug
47  {
48 
63  //
64  template <typename I, typename J>
65  mln_ch_value(I,value::rgb8)
66  superpose(const Image<I>& input_, const Image<J>& object_,
67  const value::rgb8& object_color);
68 
70  template <typename I, typename J>
71  mln_ch_value(I,value::rgb8)
72  superpose(const Image<I>& input, const Image<J>& object);
73 
74 
75 # ifndef MLN_INCLUDE_ONLY
76 
77  template <typename I, typename J>
78  mln_ch_value(I,value::rgb8)
79  superpose(const Image<I>& input_, const Image<J>& object_,
80  const value::rgb8& object_color)
81  {
82  trace::entering("debug::superpose");
83 
84  const I& input = exact(input_);
85  const J& object = exact(object_);
86 
87  //FIXME: Allow symbolic values may not be correct...
88  mlc_or(mlc_or(mlc_is_a(mln_value(J), value::Scalar),
89  mlc_is(mln_value(J), bool)),
90  mlc_is_a(mln_value(J), value::Symbolic))::check();
91 
92  mln_precondition(input.is_valid());
93  mln_precondition(object.is_valid());
94  mln_precondition(input.domain() == object.domain());
95 
96  mln_ch_value(I,value::rgb8) output = data::convert(value::rgb8(), input);
97  data::fill((output | (pw::value(object) != pw::cst(literal::zero))).rw(),
98  object_color);
99 
100  trace::exiting("debug::superpose");
101  return output;
102  }
103 
104  template <typename I, typename J>
105  mln_ch_value(I,value::rgb8)
106  superpose(const Image<I>& input, const Image<J>& object)
107  {
108  return superpose(input, object, literal::red);
109  }
110 
111 # endif // ! MLN_INCLUDE_ONLY
112 
113  } // end of namespace mln::debug
114 
115 } // end of namespace mln
116 
117 #endif // ! MLN_DEBUG_SUPERPOSE_HH