Milena (Olena)  User documentation 2.0a Id
 All Classes Namespaces Functions Variables Typedefs Enumerator Groups Pages
gaussian_1d.hh
1 // Copyright (C) 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_1D_HH
27 # define MLN_LINEAR_GAUSSIAN_1D_HH
28 
34 
35 #include <mln/core/image/image1d.hh>
36 #include <mln/linear/gaussian_directional_2d.hh>
37 
38 
39 
40 namespace mln
41 {
42 
43  namespace linear
44  {
45 
46 
47  template <typename I>
48  mln_concrete(I)
49  gaussian_1d(const Image<I>& input,
50  double sigma,
51  const mln_value(I)& bdr);
52 
53 
54 
55 # ifndef MLN_INCLUDE_ONLY
56 
57  template <typename I>
58  inline
59  mln_concrete(I)
60  gaussian_1d(const Image<I>& input_,
61  double sigma,
62  const mln_value(I)& bdr)
63  {
64  trace::entering("linear::gaussian_1d");
65 
66  typedef mln_site(I) P;
67  mlc_bool(P::dim == 1)::check();
68 
69  const I& input = exact(input_);
70  mln_precondition(input.is_valid());
71 
72  my::recursivefilter_coef_ coef(1.68f, 3.735f,
73  1.783f, 1.723f,
74  -0.6803f, -0.2598f,
75  0.6318f, 1.997f,
76  sigma,
77  my::recursivefilter_coef_::DericheGaussian);
78 
79  extension::adjust_fill(input, 5 * int(sigma + .50001) + 1, bdr);
80  mln_concrete(I) output = duplicate(input);
81 
82  if (sigma < 0.006)
83  return output;
84 
85  int
86  ninds = geom::ninds(input),
87  b = input.border();
88 
89  recursivefilter_directional_fastest(output, coef,
90  point1d(- b),
91  point1d(ninds - 1 + b),
92  ninds + 2 * b,
93  dpoint1d(1),
94  bdr);
95 
96  trace::exiting("linear::gaussian_1d");
97  return output;
98  }
99 
100 # endif // ! MLN_INCLUDE_ONLY
101 
102  } // end of namespace mln::linear
103 
104 } // end of namespace mln
105 
106 
107 #endif // ! MLN_LINEAR_GAUSSIAN_1D_HH