00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00022 #ifndef _SplineInterpolation_hpp
00023 #define _SplineInterpolation_hpp
00024
00025 #include<ImLib3D/Image3D.hpp>
00026 #include<ImLib3D/Interpolator3D.hpp>
00027
00028 typedef float Scalar;
00029
00030
00031
00032 enum InterpolationBoundaryType
00033 {
00034 BOUNDARY_MIRROR,
00035 BOUNDARY_ZERO,
00036 BOUNDARY_BACKGROUND
00037 };
00038
00040
00044 template<class Im3DValue>
00045 class SplineInterpolator3D : public Interpolator3D<Im3DValue>
00046 {
00047 friend class AdaptativeSuperSampler;
00048 typedef Image3Dlinear<Im3DValue> ImageType;
00049 const ImageType *srcImage;
00050 ImageType *coeffImage;
00051 int splineDegree;
00052 void ConvertToInterpolationCoefficients(vector<Im3DValue> &c,vector<Scalar> &z, Scalar Tolerance);
00053 Im3DValue InitialCausalCoefficient (vector<Im3DValue> &c,Scalar z, Scalar Tolerance);
00054 Im3DValue InitialAntiCausalCoefficient (vector<Im3DValue> &c,Scalar z );
00055 virtual Im3DValue ValueFast(const ImageType &ima,const float x,const float y,const float z);
00056 inline void ComputeInterpolationWeights(Scalar *xWeight,Scalar *yWeight,Scalar *zWeight,float x,float y,float z,int x0,int y0,int z0);
00057 ;
00058 Im3DValue *background;
00059 InterpolationBoundaryType boundary;
00060 public:
00061 void SetBackground(const Im3DValue &bg){background=new Im3DValue(bg);}
00062 int DBGvaluect;
00063 int DBGvaluefastct;
00065 void SamplesToCoefficients(ImageType &ima);
00067 virtual Im3DValue Value(const ImageType &ima,const float x,const float y,const float z);
00068 ImageType *GetCoeffImage(){return coeffImage;}
00069 virtual void Reset(const ImageType *_srcImage)
00070 {
00071 if(coeffImage){delete coeffImage;coeffImage=NULL;}
00072 srcImage=_srcImage;
00073 if(!srcImage){return;}
00074 coeffImage=new ImageType();
00075 *coeffImage=*srcImage;
00076 SamplesToCoefficients(*coeffImage);
00077 }
00078 virtual ~SplineInterpolator3D()
00079 {
00080 if(coeffImage){delete coeffImage;}
00081 }
00082
00083 SplineInterpolator3D(int _splineDegree,InterpolationBoundaryType _boundary=BOUNDARY_MIRROR):
00084 srcImage(NULL),coeffImage(NULL),
00085 splineDegree(_splineDegree),background(NULL),boundary(_boundary)
00086 {
00087 DBGvaluect=1;
00088 DBGvaluefastct=1;
00089 }
00090 };
00091
00092
00093
00094 typedef SplineInterpolator3D<float> SplineInterpolator3Df;
00095
00096
00097 #include<ImLib3D/SplineInterpolation.hxx>
00098 #endif // _SplineInterpolation_hpp