20 #ifndef MIRTK_ImageGradientFunction_HXX 21 #define MIRTK_ImageGradientFunction_HXX 23 #include "mirtk/ImageGradientFunction.h" 38 template <
class TImage>
45 template <
class TImage>
52 template <
class TImage>
57 const TImage *img = NULL;
59 img =
dynamic_cast<const TImage *
>(image);
61 cerr << this->NameOfClass() <<
"::New(irtkExtrapolationMode): Invalid input image type" << endl;
65 return ExtrapolatorType::New(mode, img);
73 template <
class TImage>
77 if (input && !this->_Input) {
78 cerr << this->NameOfClass() <<
"::Input: Invalid input image type" << endl;
84 template <
class TImage>
89 cerr << this->NameOfClass() <<
"::Initialize: Missing input image" << endl;
91 }
else if (!dynamic_cast<const TImage *>(this->_Input)) {
92 cerr << this->NameOfClass() <<
"::Initialize: Invalid input image type" << endl;
96 if (this->_InfiniteInput) {
97 if (!dynamic_cast<const ExtrapolatorType *>(this->_InfiniteInput)) {
98 cerr << this->NameOfClass() <<
"::Initialize: Invalid extrapolator type" << endl;
107 template <
class TImage>
112 if (input && !dynamic_cast<const ExtrapolatorType *>(this->_InfiniteInput)) {
113 cerr << this->NameOfClass() <<
"::Extrapolator: Invalid extrapolator type" << endl;
123 #define mirtkGradientInterpolatorInstantiations(clsname) \ 124 template class clsname<mirtk::BaseImage>; \ 125 template class clsname<mirtk::GenericImage<mirtk::GreyPixel> >; \ 126 template class clsname<mirtk::GenericImage<float> >; \ 127 template class clsname<mirtk::GenericImage<double> > 132 #endif // MIRTK_ImageGradientFunction_HXX 138 #ifndef MIRTK_ImageGradientFunctionNew_HXX 139 #define MIRTK_ImageGradientFunctionNew_HXX 141 #include "mirtk/LinearImageGradientFunction.h" 142 #include "mirtk/LinearImageGradientFunction2D.h" 143 #include "mirtk/LinearImageGradientFunction3D.h" 145 #include "mirtk/FastLinearImageGradientFunction.h" 146 #include "mirtk/FastLinearImageGradientFunction2D.h" 147 #include "mirtk/FastLinearImageGradientFunction3D.h" 154 template <
class TImage>
165 if (image->Z() == 1) dim = 2;
166 else if (image->T() == 1 || image->GetTSize() == .0) dim = 3;
173 case Interpolation_Linear:
176 case Interpolation_FastLinear:
185 case Interpolation_Linear:
188 case Interpolation_FastLinear:
197 case Interpolation_Linear:
200 case Interpolation_FastLinear:
211 p->NumberOfDimensions(dim);
215 cerr <<
"GenericImageGradientFunction::New: Interpolation mode (" << mode;
216 cerr <<
") not supported for " << (dim ?
ToString(dim) :
"N") <<
"D images" << endl;
224 template <
class TImage>
231 if (emode != Extrapolation_Default) p->
Extrapolator(p->
New(emode, image),
true);
238 #endif // MIRTK_ImageGradientFunctionNew_HXX virtual ~GenericImageGradientFunction()
Destructor.
const ImageType * Input() const
Get input image.
ExtrapolatorType * Extrapolator()
virtual void Input(const BaseImage *)
Set input image.
virtual void Initialize(bool coeff=false)
ExtrapolateImageFunction * Extrapolator()
InterpolationMode
Image interpolation modes.
static GenericImageGradientFunction * New(enum InterpolationMode, const TImage *=NULL)
Construct interpolator with default infinite extension of input image.
GenericImageGradientFunction()
Default constructor.
virtual void Extrapolator(ExtrapolateImageFunction *, bool=false)
Set extrapolate image function for evaluation outside of image domain.
InterpolationMode InterpolationWithoutPadding(InterpolationMode m)
Get corresponding interpolation without padding.
string ToString(const EnergyMeasure &value, int w, char c, bool left)
Convert energy measure enumeration value to string.
ExtrapolationMode
Image extrapolation modes.
virtual void Initialize(bool coeff=false)
const BaseImage * Input() const
Get input image.