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-2013 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 
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 
171 
173  C1DInterpolatorFactory& operator = ( const C1DInterpolatorFactory& o);
174 
175  virtual ~C1DInterpolatorFactory();
176 
184  template <class T>
185  T1DInterpolator<T> *create(const std::vector<T>& src) const
186  __attribute__ ((warn_unused_result));
187 
189  PSplineKernel get_kernel() const;
190 
191 private:
192  PSplineKernel m_kernel;
194 };
195 
200 typedef std::shared_ptr<const C1DInterpolatorFactory > P1DInterpolatorFactory;
201 
209  __attribute__ ((warn_unused_result));
210 
211 // implementation
212 template <class T>
213 T1DInterpolator<T> *C1DInterpolatorFactory::create(const std::vector<T>& src) const
214 {
215  return new T1DConvoluteInterpolator<T>(src, m_kernel, *m_bc);
216 }
217 
223 template <typename T>
224 struct __dispatch_min_max {
225  static void apply(const T i, T& min, T &max);
226 };
227 
232 template <typename I, typename O>
233 struct __dispatch_copy {
234  static void apply(const I& input, O& output);
235 };
236 
238 
240 
241 #endif