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 #include "itkConceptChecking.h"
00032
00033 namespace itk
00034 {
00068 template <
00069 class TImageType,
00070 class TCoordRep = float,
00071 class TCoefficientType = double >
00072 class ITK_EXPORT BSplineInterpolateImageFunction :
00073 public InterpolateImageFunction<TImageType,TCoordRep>
00074 {
00075 public:
00077 typedef BSplineInterpolateImageFunction Self;
00078 typedef InterpolateImageFunction<TImageType,TCoordRep> Superclass;
00079 typedef SmartPointer<Self> Pointer;
00080 typedef SmartPointer<const Self> ConstPointer;
00081
00083 itkTypeMacro(BSplineInterpolateImageFunction, InterpolateImageFunction);
00084
00085
00087 itkNewMacro( Self );
00088
00090 typedef typename Superclass::OutputType OutputType;
00091
00093 typedef typename Superclass::InputImageType InputImageType;
00094
00096 itkStaticConstMacro(ImageDimension, unsigned int,Superclass::ImageDimension);
00097
00099 typedef typename Superclass::IndexType IndexType;
00100
00102 typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
00103
00105 typedef typename Superclass::PointType PointType;
00106
00108 typedef itk::ImageLinearIteratorWithIndex<TImageType> Iterator;
00109
00111 typedef TCoefficientType CoefficientDataType;
00112 typedef itk::Image<CoefficientDataType,
00113 itkGetStaticConstMacro(ImageDimension)
00114 > CoefficientImageType;
00115
00117 typedef itk::BSplineDecompositionImageFilter<TImageType, CoefficientImageType>
00118 CoefficientFilter;
00119 typedef typename CoefficientFilter::Pointer CoefficientFilterPointer;
00120
00129 virtual OutputType EvaluateAtContinuousIndex(
00130 const ContinuousIndexType & index ) const;
00131
00133 typedef CovariantVector<OutputType,
00134 itkGetStaticConstMacro(ImageDimension)
00135 > CovariantVectorType;
00136
00137 CovariantVectorType EvaluateDerivative( const PointType & point ) const
00138 {
00139 ContinuousIndexType index;
00140 m_Image->TransformPhysicalPointToContinuousIndex( point, index );
00141 return ( this->EvaluateDerivativeAtContinuousIndex( index ) );
00142 }
00143
00144 CovariantVectorType EvaluateDerivativeAtContinuousIndex(
00145 const ContinuousIndexType & x ) const;
00146
00147
00150 void SetSplineOrder(unsigned int SplineOrder);
00151 itkGetMacro(SplineOrder, int);
00152
00153
00155 virtual void SetInputImage(const TImageType * inputData);
00156
00157 protected:
00158 BSplineInterpolateImageFunction();
00159 virtual ~BSplineInterpolateImageFunction() {};
00160 void PrintSelf(std::ostream& os, Indent indent) const;
00161
00162
00163 std::vector<CoefficientDataType> m_Scratch;
00164 typename TImageType::SizeType m_DataLength;
00165 unsigned int m_SplineOrder;
00166
00167 typename CoefficientImageType::ConstPointer m_Coefficients;
00168
00169 private:
00171 void SetInterpolationWeights( const ContinuousIndexType & x,
00172 const vnl_matrix<long> & EvaluateIndex,
00173 vnl_matrix<double> & weights,
00174 unsigned int splineOrder ) const;
00175
00177 void SetDerivativeWeights( const ContinuousIndexType & x,
00178 const vnl_matrix<long> & EvaluateIndex,
00179 vnl_matrix<double> & weights,
00180 unsigned int splineOrder ) const;
00181
00184 void GeneratePointsToIndex( );
00185
00187 void DetermineRegionOfSupport( vnl_matrix<long> & evaluateIndex,
00188 const ContinuousIndexType & x,
00189 unsigned int splineOrder ) const;
00190
00193 void ApplyMirrorBoundaryConditions(vnl_matrix<long> & evaluateIndex,
00194 unsigned int splineOrder) const;
00195
00196
00197 Iterator m_CIterator;
00198 unsigned long m_MaxNumberInterpolationPoints;
00199 std::vector<IndexType> m_PointsToIndex;
00200
00201 BSplineInterpolateImageFunction( const Self& );
00202 void operator=( const Self& );
00203 CoefficientFilterPointer m_CoefficientFilter;
00204
00205 };
00206
00207 }
00208
00209 #ifndef ITK_MANUAL_INSTANTIATION
00210 #include "itkBSplineInterpolateImageFunction.txx"
00211 #endif
00212
00213 #endif
00214