$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
elementary/erosion.hh
1 // Copyright (C) 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_EROSION_HH
27 # define MLN_MORPHO_ELEMENTARY_EROSION_HH
28 
30 
31 # include <mln/morpho/elementary/like_ero_fun.hh>
32 # include <mln/morpho/elementary/like_ero_set.hh>
33 
34 
35 namespace mln
36 {
37 
38  namespace morpho
39  {
40 
41  namespace elementary
42  {
43 
44 
45  template <typename I, typename N>
46  mln_concrete(I)
47  erosion(const Image<I>& input, const Neighborhood<N>& nbh);
48 
49 
50 # ifndef MLN_INCLUDE_ONLY
51 
52  namespace internal
53  {
54 
55  // Dispatch.
56 
57  template <typename I, typename N>
58  mln_concrete(I)
59  erosion_dispatch(trait::image::kind::any,
60  const Image<I>& input, const Neighborhood<N>& nbh)
61  {
62  return like_ero_fun(accu::meta::stat::min(), f_accu(), input, nbh);
63  }
64 
65  template <typename I, typename N>
66  mln_concrete(I)
67  erosion_dispatch(trait::image::kind::logic,
68  const Image<I>& input, const Neighborhood<N>& nbh)
69  {
70  bool val[] =
71  {
72  1, // ext_value
73  1, // do_duplicate
74  1, // on_input_p
75  0, // on_input_n
76  0, // output_p
77  };
78  return like_ero_set(val, input, nbh);
79  }
80 
81  template <typename I, typename N>
82  mln_concrete(I)
83  erosion_dispatch(const Image<I>& input, const Neighborhood<N>& nbh)
84  {
85  return erosion_dispatch(mln_trait_image_kind(I)(),
86  input, nbh);
87  }
88 
89  } // end of namespace mln::morpho::elementary::internal
90 
91 
92  // Facade.
93 
94  template <typename I, typename N>
95  mln_concrete(I)
96  erosion(const Image<I>& input, const Neighborhood<N>& nbh)
97  {
98  mln_trace("morpho::elementary::erosion");
99 
100  mln_precondition(exact(input).is_valid());
101  mln_precondition(exact(nbh).is_valid());
102 
103  mln_concrete(I) output = internal::erosion_dispatch(input, nbh);
104 
105  mln_postcondition(output <= input);
106  return output;
107  }
108 
109 # endif // ! MLN_INCLUDE_ONLY
110 
111  } // end of namespace mln::morpho::elementary
112 
113  } // end of namespace mln::morpho
114 
115 } // end of namespace mln
116 
117 
118 #endif // ! MLN_MORPHO_ELEMENTARY_EROSION_HH