/vol/vipdata/irtk/image++/include/irtkInterpolateImageFunction.h

00001 /*=========================================================================
00002 
00003   Library   : Image Registration Toolkit (IRTK)
00004   Module    : $Id: irtkInterpolateImageFunction.h 8 2009-03-02 16:12:58Z dr $
00005   Copyright : Imperial College, Department of Computing
00006               Visual Information Processing (VIP), 2008 onwards
00007   Date      : $Date: 2009-03-02 16:12:58 +0000 (Mon, 02 Mar 2009) $
00008   Version   : $Revision: 8 $
00009   Changes   : $Author: dr $
00010 
00011 =========================================================================*/
00012 
00013 #ifndef _IRTKINTERPOLATEIMAGEFUNCTION_H
00014 
00015 #define _IRTKINTERPOLATEIMAGEFUNCTION_H
00016 
00018 typedef enum { Interpolation_NN,
00019                Interpolation_Linear,
00020                Interpolation_BSpline,
00021                Interpolation_CSpline,
00022                Interpolation_Sinc,
00023                Interpolation_Gaussian
00024              } irtkInterpolationMode;
00025 
00034 class irtkInterpolateImageFunction : public irtkImageFunction
00035 {
00036 
00037 protected:
00038 
00041   int _clamped;
00042 
00044   double _min, _max;
00045 
00048   double _x1, _y1, _z1, _x2, _y2, _z2;
00049 
00050 public:
00051 
00053   irtkInterpolateImageFunction();
00054 
00056   virtual ~irtkInterpolateImageFunction();
00057 
00059   static irtkInterpolateImageFunction *New(irtkInterpolationMode,
00060       irtkBaseImage *);
00061 
00064   virtual void Initialize();
00065 
00067   virtual double Evaluate(double, double, double, double = 0) = 0;
00068 
00072   virtual double EvaluateInside(double, double, double, double = 0) = 0;
00073 
00077   virtual Bool IsInside(double, double, double);
00078 
00081   virtual void Inside(double &, double &, double &,
00082                       double &, double &, double &);
00083 
00084 };
00085 
00086 inline Bool irtkInterpolateImageFunction::IsInside(double x, double y, double z)
00087 {
00088   return ((x > _x1) && (x < _x2) && (y > _y1) && (y < _y2) &&
00089           (z > _z1) && (z < _z2));
00090 }
00091 
00092 inline void irtkInterpolateImageFunction::Inside(double &x1, double &y1, double &z1, double &x2, double &y2, double &z2)
00093 {
00094   x1 = _x1;
00095   y1 = _y1;
00096   z1 = _z1;
00097   x2 = _x2;
00098   y2 = _y2;
00099   z2 = _z2;
00100 }
00101 
00102 #include <irtkNearestNeighborInterpolateImageFunction.h>
00103 #include <irtkLinearInterpolateImageFunction.h>
00104 #include <irtkBSplineInterpolateImageFunction.h>
00105 #include <irtkCSplineInterpolateImageFunction.h>
00106 #include <irtkSincInterpolateImageFunction.h>
00107 #include <irtkGaussianInterpolateImageFunction.h>
00108 
00109 #include <irtkNearestNeighborInterpolateImageFunction2D.h>
00110 #include <irtkLinearInterpolateImageFunction2D.h>
00111 #include <irtkBSplineInterpolateImageFunction2D.h>
00112 #include <irtkCSplineInterpolateImageFunction2D.h>
00113 #include <irtkSincInterpolateImageFunction2D.h>
00114 #include <irtkGaussianInterpolateImageFunction2D.h>
00115 
00116 #endif