aimsalgo  5.0.5
Neuroimaging image processing
movingaveragefilter.h
Go to the documentation of this file.
1 /* This software and supporting documentation are distributed by
2  * Institut Federatif de Recherche 49
3  * CEA/NeuroSpin, Batiment 145,
4  * 91191 Gif-sur-Yvette cedex
5  * France
6  *
7  * This software is governed by the CeCILL-B license under
8  * French law and abiding by the rules of distribution of free software.
9  * You can use, modify and/or redistribute the software under the
10  * terms of the CeCILL-B license as circulated by CEA, CNRS
11  * and INRIA at the following URL "http://www.cecill.info".
12  *
13  * As a counterpart to the access to the source code and rights to copy,
14  * modify and redistribute granted by the license, users are provided only
15  * with a limited warranty and the software's author, the holder of the
16  * economic rights, and the successive licensors have only limited
17  * liability.
18  *
19  * In this respect, the user's attention is drawn to the risks associated
20  * with loading, using, modifying and/or developing or reproducing the
21  * software by the user in light of its specific status of free software,
22  * that may mean that it is complicated to manipulate, and that also
23  * therefore means that it is reserved for developers and experienced
24  * professionals having in-depth computer knowledge. Users are therefore
25  * encouraged to load and test the software's suitability as regards their
26  * requirements in conditions enabling the security of their systems and/or
27  * data to be ensured and, more generally, to use and operate it in the
28  * same conditions as regards security.
29  *
30  * The fact that you are presently reading this means that you have had
31  * knowledge of the CeCILL-B license and that you accept its terms.
32  */
33 
34 #ifndef AIMS_SIGNALFILTER_MOVINGAVERAGEFILTER_H
35 #define AIMS_SIGNALFILTER_MOVINGAVERAGEFILTER_H
36 
37 //============================================================================
38 //
39 // MOVING AVERAGE KERNEL
40 //
41 //============================================================================
42 
44 #include <aims/vector/vector.h>
45 #include <vector>
46 
47 namespace aims {
48 
61  {
62  public:
63 
64  //------------------------------------------------------------------------
66  //------------------------------------------------------------------------
69  MovingAverageKernel( unsigned length = 3,
72  virtual ~MovingAverageKernel();
75 
76  //------------------------------------------------------------------------
78  //------------------------------------------------------------------------
80  double operator() ( int x ) const;
81  double at( int x ) const;
82  const Point2di & support() const;
84 
85  //------------------------------------------------------------------------
87  //------------------------------------------------------------------------
94  void reset( unsigned length = 3,
96  void setLength( unsigned length );
97  void setType( FilterType::Direction symtype );
99 
100  //------------------------------------------------------------------------
102  //------------------------------------------------------------------------
104  unsigned length() const;
105  FilterType::Direction type() const;
107 
108  protected:
109  void setSupport( FilterType::Direction symtype );
112  std::vector<double> _values;
113  };
114 
115 } // namespace aims
116 
117 //============================================================================
118 //
119 // MOVING AVERAGE CASCADE KERNEL
120 //
121 //============================================================================
122 
123 #include <aims/vector/vector.h>
124 #include <vector>
125 
126 namespace aims {
127 
137  {
138  public:
139  //------------------------------------------------------------------------
141  //------------------------------------------------------------------------
144  MovingAverageCascadeKernel( unsigned length = 3, unsigned n = 2,
147  virtual ~MovingAverageCascadeKernel();
150 
151  //------------------------------------------------------------------------
153  //------------------------------------------------------------------------
155  double operator() ( int x ) const;
156  double at( int x ) const;
157  const Point2di & support() const;
159 
160  //------------------------------------------------------------------------
162  //------------------------------------------------------------------------
170  void reset( unsigned length = 3, unsigned n = 2,
172  void setLength( unsigned length );
173  void setCascade( unsigned n );
174  void setType( FilterType::Direction symtype );
176 
177  //------------------------------------------------------------------------
179  //------------------------------------------------------------------------
181  unsigned length() const;
182  unsigned cascade() const;
183  FilterType::Direction type() const;
185 
186  protected:
187  void setValues( unsigned length, unsigned n, FilterType::Direction symtype );
188  unsigned _n;
190  std::vector<double> _values;
191  };
192 
193 } // namespace aims
194 
195 
196 //============================================================================
197 //
198 // MOVING AVERAGE FILTER
199 //
200 //============================================================================
201 
203 
204 namespace aims {
205 
210  class MovingAverageFilter: public ConvolutionFilter<MovingAverageKernel>
211  {
212  public:
213  //------------------------------------------------------------------------
215  //------------------------------------------------------------------------
219  MovingAverageFilter( const MovingAverageFilter & other );
220  virtual ~MovingAverageFilter();
223 
224  //------------------------------------------------------------------------
226  //------------------------------------------------------------------------
228  void setLength( unsigned length );
229  void setLength( const Point4du & length );
230  void setType( FilterType::Direction symtype );
232 
233  //------------------------------------------------------------------------
235  //------------------------------------------------------------------------
237  Point4du length() const;
238  FilterType::Direction type() const;
240 
241  protected:
242  // Make some inherited functions private
244  };
245 
246 } // namespace aims
247 
248 //============================================================================
249 //
250 // MOVING AVERAGE CASCADE FILTER
251 //
252 //============================================================================
253 
255 
256 namespace aims {
257 
262  class MovingAverageCascadeFilter: public ConvolutionFilter<MovingAverageCascadeKernel>
263  {
264  public:
265  //------------------------------------------------------------------------
267  //------------------------------------------------------------------------
269  MovingAverageCascadeFilter( unsigned length = 3, unsigned n = 2,
271  MovingAverageCascadeFilter( const Point4du & length, unsigned n = 2,
273  MovingAverageCascadeFilter( const Point4du & length, const Point4du & n,
276  virtual ~MovingAverageCascadeFilter();
279 
280  //------------------------------------------------------------------------
282  //------------------------------------------------------------------------
284  void setLength( unsigned length );
285  void setLength( const Point4du & length );
286  void setCascade( unsigned n );
287  void setCascade( const Point4du & n );
288  void setType( FilterType::Direction symtype );
290 
293  Point4du length() const;
294  Point4du cascade() const;
295  FilterType::Direction type() const;
297 
298  protected:
299  // Make some inherited functions private
301  };
302 
303 } // namespace aims
304 
305 #endif // AIMS_SIGNALFILTER_MOVINGAVERAGEFILTER_H
void setLength(unsigned length)
std::vector< double > _values
unsigned length() const
Get parameters.
1D Cascade of Moving Average Kernel
double operator()(int x) const
Get value.
Separable Moving Average Filter.
FilterType::Direction type() const
void setSupport(FilterType::Direction symtype)
Convolution Filter.
MovingAverageKernel & operator=(const MovingAverageKernel &other)
1D Moving Average Kernel
MovingAverageKernel(unsigned length=3, FilterType::Direction symtype=FilterType::Symmetrical)
Constructor/Destructor/Copy.
FilterType::Direction _type
double at(int x) const
void setType(FilterType::Direction symtype)
void reset(unsigned length=3, FilterType::Direction symtype=FilterType::Symmetrical)
Set parameters.
Separable Cascade of Moving Average Filter.
const Point2di & support() const