3d/interpolator.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/>.
*
*/
#ifndef mia_3d_interpolator_hh
#define mia_3d_interpolator_hh
#include <vector>
#include <mia/core/splinekernel.hh>
#include <mia/core/boundary_conditions.hh>
#include <mia/3d/image.hh>
#include <mia/core/parallel.hh>
NS_MIA_BEGIN
template <typename T>
class EXPORT_3D T3DInterpolator
{
public:
virtual ~T3DInterpolator() {}
virtual T operator () (const C3DFVector& x) const = 0;
};
template <class U>
struct coeff_map<T3DVector<U>> {
typedef T3DVector<U> value_type;
typedef C3DDVector coeff_type;
};
struct C3DWeightCache {
CSplineKernel::SCache x;
CSplineKernel::SCache y;
CSplineKernel::SCache z;
C3DWeightCache(int kernel_size,
const CSplineBoundaryCondition& xbc,
const CSplineBoundaryCondition& ybc,
const CSplineBoundaryCondition& zbc);
};
template <class T>
class EXPORT_3D T3DConvoluteInterpolator: public T3DInterpolator<T>
{
public:
typedef T3DDatafield< typename coeff_map< T >::coeff_type > TCoeff3D;
T3DConvoluteInterpolator(const T3DDatafield<T>& data, PSplineKernel kernel);
T3DConvoluteInterpolator(const T3DDatafield<T>& data, PSplineKernel kernel,
const CSplineBoundaryCondition& xbc,
const CSplineBoundaryCondition& ybc,
const CSplineBoundaryCondition& zbc);
~T3DConvoluteInterpolator();
C3DWeightCache create_cache() const;
T operator () (const C3DFVector& x, C3DWeightCache& cache) const;
T operator () (const C3DFVector& x) const;
const TCoeff3D& get_coefficients() const
{
return m_coeff;
}
protected:
typedef std::vector< typename TCoeff3D::value_type > coeff_vector;
private:
void prefilter(const T3DDatafield<T>& image);
TCoeff3D m_coeff;
C3DBounds m_size2;
PSplineKernel m_kernel;
PSplineBoundaryCondition m_xbc;
PSplineBoundaryCondition m_ybc;
PSplineBoundaryCondition m_zbc;
typename T3DDatafield<T>::value_type m_min;
typename T3DDatafield<T>::value_type m_max;
mutable CMutex m_cache_lock;
mutable C3DWeightCache m_cache;
};
class EXPORT_3D C3DInterpolatorFactory
{
public:
C3DInterpolatorFactory(const std::string& kernel, const std::string& boundary_conditions);
C3DInterpolatorFactory(PSplineKernel kernel, const CSplineBoundaryCondition& boundary_conditions);
C3DInterpolatorFactory(PSplineKernel kernel,
const CSplineBoundaryCondition& xbc,
const CSplineBoundaryCondition& ybc,
const CSplineBoundaryCondition& zbc);
C3DInterpolatorFactory(PSplineKernel kernel, const std::string& bc);
C3DInterpolatorFactory(const C3DInterpolatorFactory& o);
C3DInterpolatorFactory& operator = ( const C3DInterpolatorFactory& o);
virtual ~C3DInterpolatorFactory();
template <class T>
T3DConvoluteInterpolator<T> *create(const T3DDatafield<T>& src) const
__attribute__ ((warn_unused_result));
PSplineKernel get_kernel() const;
private:
PSplineKernel m_kernel;
PSplineBoundaryCondition m_xbc;
PSplineBoundaryCondition m_ybc;
PSplineBoundaryCondition m_zbc;
};
// implementation
template <class T>
T3DConvoluteInterpolator<T> *C3DInterpolatorFactory::create(const T3DDatafield<T>& src) const
{
return new T3DConvoluteInterpolator<T>(src, m_kernel, *m_xbc, *m_ybc, *m_zbc);
}
typedef std::shared_ptr<C3DInterpolatorFactory> P3DInterpolatorFactory;
NS_MIA_END
#endif
image.hh
P3DInterpolatorFactory
std::shared_ptr< C3DInterpolatorFactory > P3DInterpolatorFactory
Pointer type of the 3D interpolation factory.
Definition 3d/interpolator.hh:250
C3DBounds
T3DVector< unsigned int > C3DBounds
A unsinged int 3D Vector (used for 3D field sizes).
Definition 3d/vector.hh:415
C3DDVector
T3DVector< double > C3DDVector
A double 3D Vector.
Definition 3d/vector.hh:412
C3DFVector
T3DVector< float > C3DFVector
A float 3D Vector.
Definition 3d/vector.hh:409
boundary_conditions.hh
C3DInterpolatorFactory::~C3DInterpolatorFactory
virtual ~C3DInterpolatorFactory()
C3DInterpolatorFactory::C3DInterpolatorFactory
C3DInterpolatorFactory(PSplineKernel kernel, const CSplineBoundaryCondition &xbc, const CSplineBoundaryCondition &ybc, const CSplineBoundaryCondition &zbc)
C3DInterpolatorFactory::C3DInterpolatorFactory
C3DInterpolatorFactory(PSplineKernel kernel, const std::string &bc)
C3DInterpolatorFactory::create
T3DConvoluteInterpolator< T > * create(const T3DDatafield< T > &src) const __attribute__((warn_unused_result))
Definition 3d/interpolator.hh:244
C3DInterpolatorFactory::C3DInterpolatorFactory
C3DInterpolatorFactory(const std::string &kernel, const std::string &boundary_conditions)
C3DInterpolatorFactory::C3DInterpolatorFactory
C3DInterpolatorFactory(PSplineKernel kernel, const CSplineBoundaryCondition &boundary_conditions)
C3DInterpolatorFactory::C3DInterpolatorFactory
C3DInterpolatorFactory(const C3DInterpolatorFactory &o)
Copy constructor.
C3DInterpolatorFactory::get_kernel
PSplineKernel get_kernel() const
CSplineBoundaryCondition
Abstract base class for B-spline interpolation boundary conditions.
Definition boundary_conditions.hh:53
T3DConvoluteInterpolator
Interpolator that is based on convolution,like b-splines an o-moms.
Definition 3d/interpolator.hh:84
T3DConvoluteInterpolator::coeff_vector
std::vector< typename TCoeff3D::value_type > coeff_vector
helper class for filtering
Definition 3d/interpolator.hh:146
T3DConvoluteInterpolator::~T3DConvoluteInterpolator
~T3DConvoluteInterpolator()
Standart constructor for factory prototyping.
T3DConvoluteInterpolator::get_coefficients
const TCoeff3D & get_coefficients() const
Definition 3d/interpolator.hh:139
T3DConvoluteInterpolator::T3DConvoluteInterpolator
T3DConvoluteInterpolator(const T3DDatafield< T > &data, PSplineKernel kernel)
T3DConvoluteInterpolator::TCoeff3D
T3DDatafield< typename coeff_map< T >::coeff_type > TCoeff3D
Definition 3d/interpolator.hh:88
T3DConvoluteInterpolator::T3DConvoluteInterpolator
T3DConvoluteInterpolator(const T3DDatafield< T > &data, PSplineKernel kernel, const CSplineBoundaryCondition &xbc, const CSplineBoundaryCondition &ybc, const CSplineBoundaryCondition &zbc)
T3DConvoluteInterpolator::create_cache
C3DWeightCache create_cache() const
T3DDatafield
A templated class of a 3D data field.
Definition 3d/datafield.hh:83
T3DInterpolator
Basic Interpolator type for 3D Data.
Definition 3d/interpolator.hh:41
T3DInterpolator::~T3DInterpolator
virtual ~T3DInterpolator()
Definition 3d/interpolator.hh:45
T3DVector
A simple 3D vector type.
Definition 3d/vector.hh:49
EXPORT_3D
#define EXPORT_3D
Definition defines3d.hh:45
NS_MIA_BEGIN
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition defines.hh:33
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
PSplineKernel
std::shared_ptr< CSplineKernel > PSplineKernel
Definition splinekernel.hh:291
parallel.hh
CMutex
std::mutex CMutex
Definition parallelcxx11.hh:34
splinekernel.hh