aimsalgo  5.1.2
Neuroimaging image processing
splinefilter.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_SPLINEFILTER_H
35 #define AIMS_SIGNALFILTER_SPLINEFILTER_H
36 
37 //============================================================================
38 //
39 // INVERSE B-SPLINE FILTER
40 //
41 //============================================================================
42 
43 //--- aims -------------------------------------------------------------------
44 #include <aims/signalfilter/iirfilter.h> // aims::SymAllPoleIIRFilter
45 //--- cartodata --------------------------------------------------------------
46 #include <cartodata/volume/volume.h> // carto::VolumeRef
47 //----------------------------------------------------------------------------
48 
49 namespace aims {
50 
62  {
63  public:
64  //------------------------------------------------------------------------
66  //------------------------------------------------------------------------
70  InverseBSplineFilter( unsigned order = 3 );
79 
80  //------------------------------------------------------------------------
82  //------------------------------------------------------------------------
85  const unsigned & order() const;
89  void setOrder( const unsigned & order );
91 
92  protected:
93  //------------------------------------------------------------------------
95  //------------------------------------------------------------------------
99  void setPoles();
101 
102  unsigned _order;
103  };
104 
105 } // namespace aims
106 
107 //============================================================================
108 //
109 // DIRECT B-SPLINE FILTER
110 //
111 //============================================================================
112 
113 //--- aims -------------------------------------------------------------------
114 #include <aims/math/bspline.h> // aims::DiscreteBSpline
115 #include <aims/signalfilter/convolutionfilter.h> // aims::ConvolutionFilter
116 #include <aims/vector/vector.h> // Point4df
117 //--- cartodata --------------------------------------------------------------
118 #include <cartodata/volume/volume.h> // carto::VolumeRef
119 //----------------------------------------------------------------------------
120 
121 namespace aims {
122 
129  class DirectBSplineFilter: public ConvolutionFilter<DiscreteBSpline>
130  {
131  public:
132  //------------------------------------------------------------------------
134  //------------------------------------------------------------------------
136  DirectBSplineFilter( float scale = 1., bool normalize = false,
137  unsigned order = 3 );
138  DirectBSplineFilter( const Point4df & scale, bool normalize = false,
139  unsigned order = 3 );
144 
145  //------------------------------------------------------------------------
147  //------------------------------------------------------------------------
150  unsigned order() const;
152  Point4df scale() const;
154  bool normalize() const;
157  void setOrder( const unsigned & order );
160  void setScale( const float & scale );
163  void setScale( const Point4df & scale );
165  void setNormalize( const bool & normalize = true );
167 
168  //------------------------------------------------------------------------
170  //------------------------------------------------------------------------
182  template <typename OUTP, typename INP>
184  carto::VolumeRef<OUTP> & out ) const;
187 
188  protected:
190  // Make some inherited functions private
192  };
193 
194 } // namespace aims
195 
196 // Yael - April 15th, 2016
197 // I'm commenting out this class for now because its implementation is false.
198 // Because poles depend on the smoothing parameter, the stability of the
199 // filter cannot be known a priori. Several implementations are possible
200 // (using computations in the complex space, separating the filter into
201 // a sum of causal and anticausal filters, separating it into a
202 // convolution of causal and anticausal filters, ...? )
203 // but I don't have the time and do not need this class for now.
204 // I leave it in case it is of interest someday.
205 #if 0
206 //============================================================================
207 //
208 // INVERSE SMOOTHING B-SPLINE FILTER
209 //
210 //============================================================================
211 
212 //--- aims -------------------------------------------------------------------
213 #include <aims/signalfilter/iirfilter.h> // aims::SymAllPoleIIRFilter
214 //--- cartodata --------------------------------------------------------------
215 #include <cartodata/volume/volume.h> // carto::VolumeRef
216 //----------------------------------------------------------------------------
217 
218 namespace aims {
219 
234  class InverseSmoothingSplineFilter: public IIRFilterBase
235  {
236  public:
237  //------------------------------------------------------------------------
239  //------------------------------------------------------------------------
243  InverseSmoothingSplineFilter( float lambda, unsigned n = N );
244  InverseSmoothingSplineFilter( const InverseSmoothingSplineFilter & other );
245  virtual ~InverseSmoothingSplineFilter();
246  InverseSmoothingSplineFilter & operator=( const InverseSmoothingSplineFilter & other );
248 
249  //------------------------------------------------------------------------
251  //------------------------------------------------------------------------
253  virtual void filter1d( const carto::VolumeRef<double> in,
254  carto::VolumeRef<double> out, int dir = -1 ) const;
256 
257  //------------------------------------------------------------------------
259  //------------------------------------------------------------------------
262  const unsigned & order() const;
264  const float & lambda() const;
268  void setOrder( unsigned n );
272  void setLambda( float l );
274 
275  protected:
276  //------------------------------------------------------------------------
278  //------------------------------------------------------------------------
280  void setFilters();
282 
283  enum FilterType { Interpolation, SymRealPole, SymComplexPole };
284 
285  unsigned _order;
286  float _lambda;
287  FilterType _ftype;
288  CausalAllPoleIIRFilter _causal;
289  AntiCausalAllPoleIIRFilter _anticausal;
290  SymAllPoleIIRFilter _symmetric;
291  InverseBSplineFilter _interpolation;
292 
293  // friend class
294  template <unsigned O> friend class InverseSmoothingSplineFilter;
295  };
296 
297 } // namespace aims
298 #endif
299 
300 #endif // AIMS_SIGNALFILTER_SPLINEFILTER_H
Convolution Filter.
This filter uses a convolution with Spline basis functions.
Definition: splinefilter.h:130
unsigned order() const
Parameters.
carto::VolumeRef< OUTP > execute(const carto::VolumeRef< INP > &in, carto::VolumeRef< OUTP > &out) const
Execution.
Point4df scale() const
Get spline scaling coefficient.
DirectBSplineFilter(const DirectBSplineFilter &other)
void setNormalize(const bool &normalize=true)
Set normalization mode.
void setScale(const float &scale)
Set scaling coefficient Updates underlyong basis functions.
void setOrder(const unsigned &order)
Set spline order Updates underlyong basis functions.
DirectBSplineFilter(float scale=1., bool normalize=false, unsigned order=3)
Constructor / Copy.
DirectBSplineFilter & operator=(const DirectBSplineFilter &other)
bool normalize() const
Get normalization mode.
void setScale(const Point4df &scale)
Set scaling coefficient Updates underlyong basis functions.
DirectBSplineFilter(const Point4df &scale, bool normalize=false, unsigned order=3)
This filter uses an inverse B-Spline convolution function to transform a discrete signal to its splin...
Definition: splinefilter.h:62
InverseBSplineFilter(const InverseBSplineFilter &other)
The internal order of the copied filter is kept, meaning that the built filter's order might differ f...
const unsigned & order() const
Parameters.
InverseBSplineFilter(unsigned order=3)
Constructor / Copy.
void setOrder(const unsigned &order)
Set spline order The gain and poles of the underlying IIR filter will be updated accordingly.
InverseBSplineFilter & operator=(const InverseBSplineFilter &other)
The internal order of the copied filter is kept, meaning that the built filter's order might differ f...
Symmetric, all-pole, infinite impulse response Filter.
Definition: iirfilter.h:418