Milena (Olena)  User documentation 2.0a Id
 All Classes Namespaces Functions Variables Typedefs Enumerator Groups Pages
elementary/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_ELEMENTARY_TOP_HAT_HH
27 # define MLN_MORPHO_ELEMENTARY_TOP_HAT_HH
28 
34 
35 # include <mln/morpho/elementary/opening.hh>
36 # include <mln/morpho/elementary/closing.hh>
37 # include <mln/morpho/minus.hh>
38 
39 
40 namespace mln
41 {
42 
43  namespace morpho
44  {
45 
46  namespace elementary
47  {
48 
52  //
53  template <typename I, typename N>
54  mln_concrete(I)
55  top_hat_white(const Image<I>& input, const Neighborhood<N>& nbh);
56 
57 
61  //
62  template <typename I, typename N>
63  mln_concrete(I)
64  top_hat_black(const Image<I>& input, const Neighborhood<N>& nbh);
65 
66 
73  //
74  template <typename I, typename N>
75  mln_concrete(I)
76  top_hat_self_complementary(const Image<I>& input, const Neighborhood<N>& nbh);
77 
78 
79 # ifndef MLN_INCLUDE_ONLY
80 
81 
82  template <typename I, typename N>
83  inline
84  mln_concrete(I)
85  top_hat_white(const Image<I>& input, const Neighborhood<N>& nbh)
86  {
87  trace::entering("morpho::elementary::top_hat_white");
88 
89  mln_precondition(exact(input).is_valid());
90  mln_precondition(exact(nbh).is_valid());
91 
92  mln_concrete(I) output = morpho::minus(input,
93  elementary::opening(input, nbh));
94 
95  mln_postcondition(test::positive(output));
96 
97  trace::exiting("morpho::elementary::top_hat_white");
98  return output;
99  }
100 
101 
102  template <typename I, typename N>
103  inline
104  mln_concrete(I)
105  top_hat_black(const Image<I>& input, const Neighborhood<N>& nbh)
106  {
107  trace::entering("morpho::elementary::top_hat_black");
108 
109  mln_precondition(exact(input).is_valid());
110  mln_precondition(exact(nbh).is_valid());
111 
112  mln_concrete(I) output = morpho::minus(elementary::closing(input, nbh),
113  input);
114 
115  mln_postcondition(test::positive(output));
116 
117  trace::exiting("morpho::elementary::top_hat_black");
118  return output;
119  }
120 
121 
122  template <typename I, typename N>
123  inline
124  mln_concrete(I)
125  top_hat_self_complementary(const Image<I>& input, const Neighborhood<N>& nbh)
126  {
127  trace::entering("morpho::elementary::top_hat_self_complementary");
128  mln_precondition(exact(input).is_valid());
129  mln_precondition(exact(nbh).is_valid());
130 
131  mln_concrete(I) output = morpho::minus(elementary::closing(input, nbh),
132  elementary::opening(input, nbh));
133 
134  mln_postcondition(test::positive(output));
135  // mln_postcondition(output == white + black);
136 
137  trace::exiting("morpho::elementary::top_hat_self_complementary");
138  return output;
139  }
140 
141 
142 # endif // ! MLN_INCLUDE_ONLY
143 
144  } // end of namespace mln::morpho::elementary
145 
146  } // end of namespace mln::morpho
147 
148 } // end of namespace mln
149 
150 
151 #endif // ! MLN_MORPHO_ELEMENTARY_TOP_HAT_HH