My Project
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>
28#include <mia/3d/image.hh>
29#include <mia/core/parallel.hh>
30
32
33
39template <typename T>
41{
42public:
43
45 virtual ~T3DInterpolator() {}
46
51 virtual T operator () (const C3DFVector& x) const = 0;
52
53};
54
58template <class U>
59struct coeff_map<T3DVector<U>> {
60 typedef T3DVector<U> value_type;
61 typedef C3DDVector coeff_type;
62};
63
64struct C3DWeightCache {
68
69 C3DWeightCache(int kernel_size,
70 const CSplineBoundaryCondition& xbc,
71 const CSplineBoundaryCondition& ybc,
72 const CSplineBoundaryCondition& zbc);
73};
75
82template <class T>
84{
85public:
89
96
106 const CSplineBoundaryCondition& xbc,
107 const CSplineBoundaryCondition& ybc,
108 const CSplineBoundaryCondition& zbc);
109
112
118 C3DWeightCache create_cache() const;
119
127 T operator () (const C3DFVector& x, C3DWeightCache& cache) const;
128
135 T operator () (const C3DFVector& x) const;
136
137
140 {
141 return m_coeff;
142 }
143
144protected:
146 typedef std::vector< typename TCoeff3D::value_type > coeff_vector;
147private:
148
149 void prefilter(const T3DDatafield<T>& image);
150
151 TCoeff3D m_coeff;
152 C3DBounds m_size2;
153 PSplineKernel m_kernel;
157
158 typename T3DDatafield<T>::value_type m_min;
159 typename T3DDatafield<T>::value_type m_max;
160
161 mutable CMutex m_cache_lock;
162 mutable C3DWeightCache m_cache;
163};
164
165
175{
176public:
177
178
184 C3DInterpolatorFactory(const std::string& kernel, const std::string& boundary_conditions);
185
192
202 const CSplineBoundaryCondition& xbc,
203 const CSplineBoundaryCondition& ybc,
204 const CSplineBoundaryCondition& zbc);
205
212 C3DInterpolatorFactory(PSplineKernel kernel, const std::string& bc);
213
214
217
220
223
228 template <class T>
229 T3DConvoluteInterpolator<T> *create(const T3DDatafield<T>& src) const
230 __attribute__ ((warn_unused_result));
231
234private:
235 PSplineKernel m_kernel;
239};
240
241// implementation
242
243template <class T>
245{
246 return new T3DConvoluteInterpolator<T>(src, m_kernel, *m_xbc, *m_ybc, *m_zbc);
247}
248
250typedef std::shared_ptr<C3DInterpolatorFactory> P3DInterpolatorFactory;
251
253
254#endif
std::shared_ptr< C3DInterpolatorFactory > P3DInterpolatorFactory
Pointer type of the 3D interpolation factory.
A factory to create interpolators of a given type by providing input data.
virtual ~C3DInterpolatorFactory()
C3DInterpolatorFactory(PSplineKernel kernel, const CSplineBoundaryCondition &xbc, const CSplineBoundaryCondition &ybc, const CSplineBoundaryCondition &zbc)
C3DInterpolatorFactory(PSplineKernel kernel, const std::string &bc)
T3DConvoluteInterpolator< T > * create(const T3DDatafield< T > &src) const __attribute__((warn_unused_result))
C3DInterpolatorFactory(const std::string &kernel, const std::string &boundary_conditions)
C3DInterpolatorFactory(PSplineKernel kernel, const CSplineBoundaryCondition &boundary_conditions)
C3DInterpolatorFactory(const C3DInterpolatorFactory &o)
Copy constructor.
PSplineKernel get_kernel() const
Abstract base class for B-spline interpolation boundary conditions.
Interpolator that is based on convolution,like b-splines an o-moms.
std::vector< typename TCoeff3D::value_type > coeff_vector
helper class for filtering
~T3DConvoluteInterpolator()
Standart constructor for factory prototyping.
const TCoeff3D & get_coefficients() const
T3DConvoluteInterpolator(const T3DDatafield< T > &data, PSplineKernel kernel)
T3DDatafield< typename coeff_map< T >::coeff_type > TCoeff3D
T3DConvoluteInterpolator(const T3DDatafield< T > &data, PSplineKernel kernel, const CSplineBoundaryCondition &xbc, const CSplineBoundaryCondition &ybc, const CSplineBoundaryCondition &zbc)
C3DWeightCache create_cache() const
A templated class of a 3D data field.
Definition: 3d/datafield.hh:83
Basic Interpolator type for 3D Data.
virtual ~T3DInterpolator()
#define EXPORT_3D
Definition: defines3d.hh:45
#define NS_MIA_BEGIN
conveniance define to start the mia namespace
Definition: defines.hh:33
#define NS_MIA_END
conveniance define to end the mia namespace
Definition: defines.hh:36
CSplineBoundaryCondition::Pointer PSplineBoundaryCondition
std::shared_ptr< CSplineKernel > PSplineKernel
std::mutex CMutex