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