00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __itkBSplineDeformableTransform_h
00019 #define __itkBSplineDeformableTransform_h
00020
00021 #include <iostream>
00022 #include "itkTransform.h"
00023 #include "itkImage.h"
00024 #include "itkImageRegion.h"
00025 #include "itkBSplineInterpolationWeightFunction.h"
00026
00027 namespace itk
00028 {
00029
00067 template <
00068 class TScalarType = double,
00069 unsigned int NDimensions = 3,
00070 unsigned int VSplineOrder = 3 >
00071 class BSplineDeformableTransform :
00072 public Transform< TScalarType, NDimensions, NDimensions >
00073 {
00074 public:
00076 typedef BSplineDeformableTransform Self;
00077 typedef Transform< TScalarType, NDimensions, NDimensions > Superclass;
00078 typedef SmartPointer<Self> Pointer;
00079 typedef SmartPointer<const Self> ConstPointer;
00080
00082 itkNewMacro( Self );
00083
00085 itkTypeMacro( BSplineDeformableTransform, Transform );
00086
00088 itkStaticConstMacro(SpaceDimension, unsigned int, NDimensions);
00089
00091 itkStaticConstMacro(SplineOrder, unsigned int, VSplineOrder);
00092
00094 typedef typename Superclass::ScalarType ScalarType;
00095
00097 typedef typename Superclass::ParametersType ParametersType;
00098
00100 typedef typename Superclass::JacobianType JacobianType;
00101
00103 typedef Vector<TScalarType,
00104 itkGetStaticConstMacro(SpaceDimension)> InputVectorType;
00105 typedef Vector<TScalarType,
00106 itkGetStaticConstMacro(SpaceDimension)> OutputVectorType;
00107
00109 typedef CovariantVector<TScalarType,
00110 itkGetStaticConstMacro(SpaceDimension)> InputCovariantVectorType;
00111 typedef CovariantVector<TScalarType,
00112 itkGetStaticConstMacro(SpaceDimension)> OutputCovariantVectorType;
00113
00115 typedef vnl_vector_fixed<TScalarType,
00116 itkGetStaticConstMacro(SpaceDimension)> InputVnlVectorType;
00117 typedef vnl_vector_fixed<TScalarType,
00118 itkGetStaticConstMacro(SpaceDimension)> OutputVnlVectorType;
00119
00121 typedef Point<TScalarType,
00122 itkGetStaticConstMacro(SpaceDimension)> InputPointType;
00123 typedef Point<TScalarType,
00124 itkGetStaticConstMacro(SpaceDimension)> OutputPointType;
00125
00143 void SetParameters(const ParametersType & parameters);
00144
00146 virtual const ParametersType& GetParameters(void) const;
00147
00149 typedef ImageRegion<itkGetStaticConstMacro(SpaceDimension)> RegionType;
00150 typedef typename RegionType::IndexType IndexType;
00151 typedef typename RegionType::SizeType SizeType;
00152 typedef FixedArray<double> SpacingType;
00153 typedef FixedArray<double> OriginType;
00154
00156 virtual void SetGridRegion( const RegionType& region );
00157 itkGetMacro( GridRegion, RegionType );
00158
00160 virtual void SetGridSpacing( const SpacingType& spacing );
00161 itkGetMacro( GridSpacing, SpacingType );
00162
00164 virtual void SetGridOrigin( const OriginType& origin );
00165 itkGetMacro( GridOrigin, OriginType );
00166
00168 typedef Transform<ScalarType,itkGetStaticConstMacro(SpaceDimension),
00169 itkGetStaticConstMacro(SpaceDimension)> BulkTransformType;
00170 typedef typename BulkTransformType::ConstPointer BulkTransformPointer;
00171
00175 itkSetConstObjectMacro( BulkTransform, BulkTransformType );
00176 itkGetConstObjectMacro( BulkTransform, BulkTransformType );
00177
00179 OutputPointType TransformPoint(const InputPointType &point ) const;
00180
00182 typedef BSplineInterpolationWeightFunction<ScalarType,
00183 itkGetStaticConstMacro(SpaceDimension),
00184 itkGetStaticConstMacro(SplineOrder)> WeightsFunctionType;
00185 typedef typename WeightsFunctionType::WeightsType WeightsType;
00186 typedef typename WeightsFunctionType::ContinuousIndexType ContinuousIndexType;
00187
00193 void TransformPoint( const InputPointType & inputPoint,
00194 OutputPointType & outputPoint,
00195 WeightsType & weights,
00196 IndexType & startIndex, bool & inside ) const;
00197
00199 unsigned long GetNumberOfWeights() const
00200 { return m_WeightsFunction->GetNumberOfWeights(); }
00201
00203 virtual OutputVectorType TransformVector(const InputVectorType &vector) const
00204 {
00205 itkExceptionMacro(<< "Method not applicable for deformable transform." );
00206 return OutputVectorType();
00207 }
00208
00210 virtual OutputVnlVectorType TransformVector(const InputVnlVectorType &vector) const
00211 {
00212 itkExceptionMacro(<< "Method not applicable for deformable transform. ");
00213 return OutputVnlVectorType();
00214 }
00215
00217 virtual OutputCovariantVectorType TransformCovariantVector(
00218 const InputCovariantVectorType &vector) const
00219 {
00220 itkExceptionMacro(<< "Method not applicable for deformable transfrom. ");
00221 return OutputCovariantVectorType();
00222 }
00223
00225 void PrintSelf(std::ostream &os, Indent indent) const;
00226
00228 virtual const JacobianType& GetJacobian(const InputPointType &point ) const;
00229
00231 unsigned int virtual GetNumberOfParameters(void) const;
00232
00233 protected:
00234 BSplineDeformableTransform();
00235 ~BSplineDeformableTransform();
00236
00237 private:
00238 BSplineDeformableTransform(const Self&);
00239 void operator=(const Self&);
00240
00242 BulkTransformPointer m_BulkTransform;
00243
00245 RegionType m_GridRegion;
00246 SpacingType m_GridSpacing;
00247 OriginType m_GridOrigin;
00248
00249 RegionType m_ValidRegion;
00250
00252 unsigned long m_Offset;
00253 SizeType m_SupportSize;
00254
00256 typedef typename ParametersType::ValueType PixelType;
00257 typedef Image<PixelType,itkGetStaticConstMacro(SpaceDimension)> ImageType;
00258
00259 typename ImageType::Pointer m_CoefficientImage[NDimensions];
00260
00262 typedef typename JacobianType::ValueType JacobianPixelType;
00263 typedef Image<JacobianPixelType,
00264 itkGetStaticConstMacro(SpaceDimension)> JacobianImageType;
00265
00266 typename JacobianImageType::Pointer m_JacobianImage[NDimensions];
00267
00271 mutable IndexType m_LastJacobianIndex;
00272
00274 const ParametersType * m_InputParametersPointer;
00275
00277 typename WeightsFunctionType::Pointer m_WeightsFunction;
00278
00279
00280 };
00281
00282
00283 }
00284
00285
00286 #ifndef ITK_MANUAL_INSTANTIATION
00287 #include "itkBSplineDeformableTransform.txx"
00288 #endif
00289
00290 #endif