$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
gaussian_1d.hh
1 // Copyright (C) 2009, 2012 EPITA Research and Development Laboratory
2 // (LRDE)
3 //
4 // This file is part of Olena.
5 //
6 // Olena is free software: you can redistribute it and/or modify it under
7 // the terms of the GNU General Public License as published by the Free
8 // Software Foundation, version 2 of the License.
9 //
10 // Olena is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with Olena. If not, see <http://www.gnu.org/licenses/>.
17 //
18 // As a special exception, you may use this file as part of a free
19 // software project without restriction. Specifically, if other files
20 // instantiate templates or use macros or inline functions from this
21 // file, or you compile this file and link it with other files to produce
22 // an executable, this file does not by itself cause the resulting
23 // executable to be covered by the GNU General Public License. This
24 // exception does not however invalidate any other reasons why the
25 // executable file might be covered by the GNU General Public License.
26 
27 #ifndef MLN_LINEAR_GAUSSIAN_1D_HH
28 # define MLN_LINEAR_GAUSSIAN_1D_HH
29 
35 
36 #include <mln/core/image/image1d.hh>
37 #include <mln/linear/gaussian_directional_2d.hh>
38 
39 
40 
41 namespace mln
42 {
43 
44  namespace linear
45  {
46 
50  template <typename I>
51  mln_concrete(I)
52  gaussian_1d(const Image<I>& input,
53  double sigma,
54  const mln_value(I)& bdr);
55 
56 
57 
58 # ifndef MLN_INCLUDE_ONLY
59 
60  template <typename I>
61  inline
62  mln_concrete(I)
63  gaussian_1d(const Image<I>& input_,
64  double sigma,
65  const mln_value(I)& bdr)
66  {
67  mln_trace("linear::gaussian_1d");
68 
69  typedef mln_site(I) P;
70  mlc_bool(P::dim == 1)::check();
71 
72  const I& input = exact(input_);
73  mln_precondition(input.is_valid());
74 
75  my::recursivefilter_coef_ coef(1.68f, 3.735f,
76  1.783f, 1.723f,
77  -0.6803f, -0.2598f,
78  0.6318f, 1.997f,
79  sigma,
80  my::recursivefilter_coef_::DericheGaussian);
81 
82  extension::adjust_fill(input, 5 * int(sigma + .50001) + 1, bdr);
83  mln_concrete(I) output = duplicate(input);
84 
85  if (sigma < 0.006)
86  return output;
87 
88  int
89  ninds = geom::ninds(input),
90  b = input.border();
91 
92  recursivefilter_directional_fastest(output, coef,
93  point1d(- b),
94  point1d(ninds - 1 + b),
95  ninds + 2 * b,
96  dpoint1d(1),
97  bdr);
98 
99  return output;
100  }
101 
102 # endif // ! MLN_INCLUDE_ONLY
103 
104  } // end of namespace mln::linear
105 
106 } // end of namespace mln
107 
108 
109 #endif // ! MLN_LINEAR_GAUSSIAN_1D_HH