Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

SplineInterpolation.hpp

Go to the documentation of this file.
00001 /* ImLib3D
00002  * Copyright (c) 2001, ULP-IPB Strasbourg.
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or (at
00007  * your option) any later version.
00008  * 
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * General Public License for more details.
00013  * 
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
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 //FIXME should clean up all the interpollation code... it sucks
00031 
00032 enum InterpolationBoundaryType
00033 {
00034     BOUNDARY_MIRROR,
00035     BOUNDARY_ZERO,// assume image=0 outside, this is not properly implemented ...
00036     BOUNDARY_BACKGROUND// assume image=properties.background outside, this is not properly implemented ...
00037 };
00038 // ********************** SplineInterpolator3D ***********
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 // ***************** type declarations  *****************************
00094 typedef SplineInterpolator3D<float> SplineInterpolator3Df;
00095 
00096 
00097 #include<ImLib3D/SplineInterpolation.hxx>
00098 #endif // _SplineInterpolation_hpp

Generated on Fri Jun 17 13:36:07 2005 for ImLib3D by  doxygen 1.4.2