$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends 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  mln_trace("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  return output;
98  }
99 
100 
101  template <typename I, typename N>
102  inline
103  mln_concrete(I)
104  top_hat_black(const Image<I>& input, const Neighborhood<N>& nbh)
105  {
106  mln_trace("morpho::elementary::top_hat_black");
107 
108  mln_precondition(exact(input).is_valid());
109  mln_precondition(exact(nbh).is_valid());
110 
111  mln_concrete(I) output = morpho::minus(elementary::closing(input, nbh),
112  input);
113 
114  mln_postcondition(test::positive(output));
115 
116  return output;
117  }
118 
119 
120  template <typename I, typename N>
121  inline
122  mln_concrete(I)
123  top_hat_self_complementary(const Image<I>& input, const Neighborhood<N>& nbh)
124  {
125  mln_trace("morpho::elementary::top_hat_self_complementary");
126  mln_precondition(exact(input).is_valid());
127  mln_precondition(exact(nbh).is_valid());
128 
129  mln_concrete(I) output = morpho::minus(elementary::closing(input, nbh),
130  elementary::opening(input, nbh));
131 
132  mln_postcondition(test::positive(output));
133  // mln_postcondition(output == white + black);
134 
135  return output;
136  }
137 
138 
139 # endif // ! MLN_INCLUDE_ONLY
140 
141  } // end of namespace mln::morpho::elementary
142 
143  } // end of namespace mln::morpho
144 
145 } // end of namespace mln
146 
147 
148 #endif // ! MLN_MORPHO_ELEMENTARY_TOP_HAT_HH