interpolator1d.hh
Go to the documentation of this file.
1 /* -*- mia-c++ -*-
2  *
3  * This file is part of MIA - a toolbox for medical image analysis
4  * Copyright (c) Leipzig, Madrid 1999-2017 Gert Wollny
5  *
6  * MIA is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with MIA; if not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 /*
22  The filter routines for splines and omoms is based on code by
23  Philippe Thevenaz http://bigwww.epfl.ch/thevenaz/interpolation/
24  see also:
25 
26  [1] M. Unser,
27  "Splines: A Perfect Fit for Signal and Image Processing,"
28  IEEE Signal Processing Magazine, vol. 16, no. 6, pp. 22-38,
29  November 1999.
30  [2] M. Unser, A. Aldroubi and M. Eden,
31  "B-Spline Signal Processing: Part I--Theory,"
32  IEEE Transactions on Signal Processing, vol. 41, no. 2, pp. 821-832,
33  February 1993.
34  [3] M. Unser, A. Aldroubi and M. Eden,
35  "B-Spline Signal Processing: Part II--Efficient Design and Applications,"
36  IEEE Transactions on Signal Processing, vol. 41, no. 2, pp. 834-848,
37  February 1993.
38 
39 */
40 
41 #ifndef mia_1d_interpolator_hh
42 #define mia_1d_interpolator_hh
43 
44 
45 #include <vector>
46 
47 #include <mia/core/defines.hh>
48 #include <mia/core/splinekernel.hh>
50 
51 
53 
62 public:
64  virtual ~C1DInterpolator();
65 };
66 
67 
77 template <typename T>
79 public:
80 
85  virtual T operator () (const double& x) const = 0;
86 
92  virtual typename coeff_map<T>::coeff_type derivative_at (const double& x) const = 0;
93 
94 
95 };
96 
105 template <class T>
107 public:
115  T1DConvoluteInterpolator(const std::vector<T>& data, PSplineKernel kernel,
116  const CSplineBoundaryCondition& boundary_conditions);
117 
119 
125  T operator () (const double& x) const;
126 
132  virtual typename coeff_map<T>::coeff_type derivative_at (const double& x) const;
133 
134 protected:
136  typedef std::vector< typename coeff_map< T >::coeff_type > TCoeff1D;
137 
139  typedef TCoeff1D coeff_vector;
140 private:
141 
142  TCoeff1D m_coeff;
143  PSplineKernel m_kernel;
144  PSplineBoundaryCondition m_boundary_conditions;
145  T m_min;
146  T m_max;
147 
148  // not thread save!!!
149  mutable CSplineKernel::VIndex m_x_index;
150  mutable CSplineKernel::VWeight m_x_weight;
151 };
152 
153 
161 public:
162 
168 
169  C1DInterpolatorFactory(const std::string& kernel_descr, const std::string& boundary_descr);
170 
173 
175  C1DInterpolatorFactory& operator = ( const C1DInterpolatorFactory& o);
176 
177  virtual ~C1DInterpolatorFactory();
178 
186  template <class T>
187  T1DInterpolator<T> *create(const std::vector<T>& src) const
188  __attribute__ ((warn_unused_result));
189 
191  PSplineKernel get_kernel() const;
192 
193 private:
194  PSplineKernel m_kernel;
196 };
197 
202 typedef std::shared_ptr<const C1DInterpolatorFactory > P1DInterpolatorFactory;
203 
210 // implementation
211 template <class T>
212 T1DInterpolator<T> *C1DInterpolatorFactory::create(const std::vector<T>& src) const
213 {
214  return new T1DConvoluteInterpolator<T>(src, m_kernel, *m_bc);
215 }
216 
222 template <typename T>
223 struct __dispatch_min_max {
224  static void apply(const T i, T& min, T &max);
225 };
226 
231 template <typename I, typename O>
232 struct __dispatch_copy {
233  static void apply(const I& input, O& output);
234 };
235 
237 
239 
240 #endif
std::vector< typename coeff_map< T >::coeff_type > TCoeff1D
Type of the coefficients after filtering.
virtual T operator()(const double &x) const =0
Interpolator that uses some kind of spaciel kernel.
virtual coeff_map< T >::coeff_type derivative_at(const double &x) const =0
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition: defines.hh:33
T1DInterpolator< T > * create(const std::vector< T > &src) const __attribute__((warn_unused_result))
std::vector< double > VWeight
type for the weight vector
Definition: splinekernel.hh:60
std::shared_ptr< CSplineKernel > PSplineKernel
Interpolator base class providing the full interface.
std::vector< int > VIndex
type for the index vector
Definition: splinekernel.hh:63
Abstract base class for B-spline interpolation boundary conditions.
Factory class for 1D interpolators.
TCoeff1D coeff_vector
vector to hold coefficients
#define EXPORT_CORE
Macro to manage Visual C++ style dllimport/dllexport.
Definition: defines.hh:101
Basic Interpolator type for 1D Data.
std::shared_ptr< const C1DInterpolatorFactory > P1DInterpolatorFactory
CSplineBoundaryCondition::Pointer PSplineBoundaryCondition
#define NS_MIA_END
conveniance define to end the mia namespace
Definition: defines.hh:36