00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __itkAdvancedTranslationTransform_h
00019 #define __itkAdvancedTranslationTransform_h
00020
00021 #include <iostream>
00022 #include "itkAdvancedTransform.h"
00023 #include "itkExceptionObject.h"
00024 #include "itkMatrix.h"
00025
00026
00027
00028
00029 namespace itk
00030 {
00031
00039 template <
00040 class TScalarType=double,
00041 unsigned int NDimensions=3>
00042 class ITK_EXPORT AdvancedTranslationTransform :
00043 public AdvancedTransform< TScalarType, NDimensions, NDimensions >
00044 {
00045 public:
00047 typedef AdvancedTranslationTransform Self;
00048 typedef AdvancedTransform< TScalarType, NDimensions, NDimensions > Superclass;
00049 typedef SmartPointer<Self> Pointer;
00050 typedef SmartPointer<const Self> ConstPointer;
00051
00053 itkNewMacro( Self );
00054
00056 itkTypeMacro( AdvancedTranslationTransform, AdvancedTransform );
00057
00059 itkStaticConstMacro(SpaceDimension, unsigned int, NDimensions);
00060 itkStaticConstMacro(ParametersDimension, unsigned int, NDimensions);
00061
00063 typedef typename Superclass::ScalarType ScalarType;
00064
00066 typedef typename Superclass::ParametersType ParametersType;
00067
00069 typedef typename Superclass::JacobianType JacobianType;
00070
00072 typedef Vector<TScalarType, itkGetStaticConstMacro(SpaceDimension)> InputVectorType;
00073 typedef Vector<TScalarType, itkGetStaticConstMacro(SpaceDimension)> OutputVectorType;
00074
00076 typedef CovariantVector<TScalarType, itkGetStaticConstMacro(SpaceDimension)> InputCovariantVectorType;
00077 typedef CovariantVector<TScalarType, itkGetStaticConstMacro(SpaceDimension)> OutputCovariantVectorType;
00078
00080 typedef vnl_vector_fixed<TScalarType, itkGetStaticConstMacro(SpaceDimension)> InputVnlVectorType;
00081 typedef vnl_vector_fixed<TScalarType, itkGetStaticConstMacro(SpaceDimension)> OutputVnlVectorType;
00082
00084 typedef Point<TScalarType, itkGetStaticConstMacro(SpaceDimension)> InputPointType;
00085 typedef Point<TScalarType, itkGetStaticConstMacro(SpaceDimension)> OutputPointType;
00086
00088 typedef typename Superclass
00089 ::NonZeroJacobianIndicesType NonZeroJacobianIndicesType;
00090 typedef typename Superclass::SpatialJacobianType SpatialJacobianType;
00091 typedef typename Superclass
00092 ::JacobianOfSpatialJacobianType JacobianOfSpatialJacobianType;
00093 typedef typename Superclass::SpatialHessianType SpatialHessianType;
00094 typedef typename Superclass
00095 ::JacobianOfSpatialHessianType JacobianOfSpatialHessianType;
00096 typedef typename Superclass::InternalMatrixType InternalMatrixType;
00097
00101 const OutputVectorType & GetOffset(void) const
00102 { return m_Offset; }
00103
00106 void SetParameters(const ParametersType & parameters);
00107
00109 virtual const ParametersType& GetParameters(void) const;
00110
00114 void SetOffset(const OutputVectorType &offset)
00115 { m_Offset = offset; return; }
00116
00118 void Compose(const Self * other, bool pre=0);
00119
00124 void Translate(const OutputVectorType &offset, bool pre=0);
00125
00130 OutputPointType TransformPoint(const InputPointType &point ) const;
00131 OutputVectorType TransformVector(const InputVectorType &vector) const;
00132 OutputVnlVectorType TransformVector(const InputVnlVectorType &vector) const;
00133 OutputCovariantVectorType TransformCovariantVector(
00134 const InputCovariantVectorType &vector) const;
00135
00139 inline InputPointType BackTransform(const OutputPointType &point ) const;
00140 inline InputVectorType BackTransform(const OutputVectorType &vector) const;
00141 inline InputVnlVectorType BackTransform(const OutputVnlVectorType &vector) const;
00142 inline InputCovariantVectorType BackTransform(
00143 const OutputCovariantVectorType &vector) const;
00144
00149 bool GetInverse(Self* inverse) const;
00150
00152 virtual const JacobianType & GetJacobian(const InputPointType &point ) const;
00153
00155 virtual void GetJacobian(
00156 const InputPointType &,
00157 JacobianType &,
00158 NonZeroJacobianIndicesType & ) const;
00159
00161 virtual void GetSpatialJacobian(
00162 const InputPointType &,
00163 SpatialJacobianType & ) const;
00164
00166 virtual void GetSpatialHessian(
00167 const InputPointType &,
00168 SpatialHessianType & ) const;
00169
00171 virtual void GetJacobianOfSpatialJacobian(
00172 const InputPointType &,
00173 JacobianOfSpatialJacobianType &,
00174 NonZeroJacobianIndicesType & ) const;
00175
00177 virtual void GetJacobianOfSpatialJacobian(
00178 const InputPointType &,
00179 SpatialJacobianType &,
00180 JacobianOfSpatialJacobianType &,
00181 NonZeroJacobianIndicesType & ) const;
00182
00184 virtual void GetJacobianOfSpatialHessian(
00185 const InputPointType &,
00186 JacobianOfSpatialHessianType &,
00187 NonZeroJacobianIndicesType & ) const;
00188
00192 virtual void GetJacobianOfSpatialHessian(
00193 const InputPointType & ipp,
00194 SpatialHessianType & sh,
00195 JacobianOfSpatialHessianType & jsh,
00196 NonZeroJacobianIndicesType & nonZeroJacobianIndices ) const;
00197
00199 void SetIdentity(void);
00200
00202 virtual unsigned int GetNumberOfParameters(void) const
00203 { return NDimensions; }
00204
00210 virtual bool IsLinear() const { return true; }
00211
00215 virtual void SetFixedParameters( const ParametersType & )
00216 { };
00217
00221 virtual const ParametersType& GetFixedParameters(void) const
00222 {
00223 this->m_FixedParameters.SetSize(0);
00224 return this->m_FixedParameters;
00225 };
00226
00227 protected:
00228 AdvancedTranslationTransform();
00229 ~AdvancedTranslationTransform();
00231 void PrintSelf(std::ostream &os, Indent indent) const;
00232
00233 private:
00234 AdvancedTranslationTransform(const Self&);
00235 void operator=(const Self&);
00236
00237 OutputVectorType m_Offset;
00238
00239 SpatialJacobianType m_SpatialJacobian;
00240 SpatialHessianType m_SpatialHessian;
00241 NonZeroJacobianIndicesType m_NonZeroJacobianIndices;
00242 JacobianOfSpatialJacobianType m_JacobianOfSpatialJacobian;
00243 JacobianOfSpatialHessianType m_JacobianOfSpatialHessian;
00244
00245 };
00246
00247
00248
00249 template<class TScalarType, unsigned int NDimensions>
00250 inline
00251 typename AdvancedTranslationTransform<TScalarType, NDimensions>::InputPointType
00252 AdvancedTranslationTransform<TScalarType, NDimensions>::
00253 BackTransform(const OutputPointType &point) const {
00254 return point - m_Offset;
00255 }
00256
00257
00258
00259
00260
00261 template<class TScalarType, unsigned int NDimensions>
00262 inline
00263 typename AdvancedTranslationTransform<TScalarType, NDimensions>::InputVectorType
00264 AdvancedTranslationTransform<TScalarType, NDimensions>::
00265 BackTransform(const OutputVectorType &vect ) const
00266 {
00267 return vect;
00268 }
00269
00270
00271
00272
00273
00274 template<class TScalarType, unsigned int NDimensions>
00275 inline
00276 typename AdvancedTranslationTransform<TScalarType, NDimensions>::InputVnlVectorType
00277 AdvancedTranslationTransform<TScalarType, NDimensions>::
00278 BackTransform(const OutputVnlVectorType &vect ) const
00279 {
00280 return vect;
00281 }
00282
00283
00284
00285 template<class TScalarType, unsigned int NDimensions>
00286 inline
00287 typename AdvancedTranslationTransform<TScalarType, NDimensions>::InputCovariantVectorType
00288 AdvancedTranslationTransform<TScalarType, NDimensions>::
00289 BackTransform(const OutputCovariantVectorType &vect) const
00290 {
00291 return vect;
00292 }
00293
00294 }
00295
00296
00297 #define ITK_TEMPLATE_AdvancedTranslationTransform(_, EXPORT, x, y) namespace itk { \
00298 _(2(class EXPORT AdvancedTranslationTransform< ITK_TEMPLATE_2 x >)) \
00299 namespace Templates { typedef AdvancedTranslationTransform< ITK_TEMPLATE_2 x > AdvancedTranslationTransform##y; } \
00300 }
00301
00302 #if ITK_TEMPLATE_EXPLICIT
00303 # include "Templates/itkAdvancedTranslationTransform+-.h"
00304 #endif
00305
00306 #if ITK_TEMPLATE_TXX
00307 # include "itkAdvancedTranslationTransform.txx"
00308 #endif
00309
00310 #endif