Milena (Olena)  User documentation 2.0a Id
 All Classes Namespaces Functions Variables Typedefs Enumerator Groups Pages
linear/gaussian/filter.hh
1 // Copyright (C) 2001, 2002, 2003, 2004, 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_LINEAR_GAUSSIAN_FILTER_HH
27 # define MLN_LINEAR_GAUSSIAN_FILTER_HH
28 
35 
36 # include <mln/core/concept/image.hh>
37 # include <mln/linear/gaussian/impl.hh>
38 # include <mln/linear/gaussian/internal/coefficients.hh>
39 
40 
41 namespace mln
42 {
43 
44  namespace linear
45  {
46 
47  namespace gaussian
48  {
49 
54  template <typename I>
55  mln_concrete(I)
56  filter(const Image<I>& input, double sigma);
57 
58 
59  template <typename I>
60  mln_concrete(I)
61  filter(const Image<I>& input, double sigma, int dir);
62 
63 
64 
65 # ifndef MLN_INCLUDE_ONLY
66 
67 
68  // Facades.
69 
79  template <typename I>
80  inline
81  mln_concrete(I)
82  filter(const Image<I>& input, double sigma, int dir)
83  {
84  trace::entering("linear::gaussian::filter");
85 
86  mln_precondition(exact(input).is_valid());
87  mln_precondition(dir < I::site::dim);
88 
89  mln_concrete(I) output;
90  initialize(output, input);
91 
92  internal::coefficients coef = internal::coefficients_not_derivative(sigma);
93 
94  impl::generic_filter_common_(mln_trait_value_nature(mln_value(I))(),
95  input, coef, sigma, output, dir);
96 
97  trace::exiting("linear::gaussian::filter");
98  return output;
99  }
100 
101 
102 
103 
109  template <typename I>
110  inline
111  mln_concrete(I)
112  filter(const Image<I>& input, double sigma)
113  {
114  trace::entering("linear::gaussian::filter");
115 
116  mln_precondition(exact(input).is_valid());
117 
118  mln_concrete(I) output;
119  initialize(output, input);
120 
121  internal::coefficients coef = internal::coefficients_not_derivative(sigma);
122 
123  impl::generic_filter_common_(mln_trait_value_nature(mln_value(I))(),
124  input, coef, sigma, output);
125 
126  trace::exiting("linear::gaussian::filter");
127  return output;
128  }
129 
130 
131 # endif // ! MLN_INCLUDE_ONLY
132 
133  } // end of namespace mln::linear::gaussian
134 
135  } // end of namespace mln::linear
136 
137 } // end of namespace mln
138 
139 
140 #endif // ! MLN_LINEAR_GAUSSIAN_FILTER_HH