00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __itkBSplineInterpolateImageFunction_h
00021 #define __itkBSplineInterpolateImageFunction_h
00022
00023
00024
00025
00026 #include "itkConfigure.h"
00027
00028 #ifdef ITK_USE_OPTIMIZED_REGISTRATION_METHODS
00029 #include "itkOptBSplineInterpolateImageFunction.h"
00030 #else
00031
00032 #include <vector>
00033
00034 #include "itkImageLinearIteratorWithIndex.h"
00035 #include "itkInterpolateImageFunction.h"
00036 #include "vnl/vnl_matrix.h"
00037
00038 #include "itkBSplineDecompositionImageFilter.h"
00039 #include "itkConceptChecking.h"
00040 #include "itkCovariantVector.h"
00041
00042 namespace itk
00043 {
00077 template <
00078 class TImageType,
00079 class TCoordRep = double,
00080 class TCoefficientType = double >
00081 class ITK_EXPORT BSplineInterpolateImageFunction :
00082 public InterpolateImageFunction<TImageType,TCoordRep>
00083 {
00084 public:
00086 typedef BSplineInterpolateImageFunction Self;
00087 typedef InterpolateImageFunction<TImageType,TCoordRep> Superclass;
00088 typedef SmartPointer<Self> Pointer;
00089 typedef SmartPointer<const Self> ConstPointer;
00090
00092 itkTypeMacro(BSplineInterpolateImageFunction, InterpolateImageFunction);
00093
00094
00096 itkNewMacro( Self );
00097
00099 typedef typename Superclass::OutputType OutputType;
00100
00102 typedef typename Superclass::InputImageType InputImageType;
00103
00105 itkStaticConstMacro(ImageDimension, unsigned int,Superclass::ImageDimension);
00106
00108 typedef typename Superclass::IndexType IndexType;
00109
00111 typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
00112
00114 typedef typename Superclass::PointType PointType;
00115
00117 typedef ImageLinearIteratorWithIndex<TImageType> Iterator;
00118
00120 typedef TCoefficientType CoefficientDataType;
00121 typedef Image<CoefficientDataType,
00122 itkGetStaticConstMacro(ImageDimension)
00123 > CoefficientImageType;
00124
00126 typedef BSplineDecompositionImageFilter<TImageType, CoefficientImageType>
00127 CoefficientFilter;
00128
00129 typedef typename CoefficientFilter::Pointer CoefficientFilterPointer;
00130
00139 virtual OutputType EvaluateAtContinuousIndex(
00140 const ContinuousIndexType & index ) const;
00141
00143 typedef CovariantVector<OutputType,
00144 itkGetStaticConstMacro(ImageDimension)
00145 > CovariantVectorType;
00146
00147 CovariantVectorType EvaluateDerivative( const PointType & point ) const
00148 {
00149 ContinuousIndexType index;
00150 this->GetInputImage()->TransformPhysicalPointToContinuousIndex( point, index );
00151 return ( this->EvaluateDerivativeAtContinuousIndex( index ) );
00152 }
00153
00154 CovariantVectorType EvaluateDerivativeAtContinuousIndex(
00155 const ContinuousIndexType & x ) const;
00156
00157
00160 void SetSplineOrder(unsigned int SplineOrder);
00161 itkGetConstMacro(SplineOrder, int);
00163
00164
00166 virtual void SetInputImage(const TImageType * inputData);
00167
00168
00177 itkSetMacro( UseImageDirection, bool );
00178 itkGetMacro( UseImageDirection, bool );
00179 itkBooleanMacro( UseImageDirection );
00181
00182
00183 protected:
00184 BSplineInterpolateImageFunction();
00185 virtual ~BSplineInterpolateImageFunction() {};
00186 void operator=( const Self& );
00187 void PrintSelf(std::ostream& os, Indent indent) const;
00188
00189
00190 std::vector<CoefficientDataType> m_Scratch;
00191 typename TImageType::SizeType m_DataLength;
00192 unsigned int m_SplineOrder;
00193
00194 typename CoefficientImageType::ConstPointer m_Coefficients;
00195
00196 private:
00197 BSplineInterpolateImageFunction( const Self& );
00199 void SetInterpolationWeights( const ContinuousIndexType & x,
00200 const vnl_matrix<long> & EvaluateIndex,
00201 vnl_matrix<double> & weights,
00202 unsigned int splineOrder ) const;
00203
00205 void SetDerivativeWeights( const ContinuousIndexType & x,
00206 const vnl_matrix<long> & EvaluateIndex,
00207 vnl_matrix<double> & weights,
00208 unsigned int splineOrder ) const;
00209
00212 void GeneratePointsToIndex( );
00213
00215 void DetermineRegionOfSupport( vnl_matrix<long> & evaluateIndex,
00216 const ContinuousIndexType & x,
00217 unsigned int splineOrder ) const;
00218
00221 void ApplyMirrorBoundaryConditions(vnl_matrix<long> & evaluateIndex,
00222 unsigned int splineOrder) const;
00223
00224
00225 Iterator m_CIterator;
00226 unsigned long m_MaxNumberInterpolationPoints;
00227 std::vector<IndexType> m_PointsToIndex;
00228
00229 CoefficientFilterPointer m_CoefficientFilter;
00230
00231
00232
00233 bool m_UseImageDirection;
00234
00235 };
00236
00237 }
00238
00239 #ifndef ITK_MANUAL_INSTANTIATION
00240 #include "itkBSplineInterpolateImageFunction.txx"
00241 #endif
00242
00243 #endif
00244
00245 #endif
00246