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
00099 virtual bool GetHasNonZeroSpatialHessian( void ) const
00100 {
00101 return false;
00102 }
00103 virtual bool HasNonZeroJacobianOfSpatialHessian( void ) const
00104 {
00105 return false;
00106 }
00107
00110 const OutputVectorType & GetOffset(void) const
00111 { return m_Offset; }
00112
00115 void SetParameters(const ParametersType & parameters);
00116
00118 virtual const ParametersType& GetParameters(void) const;
00119
00123 void SetOffset(const OutputVectorType &offset)
00124 { m_Offset = offset; return; }
00125
00127 void Compose(const Self * other, bool pre=0);
00128
00133 void Translate(const OutputVectorType &offset, bool pre=0);
00134
00139 OutputPointType TransformPoint(const InputPointType &point ) const;
00140 OutputVectorType TransformVector(const InputVectorType &vector) const;
00141 OutputVnlVectorType TransformVector(const InputVnlVectorType &vector) const;
00142 OutputCovariantVectorType TransformCovariantVector(
00143 const InputCovariantVectorType &vector) const;
00144
00148 inline InputPointType BackTransform(const OutputPointType &point ) const;
00149 inline InputVectorType BackTransform(const OutputVectorType &vector) const;
00150 inline InputVnlVectorType BackTransform(const OutputVnlVectorType &vector) const;
00151 inline InputCovariantVectorType BackTransform(
00152 const OutputCovariantVectorType &vector) const;
00153
00158 bool GetInverse(Self* inverse) const;
00159
00161 virtual const JacobianType & GetJacobian(const InputPointType &point ) const;
00162
00164 virtual void GetJacobian(
00165 const InputPointType &,
00166 JacobianType &,
00167 NonZeroJacobianIndicesType & ) const;
00168
00170 virtual void GetSpatialJacobian(
00171 const InputPointType &,
00172 SpatialJacobianType & ) const;
00173
00175 virtual void GetSpatialHessian(
00176 const InputPointType &,
00177 SpatialHessianType & ) const;
00178
00180 virtual void GetJacobianOfSpatialJacobian(
00181 const InputPointType &,
00182 JacobianOfSpatialJacobianType &,
00183 NonZeroJacobianIndicesType & ) const;
00184
00186 virtual void GetJacobianOfSpatialJacobian(
00187 const InputPointType &,
00188 SpatialJacobianType &,
00189 JacobianOfSpatialJacobianType &,
00190 NonZeroJacobianIndicesType & ) const;
00191
00193 virtual void GetJacobianOfSpatialHessian(
00194 const InputPointType &,
00195 JacobianOfSpatialHessianType &,
00196 NonZeroJacobianIndicesType & ) const;
00197
00201 virtual void GetJacobianOfSpatialHessian(
00202 const InputPointType & ipp,
00203 SpatialHessianType & sh,
00204 JacobianOfSpatialHessianType & jsh,
00205 NonZeroJacobianIndicesType & nonZeroJacobianIndices ) const;
00206
00208 void SetIdentity(void);
00209
00211 virtual unsigned int GetNumberOfParameters(void) const
00212 { return NDimensions; }
00213
00219 virtual bool IsLinear() const { return true; }
00220
00224 virtual void SetFixedParameters( const ParametersType & )
00225 { };
00226
00230 virtual const ParametersType& GetFixedParameters(void) const
00231 {
00232 this->m_FixedParameters.SetSize(0);
00233 return this->m_FixedParameters;
00234 };
00235
00236 protected:
00237 AdvancedTranslationTransform();
00238 ~AdvancedTranslationTransform();
00240 void PrintSelf(std::ostream &os, Indent indent) const;
00241
00242 private:
00243 AdvancedTranslationTransform(const Self&);
00244 void operator=(const Self&);
00245
00246 OutputVectorType m_Offset;
00247
00248 SpatialJacobianType m_SpatialJacobian;
00249 SpatialHessianType m_SpatialHessian;
00250 NonZeroJacobianIndicesType m_NonZeroJacobianIndices;
00251 JacobianOfSpatialJacobianType m_JacobianOfSpatialJacobian;
00252 JacobianOfSpatialHessianType m_JacobianOfSpatialHessian;
00253
00254 };
00255
00256
00257
00258 template<class TScalarType, unsigned int NDimensions>
00259 inline
00260 typename AdvancedTranslationTransform<TScalarType, NDimensions>::InputPointType
00261 AdvancedTranslationTransform<TScalarType, NDimensions>::
00262 BackTransform(const OutputPointType &point) const {
00263 return point - m_Offset;
00264 }
00265
00266
00267
00268
00269
00270 template<class TScalarType, unsigned int NDimensions>
00271 inline
00272 typename AdvancedTranslationTransform<TScalarType, NDimensions>::InputVectorType
00273 AdvancedTranslationTransform<TScalarType, NDimensions>::
00274 BackTransform(const OutputVectorType &vect ) const
00275 {
00276 return vect;
00277 }
00278
00279
00280
00281
00282
00283 template<class TScalarType, unsigned int NDimensions>
00284 inline
00285 typename AdvancedTranslationTransform<TScalarType, NDimensions>::InputVnlVectorType
00286 AdvancedTranslationTransform<TScalarType, NDimensions>::
00287 BackTransform(const OutputVnlVectorType &vect ) const
00288 {
00289 return vect;
00290 }
00291
00292
00293
00294 template<class TScalarType, unsigned int NDimensions>
00295 inline
00296 typename AdvancedTranslationTransform<TScalarType, NDimensions>::InputCovariantVectorType
00297 AdvancedTranslationTransform<TScalarType, NDimensions>::
00298 BackTransform(const OutputCovariantVectorType &vect) const
00299 {
00300 return vect;
00301 }
00302
00303 }
00304
00305
00306 #define ITK_TEMPLATE_AdvancedTranslationTransform(_, EXPORT, x, y) namespace itk { \
00307 _(2(class EXPORT AdvancedTranslationTransform< ITK_TEMPLATE_2 x >)) \
00308 namespace Templates { typedef AdvancedTranslationTransform< ITK_TEMPLATE_2 x > AdvancedTranslationTransform##y; } \
00309 }
00310
00311 #if ITK_TEMPLATE_EXPLICIT
00312 # include "Templates/itkAdvancedTranslationTransform+-.h"
00313 #endif
00314
00315 #if ITK_TEMPLATE_TXX
00316 # include "itkAdvancedTranslationTransform.txx"
00317 #endif
00318
00319 #endif