$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
approx/median.hh
1 // Copyright (C) 2007, 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_DATA_APPROX_MEDIAN_HH
27 # define MLN_DATA_APPROX_MEDIAN_HH
28 
32 
33 # include <mln/data/median.hh>
34 # include <mln/win/rectangle2d.hh>
35 # include <mln/win/disk2d.hh>
36 # include <mln/win/octagon2d.hh>
37 # include <mln/win/hline2d.hh>
38 # include <mln/win/vline2d.hh>
39 # include <mln/win/diag2d.hh>
40 # include <mln/win/backdiag2d.hh>
41 
42 #include <time.h>
43 
44 
45 namespace mln
46 {
47 
48  namespace data
49  {
50 
51  namespace approx
52  {
53 
65  template <typename I>
66  mln_concrete(I)
67  median(const Image<I>& input, const win::rectangle2d& win);
68 
69 
81  template <typename I>
82  mln_concrete(I)
83  median(const Image<I>& input, const win::disk2d& win);
84 
85 
97  template <typename I>
98  mln_concrete(I)
99  median(const Image<I>& input, const win::octagon2d& win);
100 
101 
102 
103 # ifndef MLN_INCLUDE_ONLY
104 
105 
106  // Facades.
107 
108 
109  template <typename I>
110  inline
111  mln_concrete(I)
112  median(const Image<I>& input, const win::rectangle2d& win)
113  {
114  mln_trace("data::approx::median");
115 
116  mln_concrete(I) output;
117 
118  win::hline2d win1(win.width());
119  output = data::median(input, win1);
120 
121  win::vline2d win2(win.height());
122  output = data::median(output, win2);
123 
124  return output;
125  }
126 
127 
128  template <typename I>
129  inline
130  mln_concrete(I)
131  median(const Image<I>& input, const win::disk2d& win)
132  {
133  mln_trace("data::approx::median");
134 
135  const unsigned len = win.diameter() / 3 + 1;
136  mln_concrete(I) output;
137 
138  win::diag2d win1(len);
139  output = data::median(input, win1);
140 
141  win::backdiag2d win2(len);
142  output = data::median(output, win2);
143 
144  win::hline2d win3(len);
145  output = data::median(input, win3);
146 
147  win::vline2d win4(len);
148  output = data::median(output, win4);
149 
150  return output;
151  }
152 
153 
154  template <typename I>
155  inline
156  mln_concrete(I)
157  median(const Image<I>& input, const win::octagon2d& win)
158  {
159  return median(input, win::disk2d(win.length()));
160  }
161 
162 # endif // ! MLN_INCLUDE_ONLY
163 
164  } // end of namespace mln::data::approx
165 
166  } // end of namespace mln::data
167 
168 } // end of namespace mln
169 
170 
171 #endif // ! MLN_DATA_APPROX_MEDIAN_HH