00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __itkBSplineInterpolateImageFunction_h
00022 #define __itkBSplineInterpolateImageFunction_h
00023
00024 #include <vector>
00025
00026 #include "itkImageLinearIteratorWithIndex.h"
00027 #include "itkInterpolateImageFunction.h"
00028 #include "vnl/vnl_matrix.h"
00029
00030 #include "itkBSplineDecompositionImageFilter.h"
00031
00032 namespace itk
00033 {
00067 template <class TImageType, class TCoordRep = float>
00068 class ITK_EXPORT BSplineInterpolateImageFunction :
00069 public InterpolateImageFunction<TImageType,TCoordRep>
00070 {
00071 public:
00073 typedef BSplineInterpolateImageFunction Self;
00074 typedef InterpolateImageFunction<TImageType,TCoordRep> Superclass;
00075 typedef SmartPointer<Self> Pointer;
00076 typedef SmartPointer<const Self> ConstPointer;
00077
00079 itkTypeMacro(BSplineInterpolateImageFunction, InterpolateImageFunction);
00080
00081
00083 itkNewMacro( Self );
00084
00086 typedef typename Superclass::OutputType OutputType;
00087
00089 typedef typename Superclass::InputImageType InputImageType;
00090
00092 itkStaticConstMacro(ImageDimension, unsigned int,Superclass::ImageDimension);
00093
00095 typedef typename Superclass::IndexType IndexType;
00096
00098 typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
00099
00101 typedef typename Superclass::PointType PointType;
00102
00104 typedef itk::ImageLinearIteratorWithIndex<TImageType> Iterator;
00105
00107
00108 typedef itk::BSplineDecompositionImageFilter<TImageType, TImageType>
00109 CoefficientFilter;
00110 typedef typename CoefficientFilter::Pointer CoefficientFilterPointer;
00111
00120 virtual OutputType EvaluateAtContinuousIndex(
00121 const ContinuousIndexType & index ) const;
00122
00124 typedef CovariantVector<OutputType,itkGetStaticConstMacro(ImageDimension)>
00125 CovariantVectorType;
00126
00127 CovariantVectorType EvaluateDerivative( const PointType & point )
00128 {
00129 ContinuousIndexType index;
00130 this->ConvertPointToContinuousIndex( point, index );
00131 return ( this->EvaluateDerivativeAtContinuousIndex( index ) );
00132 }
00133
00134 CovariantVectorType EvaluateDerivativeAtContinuousIndex(
00135 const ContinuousIndexType & x ) const;
00136
00137
00140 void SetSplineOrder(unsigned int SplineOrder);
00141 itkGetMacro(SplineOrder, int);
00142
00143
00145 virtual void SetInputImage(const TImageType * inputData);
00146
00147 protected:
00148 BSplineInterpolateImageFunction();
00149 virtual ~BSplineInterpolateImageFunction() {};
00150 void PrintSelf(std::ostream& os, Indent indent) const;
00151
00152
00153 std::vector<double> m_Scratch;
00154 typename TImageType::SizeType m_DataLength;
00155 unsigned int m_SplineOrder;
00156
00157 typename TImageType::Pointer m_Coefficients;
00158
00159 private:
00161 void SetInterpolationWeights( const ContinuousIndexType & x,
00162 const vnl_matrix<long> & EvaluateIndex,
00163 vnl_matrix<double> & weights,
00164 unsigned int splineOrder ) const;
00165
00167 void SetDerivativeWeights( const ContinuousIndexType & x,
00168 const vnl_matrix<long> & EvaluateIndex,
00169 vnl_matrix<double> & weights,
00170 unsigned int splineOrder ) const;
00171
00174 void GeneratePointsToIndex( );
00175
00177 void DetermineRegionOfSupport( vnl_matrix<long> & evaluateIndex,
00178 const ContinuousIndexType & x,
00179 unsigned int splineOrder ) const;
00180
00183 void ApplyMirrorBoundaryConditions(vnl_matrix<long> & evaluateIndex,
00184 unsigned int splineOrder) const;
00185
00186
00187 Iterator m_CIterator;
00188 unsigned long m_MaxNumberInterpolationPoints;
00189 std::vector<IndexType> m_PointsToIndex;
00190
00191 BSplineInterpolateImageFunction( const Self& );
00192 void operator=( const Self& );
00193 CoefficientFilterPointer m_CoefficientFilter;
00194
00195 };
00196
00197 }
00198
00199 #ifndef ITK_MANUAL_INSTANTIATION
00200 #include "itkBSplineInterpolateImageFunction.txx"
00201 #endif
00202
00203 #endif
00204