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