3d/interpolator.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-2015 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 #ifndef mia_3d_interpolator_hh
22 #define mia_3d_interpolator_hh
23 
24 
25 #include <vector>
26 #include <mia/core/splinekernel.hh>
28 #include <mia/3d/image.hh>
29 #include <tbb/mutex.h>
30 
32 
33 
39 template <typename T>
41 public:
42 
44  virtual ~T3DInterpolator(){}
45 
50  virtual T operator () (const C3DFVector& x) const = 0;
51 
52 };
53 
57 template <class U>
58 struct coeff_map<T3DVector<U> > {
59  typedef T3DVector<U> value_type;
60  typedef C3DDVector coeff_type;
61 };
62 
63 struct CWeightCache {
67 
68  CWeightCache(int kernel_size,
69  const CSplineBoundaryCondition& xbc,
70  const CSplineBoundaryCondition& ybc,
71  const CSplineBoundaryCondition& zbc);
72 };
74 
81 template <class T>
83 public:
87 
94 
104  const CSplineBoundaryCondition& xbc,
105  const CSplineBoundaryCondition& ybc,
106  const CSplineBoundaryCondition& zbc);
107 
110 
116  CWeightCache create_cache() const;
117 
125  T operator () (const C3DFVector& x, CWeightCache& cache) const;
126 
133  T operator () (const C3DFVector& x) const;
134 
135 
137  const TCoeff3D& get_coefficients() const {
138  return m_coeff;
139  }
140 
141 protected:
143  typedef std::vector< typename TCoeff3D::value_type > coeff_vector;
144 private:
145 
146  void prefilter(const T3DDatafield<T>& image);
147 
148  TCoeff3D m_coeff;
149  C3DBounds m_size2;
150  PSplineKernel m_kernel;
154 
155  T m_min;
156  T m_max;
157 
158  mutable tbb::mutex m_cache_lock;
159  mutable CSplineKernel::SCache m_x_cache;
160  mutable CSplineKernel::SCache m_y_cache;
161  mutable CSplineKernel::SCache m_z_cache;
162 };
163 
164 
174 public:
175 
176 
182  C3DInterpolatorFactory(const std::string& kernel, const std::string& boundary_conditions);
183 
189  C3DInterpolatorFactory(PSplineKernel kernel, const CSplineBoundaryCondition& boundary_conditions);
190 
200  const CSplineBoundaryCondition&xbc,
201  const CSplineBoundaryCondition&ybc,
202  const CSplineBoundaryCondition&zbc);
203 
210  C3DInterpolatorFactory(PSplineKernel kernel, const std::string& bc);
211 
212 
215 
217  C3DInterpolatorFactory& operator = ( const C3DInterpolatorFactory& o);
218 
220  virtual ~C3DInterpolatorFactory();
221 
226  template <class T>
227  T3DConvoluteInterpolator<T> *create(const T3DDatafield<T>& src) const
228  __attribute__ ((warn_unused_result));
229 
231  PSplineKernel get_kernel() const;
232 private:
233  PSplineKernel m_kernel;
237 };
238 
239 
241  __attribute__ ((warn_unused_result));
242 
243 // implementation
244 
245 template <class T>
247 {
248  return new T3DConvoluteInterpolator<T>(src, m_kernel, *m_xbc, *m_ybc, *m_zbc);
249 }
250 
252 typedef std::shared_ptr<C3DInterpolatorFactory> P3DInterpolatorFactory;
253 
255 
256 #endif
A templated class of a 3D data field.
Definition: 3d/datafield.hh:74
EXPORT_3D C3DInterpolatorFactory * create_3dinterpolation_factory(EInterpolation type, EBoundaryConditions bc) __attribute__((warn_unused_result))
Interpolator that is based on convolution,like b-splines an o-moms.
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition: defines.hh:43
const TCoeff3D & get_coefficients() const
#define EXPORT_3D
Definition: defines3d.hh:44
T3DDatafield< typename coeff_map< T >::coeff_type > TCoeff3D
std::shared_ptr< CSplineKernel > PSplineKernel
T3DConvoluteInterpolator< T > * create(const T3DDatafield< T > &src) const __attribute__((warn_unused_result))
std::vector< typename TCoeff3D::value_type > coeff_vector
helper class for filtering
std::shared_ptr< C3DInterpolatorFactory > P3DInterpolatorFactory
Pointer type of the 3D interpolation factory.
Abstract base class for B-spline interpolation boundary conditions.
Basic Interpolator type for 3D Data.
EBoundaryConditions
A factory to create interpolators of a given type by providing input data.
EInterpolation
some constants for interpoation types
Definition: defines.hh:71
CSplineBoundaryCondition::Pointer PSplineBoundaryCondition
virtual ~T3DInterpolator()
#define NS_MIA_END
conveniance define to end the mia namespace
Definition: defines.hh:46