20 #ifndef MIRTK_InterpolateImageFunction_HXX 21 #define MIRTK_InterpolateImageFunction_HXX 23 #include "mirtk/InterpolateImageFunction.h" 25 #include "mirtk/Voxel.h" 40 template <
class TImage>
47 template <
class TImage>
54 template <
class TImage>
59 const TImage *img = NULL;
61 img =
dynamic_cast<const TImage *
>(image);
63 cerr << this->NameOfClass() <<
"::New(irtkExtrapolationMode): Invalid input image type" << endl;
67 return ExtrapolatorType::New(mode, img);
75 template <
class TImage>
79 if (input && !this->_Input) {
80 cerr << this->NameOfClass() <<
"::Input: Invalid input image type" << endl;
86 template <
class TImage>
91 cerr << this->NameOfClass() <<
"::Initialize: Missing input image" << endl;
93 }
else if (!dynamic_cast<const TImage *>(this->_Input)) {
94 cerr << this->NameOfClass() <<
"::Initialize: Invalid input image type" << endl;
98 if (this->_InfiniteInput) {
99 if (!dynamic_cast<const ExtrapolatorType *>(this->_InfiniteInput)) {
100 cerr << this->NameOfClass() <<
"::Initialize: Invalid extrapolator type" << endl;
109 template <
class TImage>
114 if (input && !dynamic_cast<const ExtrapolatorType *>(this->_InfiniteInput)) {
115 cerr << this->NameOfClass() <<
"::Extrapolator: Invalid extrapolator type" << endl;
125 #define mirtkInterpolatorInstantiations(clsname) \ 126 template class clsname<mirtk::BaseImage>; \ 127 template class clsname<mirtk::GenericImage<mirtk::GreyPixel> >; \ 128 template class clsname<mirtk::GenericImage<float> >; \ 129 template class clsname<mirtk::GenericImage<float2> >; \ 130 template class clsname<mirtk::GenericImage<float3> >; \ 131 template class clsname<mirtk::GenericImage<mirtk::Float3> >; \ 132 template class clsname<mirtk::GenericImage<float3x3> >; \ 133 template class clsname<mirtk::GenericImage<double> >; \ 134 template class clsname<mirtk::GenericImage<double2> >; \ 135 template class clsname<mirtk::GenericImage<double3> >; \ 136 template class clsname<mirtk::GenericImage<mirtk::Double3> >; \ 137 template class clsname<mirtk::GenericImage<double3x3> > 142 #endif // MIRTK_InterpolateImageFunction_HXX 148 #ifndef MIRTK_InterpolateImageFunctionNew_HXX 149 #define MIRTK_InterpolateImageFunctionNew_HXX 152 #include "mirtk/NearestNeighborInterpolateImageFunction.h" 153 #include "mirtk/LinearInterpolateImageFunction.h" 154 #include "mirtk/BSplineInterpolateImageFunction.h" 155 #include "mirtk/CubicBSplineInterpolateImageFunction.h" 156 #include "mirtk/FastCubicBSplineInterpolateImageFunction.h" 157 #include "mirtk/CSplineInterpolateImageFunction.h" 158 #include "mirtk/GaussianInterpolateImageFunction.h" 159 #include "mirtk/SincInterpolateImageFunction.h" 162 #include "mirtk/LinearInterpolateImageFunction2D.h" 163 #include "mirtk/BSplineInterpolateImageFunction2D.h" 164 #include "mirtk/CubicBSplineInterpolateImageFunction2D.h" 165 #include "mirtk/FastCubicBSplineInterpolateImageFunction2D.h" 166 #include "mirtk/CSplineInterpolateImageFunction2D.h" 167 #include "mirtk/GaussianInterpolateImageFunction2D.h" 168 #include "mirtk/SincInterpolateImageFunction2D.h" 171 #include "mirtk/LinearInterpolateImageFunction3D.h" 172 #include "mirtk/BSplineInterpolateImageFunction3D.h" 173 #include "mirtk/CubicBSplineInterpolateImageFunction3D.h" 174 #include "mirtk/FastCubicBSplineInterpolateImageFunction3D.h" 175 #include "mirtk/CSplineInterpolateImageFunction3D.h" 176 #include "mirtk/GaussianInterpolateImageFunction3D.h" 177 #include "mirtk/SincInterpolateImageFunction3D.h" 179 #include "mirtk/ShapeBasedInterpolateImageFunction.h" 182 #include "mirtk/LinearInterpolateImageFunction4D.h" 183 #include "mirtk/BSplineInterpolateImageFunction4D.h" 184 #include "mirtk/CubicBSplineInterpolateImageFunction4D.h" 185 #include "mirtk/FastCubicBSplineInterpolateImageFunction4D.h" 186 #include "mirtk/CSplineInterpolateImageFunction4D.h" 187 #include "mirtk/GaussianInterpolateImageFunction4D.h" 188 #include "mirtk/SincInterpolateImageFunction4D.h" 195 template <
class TImage>
206 if (image->Z() == 1) dim = 2;
207 else if (image->T() == 1 || image->GetTSize() == .0) dim = 3;
214 case Interpolation_NN:
217 case Interpolation_Linear:
218 case Interpolation_FastLinear:
221 case Interpolation_BSpline:
224 case Interpolation_CubicBSpline:
227 case Interpolation_FastCubicBSpline:
230 case Interpolation_CSpline:
233 case Interpolation_Gaussian:
236 case Interpolation_Sinc:
245 case Interpolation_NN:
248 case Interpolation_Linear:
249 case Interpolation_FastLinear:
252 case Interpolation_BSpline:
255 case Interpolation_CubicBSpline:
258 case Interpolation_FastCubicBSpline:
261 case Interpolation_CSpline:
264 case Interpolation_Gaussian:
267 case Interpolation_Sinc:
276 case Interpolation_NN:
279 case Interpolation_Linear:
280 case Interpolation_FastLinear:
283 case Interpolation_BSpline:
286 case Interpolation_CubicBSpline:
289 case Interpolation_FastCubicBSpline:
292 case Interpolation_CSpline:
295 case Interpolation_Gaussian:
298 case Interpolation_Sinc:
307 case Interpolation_NN:
310 case Interpolation_Linear:
311 case Interpolation_FastLinear:
314 case Interpolation_BSpline:
317 case Interpolation_CubicBSpline:
320 case Interpolation_FastCubicBSpline:
323 case Interpolation_CSpline:
326 case Interpolation_Gaussian:
329 case Interpolation_Sinc:
340 p->NumberOfDimensions(dim);
344 cerr <<
"GenericInterpolateImageFunction::New: Interpolation mode (" << mode;
345 cerr <<
") not supported for " << (dim ?
ToString(dim) :
"N") <<
"D images" << endl;
353 template <
class TImage>
360 if (emode != Extrapolation_Default) p->
Extrapolator(p->
New(emode, image),
true);
367 #endif // MIRTK_InterpolateImageFunctionNew_HXX
const ImageType * Input() const
Get input image.
GenericInterpolateImageFunction()
Default constructor.
virtual void Initialize()
virtual void Extrapolator(ExtrapolateImageFunction *, bool=false)
Set extrapolate image function for evaluation outside of image domain.
InterpolationMode
Image interpolation modes.
InterpolationMode InterpolationWithoutPadding(InterpolationMode m)
Get corresponding interpolation without padding.
static GenericInterpolateImageFunction * New(enum InterpolationMode=Interpolation_Default, const TImage *=NULL)
Construct interpolator with default infinite extension of input image.
string ToString(const EnergyMeasure &value, int w, char c, bool left)
Convert energy measure enumeration value to string.
ExtrapolationMode
Image extrapolation modes.
ExtrapolateImageFunction * Extrapolator()
virtual void Input(const BaseImage *)
Set input image.
ExtrapolatorType * Extrapolator()
virtual ~GenericInterpolateImageFunction()
Destructor.
const BaseImage * Input() const
Get input image.