My Project
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 {
63 public:
65  virtual ~C1DInterpolator();
66 };
67 
68 
78 template <typename T>
80 {
81 public:
82 
87  virtual T operator () (const double& x) const = 0;
88 
94  virtual typename coeff_map<T>::coeff_type derivative_at (const double& x) const = 0;
95 
96 
97 };
98 
107 template <class T>
109 {
110 public:
118  T1DConvoluteInterpolator(const std::vector<T>& data, PSplineKernel kernel,
119  const CSplineBoundaryCondition& boundary_conditions);
120 
122 
128  T operator () (const double& x) const;
129 
135  virtual typename coeff_map<T>::coeff_type derivative_at (const double& x) const;
136 
137 protected:
139  typedef std::vector< typename coeff_map< T >::coeff_type > TCoeff1D;
140 
143 private:
144 
145  TCoeff1D m_coeff;
146  PSplineKernel m_kernel;
147  PSplineBoundaryCondition m_boundary_conditions;
148  T m_min;
149  T m_max;
150 
151  // not thread save!!!
152  mutable CSplineKernel::VIndex m_x_index;
153  mutable CSplineKernel::VWeight m_x_weight;
154 };
155 
156 
164 {
165 public:
166 
172 
173  C1DInterpolatorFactory(const std::string& kernel_descr, const std::string& boundary_descr);
174 
177 
180 
182 
190  template <class T>
191  T1DInterpolator<T> *create(const std::vector<T>& src) const
192  __attribute__ ((warn_unused_result));
193 
196 
197 private:
198  PSplineKernel m_kernel;
200 };
201 
206 typedef std::shared_ptr<const C1DInterpolatorFactory > P1DInterpolatorFactory;
207 
214 // implementation
215 template <class T>
216 T1DInterpolator<T> *C1DInterpolatorFactory::create(const std::vector<T>& src) const
217 {
218  return new T1DConvoluteInterpolator<T>(src, m_kernel, *m_bc);
219 }
220 
226 template <typename T>
227 struct __dispatch_min_max {
228  static void apply(const T i, T& min, T& max);
229 };
230 
235 template <typename I, typename O>
236 struct __dispatch_copy {
237  static void apply(const I& input, O& output);
238 };
239 
241 
243 
244 #endif
C1DInterpolatorFactory::C1DInterpolatorFactory
C1DInterpolatorFactory(const std::string &kernel_descr, const std::string &boundary_descr)
T1DConvoluteInterpolator::~T1DConvoluteInterpolator
~T1DConvoluteInterpolator()
C1DInterpolatorFactory::C1DInterpolatorFactory
C1DInterpolatorFactory(PSplineKernel kernel, const CSplineBoundaryCondition &bc)
NS_MIA_BEGIN
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition: defines.hh:33
T1DConvoluteInterpolator::TCoeff1D
std::vector< typename coeff_map< T >::coeff_type > TCoeff1D
Type of the coefficients after filtering.
Definition: interpolator1d.hh:139
C1DInterpolatorFactory::get_kernel
PSplineKernel get_kernel() const
CSplineKernel::VIndex
std::vector< int > VIndex
type for the index vector
Definition: splinekernel.hh:64
C1DInterpolatorFactory
Factory class for 1D interpolators.
Definition: interpolator1d.hh:164
CSplineBoundaryCondition
Abstract base class for B-spline interpolation boundary conditions.
Definition: boundary_conditions.hh:53
NS_MIA_END
#define NS_MIA_END
conveniance define to end the mia namespace
Definition: defines.hh:36
T1DConvoluteInterpolator::coeff_vector
TCoeff1D coeff_vector
vector to hold coefficients
Definition: interpolator1d.hh:142
CSplineKernel::VWeight
std::vector< double > VWeight
type for the weight vector
Definition: splinekernel.hh:61
T1DConvoluteInterpolator::T1DConvoluteInterpolator
T1DConvoluteInterpolator(const std::vector< T > &data, PSplineKernel kernel, const CSplineBoundaryCondition &boundary_conditions)
PSplineKernel
std::shared_ptr< CSplineKernel > PSplineKernel
Definition: splinekernel.hh:291
T1DConvoluteInterpolator
Interpolator that uses some kind of spaciel kernel.
Definition: interpolator1d.hh:109
C1DInterpolatorFactory::C1DInterpolatorFactory
C1DInterpolatorFactory(const C1DInterpolatorFactory &o)
Copy constructor.
boundary_conditions.hh
C1DInterpolator::~C1DInterpolator
virtual ~C1DInterpolator()
T1DInterpolator
Interpolator base class providing the full interface.
Definition: interpolator1d.hh:80
EXPORT_CORE
#define EXPORT_CORE
Macro to manage Visual C++ style dllimport/dllexport.
Definition: defines.hh:101
C1DInterpolator
Basic Interpolator type for 1D Data.
Definition: interpolator1d.hh:62
CCmdOptionFlags::input
@ input
CCmdOptionFlags::output
@ output
C1DInterpolatorFactory::create
T1DInterpolator< T > * create(const std::vector< T > &src) const __attribute__((warn_unused_result))
Definition: interpolator1d.hh:216
T1DInterpolator::operator()
virtual T operator()(const double &x) const =0
P1DInterpolatorFactory
std::shared_ptr< const C1DInterpolatorFactory > P1DInterpolatorFactory
Definition: interpolator1d.hh:206
T1DConvoluteInterpolator::derivative_at
virtual coeff_map< T >::coeff_type derivative_at(const double &x) const
defines.hh
C1DInterpolatorFactory::~C1DInterpolatorFactory
virtual ~C1DInterpolatorFactory()
PSplineBoundaryCondition
CSplineBoundaryCondition::Pointer PSplineBoundaryCondition
Definition: boundary_conditions.hh:167
T1DInterpolator::derivative_at
virtual coeff_map< T >::coeff_type derivative_at(const double &x) const =0
splinekernel.hh