$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
log.hh
1 // Copyright (C) 2007, 2008, 2009, 2012, 2013 EPITA Research and
2 // Development 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_LOG_HH
28 # define MLN_LINEAR_LOG_HH
29 
34 
35 
36 # include <mln/linear/convolve.hh>
37 # include <mln/make/w_window2d.hh>
38 
39 
40 
41 namespace mln
42 {
43 
44  namespace linear
45  {
46 
54  template <typename I>
55  mln_ch_convolve(I, int)
56  LoG_5x5(const Image<I>& input);
57 
64  template <typename I>
65  mln_ch_convolve(I, int)
66  LoG_7x7(const Image<I>& input);
67 
74  template <typename I>
75  mln_ch_convolve(I, int)
76  LoG_13x13(const Image<I>& input);
77 
84  template <typename I>
85  mln_ch_convolve(I, int)
86  LoG_17x17(const Image<I>& input);
87 
88 # ifndef MLN_INCLUDE_ONLY
89 
90  // LoG_5x5 (Cf. Sonka et al., pages 85-86)
91  // This is also a "mexican hat".
92 
93  template <typename I>
94  inline
95  mln_ch_convolve(I, int)
96  LoG_5x5(const Image<I>& input)
97  {
98  mln_trace("linear::LoG_5x5");
99  mln_precondition(exact(input).is_valid());
100  int ws[] = { +0, 0, -1, 0, 0,
101  +0, -1, -2, -1, 0,
102  -1, -2, 16, -2, -1,
103  +0, -1, -2, -1, 0,
104  +0, 0, -1, 0, 0 };
105  mln_ch_convolve(I, int) output = convolve(input, make::w_window2d(ws));
106  return output;
107  }
108 
109  // LoG 7x7 (Cf. Russ, p. 250)
110 
111  template <typename I>
112  inline
113  mln_ch_convolve(I, int)
114  LoG_7x7(const Image<I>& input)
115  {
116  mln_trace("linear::LoG_7x7");
117  mln_precondition(exact(input).is_valid());
118  int ws[] = { +0, 0, -1, -1, -1, 0, 0,
119  +0, -1, -3, -3, -3, -1, 0,
120  -1, -3, 0, 7, 0, -3, -1,
121  -1, -3, 7, 24, 7, -3, -1,
122  -1, -3, 0, 7, 0, -3, -1,
123  +0, -1, -3, -3, -3, -1, 0,
124  +0, 0, -1, -1, -1, 0, 0 };
125  mln_ch_convolve(I, int) output = convolve(input, make::w_window2d(ws));
126  return output;
127  }
128 
129  // LoG 13x13 (Cf. Russ, p. 250)
130 
131  template <typename I>
132  inline
133  mln_ch_convolve(I, int)
134  LoG_13x13(const Image<I>& input)
135  {
136  mln_trace("linear::LoG_13x13");
137  mln_precondition(exact(input).is_valid());
138  int ws[] = { +0, 0, 0, 0, 0, -1, -1, -1, 0, 0, 0, 0, 0,
139  +0, 0, 0, -1, -1, -2, -2, -2, -1, -1, 0, 0, 0,
140  +0, 0, -2, -2, -3, -3, -4, -3, -3, -2, -2, 0, 0,
141  +0, -1, -2, -3, -3, -3, -2, -3, -3, -3, -2, -1, 0,
142  +0, -1, -3, -3, -1, 4, 6, 4, -1, -3, -3, -1, 0,
143  -1, -2, -3, -3, 4, 14, 19, 14, 4, -3, -3, -2, -1,
144  -1, -2, -4, -2, 6, 19, 24, 19, 6, -2, -4, -2, -1,
145  -1, -2, -3, -3, 4, 14, 19, 14, 4, -3, -3, -2, -1,
146  +0, -1, -3, -3, -1, 4, 6, 4, -1, -3, -3, -1, 0,
147  +0, -1, -2, -3, -3, -3, -2, -3, -3, -3, -2, -1, 0,
148  +0, 0, -2, -2, -3, -3, -4, -3, -3, -2, -2, 0, 0,
149  +0, 0, 0, -1, -1, -2, -2, -2, -1, -1, 0, 0, 0,
150  +0, 0, 0, 0, 0, -1, -1, -1, 0, 0, 0, 0, 0 };
151  mln_ch_convolve(I, int) output = convolve(input, make::w_window2d(ws));
152  return output;
153  }
154 
155 
156  // LoG 17x17 (Cf. Sonka et al., pages 85-86)
157 
158  template <typename I>
159  inline
160  mln_ch_convolve(I, int)
161  LoG_17x17(const Image<I>& input)
162  {
163  mln_trace("linear::LoG_17x17");
164  mln_precondition(exact(input).is_valid());
165  int ws[] = { +0, 0, 0, 0, 0, 0,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 0,
166  +0, 0, 0, 0,-1,-1,-1,-1,-1,-1,-1,-1,-1, 0, 0, 0, 0,
167  +0, 0,-1,-1,-1,-2,-3,-3,-3,-3,-3,-2,-1,-1,-1, 0, 0,
168  +0, 0,-1,-1,-2,-3,-3,-3,-3,-3,-3,-3,-2,-1,-1, 0, 0,
169  +0,-1,-1,-2,-3,-3,-3,-2,-3,-2,-3,-3,-3,-2,-1,-1, 0,
170  +0,-1,-2,-3,-3,-3, 0, 2, 4, 2, 0,-3,-3,-3,-2,-1, 0,
171  -1,-1,-3,-3,-3, 0, 4,10,12,10, 4, 0,-3,-3,-3,-1,-1,
172  -1,-1,-3,-3,-2, 2,10,18,21,18,10, 2,-2,-3,-3,-1,-1,
173  -1,-1,-3,-3,-3, 4,12,21,24,21,12, 4,-3,-3,-3,-1,-1,
174  -1,-1,-3,-3,-2, 2,10,18,21,18,10, 2,-2,-3,-3,-1,-1,
175  -1,-1,-3,-3,-3, 0, 4,10,12,10, 4, 0,-3,-3,-3,-1,-1,
176  +0,-1,-2,-3,-3,-3, 0, 2, 4, 2, 0,-3,-3,-3,-2,-1, 0,
177  +0,-1,-1,-2,-3,-3,-3,-2,-3,-2,-3,-3,-3,-2,-1,-1, 0,
178  +0, 0,-1,-1,-2,-3,-3,-3,-3,-3,-3,-3,-2,-1,-1, 0, 0,
179  +0, 0,-1,-1,-1,-2,-3,-3,-3,-3,-3,-2,-1,-1,-1, 0, 0,
180  +0, 0, 0, 0,-1,-1,-1,-1,-1,-1,-1,-1,-1, 0, 0, 0, 0,
181  +0, 0, 0, 0, 0, 0,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 0 };
182  mln_ch_convolve(I, int) output = convolve(input, make::w_window2d(ws));
183  return output;
184  }
185 
186 # endif // ! MLN_INCLUDE_ONLY
187 
188  } // end of namespace mln::linear
189 
190 } // end of namespace mln
191 
192 
193 #endif // ! MLN_LINEAR_LOG_HH