$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
morpho/watershed/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_MORPHO_WATERSHED_SUPERPOSE_HH
27 # define MLN_MORPHO_WATERSHED_SUPERPOSE_HH
28 
32 
33 # include <mln/core/concept/image.hh>
34 # include <mln/core/image/dmorph/image_if.hh>
35 # include <mln/data/convert.hh>
36 # include <mln/data/fill.hh>
37 # include <mln/value/rgb8.hh>
38 # include <mln/literal/colors.hh>
39 # include <mln/pw/all.hh>
40 
41 
42 
43 namespace mln
44 {
45 
46  namespace morpho
47  {
48 
49  namespace watershed
50  {
51 
53  /*
54  ** \param[in] input_ An image.
55  ** \param[in] ws_ima_ The watershed transform of \p input_.
56  ** \param[in] wsl_color The color used for the watershed line.
57  */
58  template <typename I, typename J>
59  inline
60  mln_ch_value(I,value::rgb8)
61  superpose(const Image<I>& input_,
62  const Image<J>& ws_ima_,
63  const value::rgb8& wsl_color);
64 
65 
67  /*
68  ** \param[in] input_ An image.
69  ** \param[in] ws_ima_ The watershed transform of \p input_.
70  **
71  ** The watershed line is drawn in red.
72  */
73  template <typename I, typename J>
74  inline
75  mln_ch_value(I,value::rgb8)
76  superpose(const Image<I>& input,
77  const Image<J>& ws_ima);
78 
79 
80 # ifndef MLN_INCLUDE_ONLY
81 
82  template <typename I, typename J>
83  inline
84  mln_ch_value(I,value::rgb8)
85  superpose(const Image<I>& input_,
86  const Image<J>& ws_ima_,
87  const value::rgb8& wsl_color)
88  {
89  mln_trace("morpho::watershed::superpose");
90 
91  const I& input = exact(input_);
92  const J& ws_ima = exact(ws_ima_);
93  mln_precondition(input.is_valid());
94  mln_precondition(ws_ima.is_valid());
95 
96  mln_ch_value(I,value::rgb8) output = data::convert(value::rgb8(), input);
97 
98  data::fill((output | (pw::value(ws_ima) == pw::cst(literal::zero))).rw(),
99  wsl_color);
100 
101  return output;
102  }
103 
104 
105  template <typename I, typename J>
106  inline
107  mln_ch_value(I,value::rgb8)
108  superpose(const Image<I>& input,
109  const Image<J>& ws_ima)
110  {
111  return superpose(input, ws_ima, literal::red);
112  }
113 
114 # endif // ! MLN_INCLUDE_ONLY
115 
116 
117  } // end of namespace mln::morpho::watershed
118 
119  } // end of namespace mln::morpho
120 
121 } // end of namespace mln
122 
123 #endif // ! MLN_MORPHO_WATERSHED_SUPERPOSE_HH