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-2013 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 
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 CSplineKernel::SCache m_x_cache;
159  mutable CSplineKernel::SCache m_y_cache;
160  mutable CSplineKernel::SCache m_z_cache;
161 };
162 
163 
173 public:
174 
175 
181  C3DInterpolatorFactory(const std::string& kernel, const std::string& boundary_conditions);
182 
188  C3DInterpolatorFactory(PSplineKernel kernel, const CSplineBoundaryCondition& boundary_conditions);
189 
199  const CSplineBoundaryCondition&xbc,
200  const CSplineBoundaryCondition&ybc,
201  const CSplineBoundaryCondition&zbc);
202 
209  C3DInterpolatorFactory(PSplineKernel kernel, const std::string& bc);
210 
211 
214 
216  C3DInterpolatorFactory& operator = ( const C3DInterpolatorFactory& o);
217 
219  virtual ~C3DInterpolatorFactory();
220 
225  template <class T>
226  T3DConvoluteInterpolator<T> *create(const T3DDatafield<T>& src) const
227  __attribute__ ((warn_unused_result));
228 
230  PSplineKernel get_kernel() const;
231 private:
232  PSplineKernel m_kernel;
236 };
237 
238 
240  __attribute__ ((warn_unused_result));
241 
242 // implementation
243 
244 template <class T>
246 {
247  return new T3DConvoluteInterpolator<T>(src, m_kernel, *m_xbc, *m_ybc, *m_zbc);
248 }
249 
251 typedef std::shared_ptr<C3DInterpolatorFactory> P3DInterpolatorFactory;
252 
254 
255 #endif