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>
50
51
53
62{
63public:
66};
67
68
78template <typename T>
80{
81public:
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
107template <class T>
109{
110public:
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
137protected:
139 typedef std::vector< typename coeff_map< T >::coeff_type > TCoeff1D;
140
143private:
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{
165public:
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
197private:
198 PSplineKernel m_kernel;
200};
201
206typedef std::shared_ptr<const C1DInterpolatorFactory > P1DInterpolatorFactory;
207
214// implementation
215template <class T>
216T1DInterpolator<T> *C1DInterpolatorFactory::create(const std::vector<T>& src) const
217{
218 return new T1DConvoluteInterpolator<T>(src, m_kernel, *m_bc);
219}
220
226template <typename T>
227struct __dispatch_min_max {
228 static void apply(const T i, T& min, T& max);
229};
230
235template <typename I, typename O>
236struct __dispatch_copy {
237 static void apply(const I& input, O& output);
238};
239
241
243
244#endif
Factory class for 1D interpolators.
C1DInterpolatorFactory(PSplineKernel kernel, const CSplineBoundaryCondition &bc)
virtual ~C1DInterpolatorFactory()
C1DInterpolatorFactory(const std::string &kernel_descr, const std::string &boundary_descr)
PSplineKernel get_kernel() const
T1DInterpolator< T > * create(const std::vector< T > &src) const __attribute__((warn_unused_result))
C1DInterpolatorFactory(const C1DInterpolatorFactory &o)
Copy constructor.
Basic Interpolator type for 1D Data.
virtual ~C1DInterpolator()
Abstract base class for B-spline interpolation boundary conditions.
std::vector< double > VWeight
type for the weight vector
std::vector< int > VIndex
type for the index vector
Interpolator that uses some kind of spaciel kernel.
T1DConvoluteInterpolator(const std::vector< T > &data, PSplineKernel kernel, const CSplineBoundaryCondition &boundary_conditions)
virtual coeff_map< T >::coeff_type derivative_at(const double &x) const
TCoeff1D coeff_vector
vector to hold coefficients
std::vector< typename coeff_map< T >::coeff_type > TCoeff1D
Type of the coefficients after filtering.
Interpolator base class providing the full interface.
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
#define EXPORT_CORE
Macro to manage Visual C++ style dllimport/dllexport.
Definition defines.hh:101
#define NS_MIA_END
conveniance define to end the mia namespace
Definition defines.hh:36
CSplineBoundaryCondition::Pointer PSplineBoundaryCondition
std::shared_ptr< const C1DInterpolatorFactory > P1DInterpolatorFactory
std::shared_ptr< CSplineKernel > PSplineKernel