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-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 #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 <mia/core/parallel.hh>
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 C3DWeightCache {
67 
68  C3DWeightCache(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  C3DWeightCache create_cache() const;
117 
125  T operator () (const C3DFVector& x, C3DWeightCache& 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  typename T3DDatafield<T>::value_type m_min;
156  typename T3DDatafield<T>::value_type m_max;
157 
158  mutable CMutex m_cache_lock;
159  mutable C3DWeightCache m_cache;
160 };
161 
162 
172 public:
173 
174 
180  C3DInterpolatorFactory(const std::string& kernel, const std::string& boundary_conditions);
181 
187  C3DInterpolatorFactory(PSplineKernel kernel, const CSplineBoundaryCondition& boundary_conditions);
188 
198  const CSplineBoundaryCondition&xbc,
199  const CSplineBoundaryCondition&ybc,
200  const CSplineBoundaryCondition&zbc);
201 
208  C3DInterpolatorFactory(PSplineKernel kernel, const std::string& bc);
209 
210 
213 
215  C3DInterpolatorFactory& operator = ( const C3DInterpolatorFactory& o);
216 
218  virtual ~C3DInterpolatorFactory();
219 
224  template <class T>
225  T3DConvoluteInterpolator<T> *create(const T3DDatafield<T>& src) const
226  __attribute__ ((warn_unused_result));
227 
229  PSplineKernel get_kernel() const;
230 private:
231  PSplineKernel m_kernel;
235 };
236 
237 // implementation
238 
239 template <class T>
241 {
242  return new T3DConvoluteInterpolator<T>(src, m_kernel, *m_xbc, *m_ybc, *m_zbc);
243 }
244 
246 typedef std::shared_ptr<C3DInterpolatorFactory> P3DInterpolatorFactory;
247 
249 
250 #endif
A templated class of a 3D data field.
Definition: 3d/datafield.hh:82
const TCoeff3D & get_coefficients() const
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:33
#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.
A factory to create interpolators of a given type by providing input data.
std::mutex CMutex
CSplineBoundaryCondition::Pointer PSplineBoundaryCondition
virtual ~T3DInterpolator()
#define NS_MIA_END
conveniance define to end the mia namespace
Definition: defines.hh:36