/usr/include/mia-2.2/mia/3d/interpolator.hh is in libmia-2.2-dev 2.2.7-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | /* -*- mia-c++ -*-
*
* This file is part of MIA - a toolbox for medical image analysis
* Copyright (c) Leipzig, Madrid 1999-2015 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 <tbb/mutex.h>
NS_MIA_BEGIN
/**
\ingroup interpol
\tparam T data type to be interpolated
\brief Basic Interpolator type for 3D Data.
*/
template <typename T>
class EXPORT_3D T3DInterpolator {
public:
/** a virtual destructor is neccessary for some of the interpolators */
virtual ~T3DInterpolator(){}
/**
\param x location of data value to read
\returns interpolated value at location x
*/
virtual T operator () (const C3DFVector& x) const = 0;
};
/**
@cond INTERNAL
*/
template <class U>
struct coeff_map<T3DVector<U> > {
typedef T3DVector<U> value_type;
typedef C3DDVector coeff_type;
};
struct CWeightCache {
CSplineKernel::SCache x;
CSplineKernel::SCache y;
CSplineKernel::SCache z;
CWeightCache(int kernel_size,
const CSplineBoundaryCondition& xbc,
const CSplineBoundaryCondition& ybc,
const CSplineBoundaryCondition& zbc);
};
/// @endcond
/**
\ingroup interpol
\tparam T data type to be interpolated
\brief Interpolator that is based on convolution,like b-splines an o-moms.
*/
template <class T>
class EXPORT_3D T3DConvoluteInterpolator: public T3DInterpolator<T> {
public:
/** type how the coefficients are stored - this is done to use a higher accuracy
if the input data is not of double floating point precicion */
typedef T3DDatafield< typename coeff_map< T >::coeff_type > TCoeff3D;
/**
Create the interpolator from the input data and a given kernel
\param data
\param kernel
*/
T3DConvoluteInterpolator(const T3DDatafield<T>& data, PSplineKernel kernel);
/**
Construtor to prefilter the input for proper interpolation
\param data the data used for interpolation
\param kernel the spline kernel used for interpolation
\param xbc boundary conditions to be applied along the x-axis when interpolating
\param ybc boundary conditions to be applied along the y-axis when interpolating
\param zbc boundary conditions to be applied along the z-axis when interpolating
*/
T3DConvoluteInterpolator(const T3DDatafield<T>& data, PSplineKernel kernel,
const CSplineBoundaryCondition& xbc,
const CSplineBoundaryCondition& ybc,
const CSplineBoundaryCondition& zbc);
/// Standart constructor for factory prototyping
~T3DConvoluteInterpolator();
/**
Create the cache structure needed to run the interpolation in a multi-threaded
environment. This function must be called in each thread once.
\returns the cache structure
*/
CWeightCache create_cache() const;
/**
get the interpolated value at a given location \a x
\param x
\param cache the cache structure created by calling create_cache()-
\returns the interpolated value
\remark This method is thread save if the cache structure is thread local
*/
T operator () (const C3DFVector& x, CWeightCache& cache) const;
/**
get the interpolated value at a given location \a x
\param x
\returns the interpolated value
\remark This method is not thread save
*/
T operator () (const C3DFVector& x) const;
/// \returns the coefficients
const TCoeff3D& get_coefficients() const {
return m_coeff;
}
protected:
/// helper class for filtering
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;
T m_min;
T m_max;
mutable tbb::mutex m_cache_lock;
mutable CSplineKernel::SCache m_x_cache;
mutable CSplineKernel::SCache m_y_cache;
mutable CSplineKernel::SCache m_z_cache;
};
/**
\ingroup interpol
@brief A factory to create interpolators of a given type by providing input data.
*/
class EXPORT_3D C3DInterpolatorFactory {
public:
/**
Construct the factory the interpolation kernel and according boundary conditions
\param kernel description of the interpolation kernel
\param boundary_conditions description of the boundary conditions
*/
C3DInterpolatorFactory(const std::string& kernel, const std::string& boundary_conditions);
/**
Construct the factory the interpolation kernel and according boundary conditions
\param kernel description of the interpolation kernel
\param boundary_conditions boundary condition proto type
*/
C3DInterpolatorFactory(PSplineKernel kernel, const CSplineBoundaryCondition& boundary_conditions);
/**
Construct the factory the interpolation kernel and according boundary conditions
\param kernel
\param xbc boundary conditions along the x-axis
\param ybc boundary conditions along the y-axis
\param zbc boundary conditions along the z-axis
*/
C3DInterpolatorFactory(PSplineKernel kernel,
const CSplineBoundaryCondition&xbc,
const CSplineBoundaryCondition&ybc,
const CSplineBoundaryCondition&zbc);
/**
Construct the factory from an interpolation kernel and according boundary conditions description
\param kernel interpolation kernel
\param bc description of the boundary conditions
*/
C3DInterpolatorFactory(PSplineKernel kernel, const std::string& bc);
/// Copy constructor
C3DInterpolatorFactory(const C3DInterpolatorFactory& o);
/// Assignment operator
C3DInterpolatorFactory& operator = ( const C3DInterpolatorFactory& o);
/// \remark why do I need a virtual destructor here?
virtual ~C3DInterpolatorFactory();
/**
\param src input data
\returns an interpolator with the given input data and the predefined interpolation type
*/
template <class T>
T3DConvoluteInterpolator<T> *create(const T3DDatafield<T>& src) const
__attribute__ ((warn_unused_result));
/// @returns the B-spline kernel used for interpolator creation
PSplineKernel get_kernel() const;
private:
PSplineKernel m_kernel;
PSplineBoundaryCondition m_xbc;
PSplineBoundaryCondition m_ybc;
PSplineBoundaryCondition m_zbc;
};
EXPORT_3D C3DInterpolatorFactory *create_3dinterpolation_factory(EInterpolation type, EBoundaryConditions bc)
__attribute__ ((warn_unused_result));
// 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);
}
/// Pointer type of the 3D interpolation factory
typedef std::shared_ptr<C3DInterpolatorFactory> P3DInterpolatorFactory;
NS_MIA_END
#endif
|