Milena (Olena)  User documentation 2.0a Id
 All Classes Namespaces Functions Variables Typedefs Enumerator Groups Pages
lap.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_LINEAR_LAP_HH
27 # define MLN_LINEAR_LAP_HH
28 
34 # include <mln/linear/convolve.hh>
35 # include <mln/make/w_window2d.hh>
36 
37 
38 
39 namespace mln
40 {
41 
42  namespace linear
43  {
44 
45  // FIXME: Doc!
46 
47  template <typename I>
48  mln_ch_convolve(I, int)
49  lap_4(const Image<I>& input);
50 
51  template <typename I>
52  mln_ch_convolve(I, int)
53  lap_8(const Image<I>& input);
54 
55  template <typename I>
56  mln_ch_convolve(I, int)
57  lap_x(const Image<I>& input);
58 
59  template <typename I>
60  mln_ch_convolve(I, int)
61  lap_o(const Image<I>& input);
62 
63 
64 # ifndef MLN_INCLUDE_ONLY
65 
66  // Laplacian operators (Cf. Sonka et al., p. 81)
67 
68  template <typename I>
69  inline
71  lap_4(const Image<I>& input)
72  {
73  trace::entering("linear::lap_4");
74  mln_precondition(exact(input).is_valid());
75  int ws[] = { 0, 1, 0,
76  1, -4, 1,
77  0, 1, 0 };
78  mln_ch_convolve(I, int) output = convolve(input, make::w_window2d(ws));
79  trace::exiting("linear::lap_4");
80  return output;
81  }
82 
83  template <typename I>
84  inline
85  mln_ch_convolve(I, int)
86  lap_8(const Image<I>& input)
87  {
88  trace::entering("linear::lap_8");
89  mln_precondition(exact(input).is_valid());
90  int ws[] = { 1, 1, 1,
91  1, -8, 1,
92  1, 1, 1 };
93  mln_ch_convolve(I, int) output = convolve(input, make::w_window2d(ws));
94  trace::exiting("linear::lap_8");
95  return output;
96  }
97 
98  template <typename I>
99  inline
100  mln_ch_convolve(I, int)
101  lap_x(const Image<I>& input)
102  {
103  trace::entering("linear::lap_x");
104  mln_precondition(exact(input).is_valid());
105  int ws[] = { +2, -1, +2,
106  -1, -4, -1,
107  +2, -1, +2 };
108  mln_ch_convolve(I, int) output = convolve(input, make::w_window2d(ws));
109  trace::exiting("linear::lap_x");
110  return output;
111  }
112 
113  template <typename I>
114  inline
115  mln_ch_convolve(I, int)
116  lap_o(const Image<I>& input)
117  {
118  trace::entering("linear::lap_o");
119  mln_precondition(exact(input).is_valid());
120  int ws[] = { -1, +2, -1,
121  +2, -4, +2,
122  -1, +2, -1 };
123  mln_ch_convolve(I, int) output = convolve(input, make::w_window2d(ws));
124  trace::exiting("linear::lap_o");
125  return output;
126  }
127 
128 # endif // ! MLN_INCLUDE_ONLY
129 
130  } // end of namespace mln::linear
131 
132 } // end of namespace mln
133 
134 
135 #endif // ! MLN_LINEAR_LAP_HH