interpolator1d.hh
Go to the documentation of this file.
/* -*- mia-c++ -*-
*
* This file is part of MIA - a toolbox for medical image analysis
* Copyright (c) Leipzig, Madrid 1999-2017 Gert Wollny
*
* MIA is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MIA; if not, see <http://www.gnu.org/licenses/>.
*
*/
/*
The filter routines for splines and omoms is based on code by
Philippe Thevenaz http://bigwww.epfl.ch/thevenaz/interpolation/
see also:
[1] M. Unser,
"Splines: A Perfect Fit for Signal and Image Processing,"
IEEE Signal Processing Magazine, vol. 16, no. 6, pp. 22-38,
November 1999.
[2] M. Unser, A. Aldroubi and M. Eden,
"B-Spline Signal Processing: Part I--Theory,"
IEEE Transactions on Signal Processing, vol. 41, no. 2, pp. 821-832,
February 1993.
[3] M. Unser, A. Aldroubi and M. Eden,
"B-Spline Signal Processing: Part II--Efficient Design and Applications,"
IEEE Transactions on Signal Processing, vol. 41, no. 2, pp. 834-848,
February 1993.
*/
#ifndef mia_1d_interpolator_hh
#define mia_1d_interpolator_hh
#include <vector>
#include <mia/core/defines.hh>
#include <mia/core/splinekernel.hh>
#include <mia/core/boundary_conditions.hh>
NS_MIA_BEGIN
class EXPORT_CORE C1DInterpolator
{
public:
virtual ~C1DInterpolator();
};
template <typename T>
class EXPORT_CORE T1DInterpolator : public C1DInterpolator
{
public:
virtual T operator () (const double& x) const = 0;
virtual typename coeff_map<T>::coeff_type derivative_at (const double& x) const = 0;
};
template <class T>
class EXPORT_CORE T1DConvoluteInterpolator: public T1DInterpolator<T>
{
public:
T1DConvoluteInterpolator(const std::vector<T>& data, PSplineKernel kernel,
const CSplineBoundaryCondition& boundary_conditions);
~T1DConvoluteInterpolator();
T operator () (const double& x) const;
virtual typename coeff_map<T>::coeff_type derivative_at (const double& x) const;
protected:
typedef std::vector< typename coeff_map< T >::coeff_type > TCoeff1D;
typedef TCoeff1D coeff_vector;
private:
TCoeff1D m_coeff;
PSplineKernel m_kernel;
PSplineBoundaryCondition m_boundary_conditions;
T m_min;
T m_max;
// not thread save!!!
mutable CSplineKernel::VIndex m_x_index;
mutable CSplineKernel::VWeight m_x_weight;
};
class EXPORT_CORE C1DInterpolatorFactory
{
public:
C1DInterpolatorFactory(PSplineKernel kernel, const CSplineBoundaryCondition& bc);
C1DInterpolatorFactory(const std::string& kernel_descr, const std::string& boundary_descr);
C1DInterpolatorFactory(const C1DInterpolatorFactory& o);
C1DInterpolatorFactory& operator = ( const C1DInterpolatorFactory& o);
virtual ~C1DInterpolatorFactory();
template <class T>
T1DInterpolator<T> *create(const std::vector<T>& src) const
__attribute__ ((warn_unused_result));
PSplineKernel get_kernel() const;
private:
PSplineKernel m_kernel;
PSplineBoundaryCondition m_bc;
};
typedef std::shared_ptr<const C1DInterpolatorFactory > P1DInterpolatorFactory;
// implementation
template <class T>
T1DInterpolator<T> *C1DInterpolatorFactory::create(const std::vector<T>& src) const
{
return new T1DConvoluteInterpolator<T>(src, m_kernel, *m_bc);
}
template <typename T>
struct __dispatch_min_max {
static void apply(const T i, T& min, T& max);
};
template <typename I, typename O>
struct __dispatch_copy {
static void apply(const I& input, O& output);
};
NS_MIA_END
#endif
boundary_conditions.hh
C1DInterpolatorFactory::C1DInterpolatorFactory
C1DInterpolatorFactory(PSplineKernel kernel, const CSplineBoundaryCondition &bc)
C1DInterpolatorFactory::~C1DInterpolatorFactory
virtual ~C1DInterpolatorFactory()
C1DInterpolatorFactory::C1DInterpolatorFactory
C1DInterpolatorFactory(const std::string &kernel_descr, const std::string &boundary_descr)
C1DInterpolatorFactory::get_kernel
PSplineKernel get_kernel() const
C1DInterpolatorFactory::create
T1DInterpolator< T > * create(const std::vector< T > &src) const __attribute__((warn_unused_result))
Definition interpolator1d.hh:216
C1DInterpolatorFactory::C1DInterpolatorFactory
C1DInterpolatorFactory(const C1DInterpolatorFactory &o)
Copy constructor.
C1DInterpolator
Basic Interpolator type for 1D Data.
Definition interpolator1d.hh:62
C1DInterpolator::~C1DInterpolator
virtual ~C1DInterpolator()
CSplineBoundaryCondition
Abstract base class for B-spline interpolation boundary conditions.
Definition boundary_conditions.hh:53
CSplineKernel::VWeight
std::vector< double > VWeight
type for the weight vector
Definition splinekernel.hh:61
CSplineKernel::VIndex
std::vector< int > VIndex
type for the index vector
Definition splinekernel.hh:64
T1DConvoluteInterpolator
Interpolator that uses some kind of spaciel kernel.
Definition interpolator1d.hh:109
T1DConvoluteInterpolator::T1DConvoluteInterpolator
T1DConvoluteInterpolator(const std::vector< T > &data, PSplineKernel kernel, const CSplineBoundaryCondition &boundary_conditions)
T1DConvoluteInterpolator::derivative_at
virtual coeff_map< T >::coeff_type derivative_at(const double &x) const
T1DConvoluteInterpolator::coeff_vector
TCoeff1D coeff_vector
vector to hold coefficients
Definition interpolator1d.hh:142
T1DConvoluteInterpolator::TCoeff1D
std::vector< typename coeff_map< T >::coeff_type > TCoeff1D
Type of the coefficients after filtering.
Definition interpolator1d.hh:139
T1DConvoluteInterpolator::~T1DConvoluteInterpolator
~T1DConvoluteInterpolator()
T1DInterpolator
Interpolator base class providing the full interface.
Definition interpolator1d.hh:80
T1DInterpolator::derivative_at
virtual coeff_map< T >::coeff_type derivative_at(const double &x) const =0
CCmdOptionFlags::output
@ output
Definition cmdoptionflags.hh:32
CCmdOptionFlags::input
@ input
Definition cmdoptionflags.hh:31
defines.hh
NS_MIA_BEGIN
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition defines.hh:33
EXPORT_CORE
#define EXPORT_CORE
Macro to manage Visual C++ style dllimport/dllexport.
Definition defines.hh:101
NS_MIA_END
#define NS_MIA_END
conveniance define to end the mia namespace
Definition defines.hh:36
PSplineBoundaryCondition
CSplineBoundaryCondition::Pointer PSplineBoundaryCondition
Definition boundary_conditions.hh:167
P1DInterpolatorFactory
std::shared_ptr< const C1DInterpolatorFactory > P1DInterpolatorFactory
Definition interpolator1d.hh:206
PSplineKernel
std::shared_ptr< CSplineKernel > PSplineKernel
Definition splinekernel.hh:291
splinekernel.hh