Milena (Olena)  User documentation 2.0a Id
 All Classes Namespaces Functions Variables Typedefs Enumerator Groups Pages
top_hat.hh
1 // Copyright (C) 2007, 2008, 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_TOP_HAT_HH
27 # define MLN_MORPHO_TOP_HAT_HH
28 
34 
35 # include <mln/morpho/opening/structural.hh>
36 # include <mln/morpho/closing/structural.hh>
37 
38 
39 namespace mln
40 {
41 
42  namespace morpho
43  {
44 
45 
49  //
50  template <typename I, typename W>
51  mln_concrete(I)
52  top_hat_white(const Image<I>& input, const Window<W>& win);
53 
54 
58  //
59  template <typename I, typename W>
60  mln_concrete(I)
61  top_hat_black(const Image<I>& input, const Window<W>& win);
62 
63 
70  //
71  template <typename I, typename W>
72  mln_concrete(I)
73  top_hat_self_complementary(const Image<I>& input, const Window<W>& win);
74 
75 
76 
77 # ifndef MLN_INCLUDE_ONLY
78 
79 
80  template <typename I, typename W>
81  inline
82  mln_concrete(I)
83  top_hat_white(const Image<I>& input, const Window<W>& win)
84  {
85  trace::entering("morpho::top_hat_white");
86 
87  mln_precondition(exact(input).is_valid());
88  mln_precondition(! exact(win).is_empty());
89 
90  mln_concrete(I) output = morpho::minus(input,
91  opening::structural(input, win));
92 
93  mln_postcondition(test::positive(output));
94 
95  trace::exiting("morpho::top_hat_white");
96  return output;
97  }
98 
99 
100  template <typename I, typename W>
101  inline
102  mln_concrete(I) top_hat_black(const Image<I>& input, const Window<W>& win)
103  {
104  trace::entering("morpho::top_hat_black");
105 
106  mln_precondition(exact(input).is_valid());
107  mln_precondition(! exact(win).is_empty());
108 
109  mln_concrete(I) output = morpho::minus(closing::structural(input, win),
110  input);
111 
112  mln_postcondition(test::positive(output));
113 
114  trace::exiting("morpho::top_hat_black");
115  return output;
116  }
117 
118 
119  template <typename I, typename W>
120  inline
121  mln_concrete(I) top_hat_self_complementary(const Image<I>& input, const Window<W>& win)
122  {
123  trace::entering("morpho::top_hat_self_complementary");
124 
125  mln_precondition(exact(input).is_valid());
126  mln_precondition(! exact(win).is_empty());
127 
128  mln_concrete(I) output = morpho::minus(closing::structural(input, win),
129  opening::structural(input, win));
130 
131  mln_postcondition(test::positive(output));
132 
133  trace::exiting("morpho::top_hat_self_complementary");
134  return output;
135  }
136 
137 
138 # endif // ! MLN_INCLUDE_ONLY
139 
140  } // end of namespace mln::morpho
141 
142 } // end of namespace mln
143 
144 
145 #endif // ! MLN_MORPHO_TOP_HAT_HH