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);
00154
00155
00157 virtual void SetInputImage(const TImageType * inputData);
00158
00159 protected:
00160 BSplineInterpolateImageFunction();
00161 virtual ~BSplineInterpolateImageFunction() {};
00162 void operator=( const Self& );
00163 void PrintSelf(std::ostream& os, Indent indent) const;
00164
00165
00166 std::vector<CoefficientDataType> m_Scratch;
00167 typename TImageType::SizeType m_DataLength;
00168 unsigned int m_SplineOrder;
00169
00170 typename CoefficientImageType::ConstPointer m_Coefficients;
00171
00172 private:
00173 BSplineInterpolateImageFunction( const Self& );
00175 void SetInterpolationWeights( const ContinuousIndexType & x,
00176 const vnl_matrix<long> & EvaluateIndex,
00177 vnl_matrix<double> & weights,
00178 unsigned int splineOrder ) const;
00179
00181 void SetDerivativeWeights( const ContinuousIndexType & x,
00182 const vnl_matrix<long> & EvaluateIndex,
00183 vnl_matrix<double> & weights,
00184 unsigned int splineOrder ) const;
00185
00188 void GeneratePointsToIndex( );
00189
00191 void DetermineRegionOfSupport( vnl_matrix<long> & evaluateIndex,
00192 const ContinuousIndexType & x,
00193 unsigned int splineOrder ) const;
00194
00197 void ApplyMirrorBoundaryConditions(vnl_matrix<long> & evaluateIndex,
00198 unsigned int splineOrder) const;
00199
00200
00201 Iterator m_CIterator;
00202 unsigned long m_MaxNumberInterpolationPoints;
00203 std::vector<IndexType> m_PointsToIndex;
00204
00205 CoefficientFilterPointer m_CoefficientFilter;
00206
00207 };
00208
00209 }
00210
00211 #ifndef ITK_MANUAL_INSTANTIATION
00212 #include "itkBSplineInterpolateImageFunction.txx"
00213 #endif
00214
00215 #endif
00216
00217