Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef __itkStackTransform_h
00016 #define __itkStackTransform_h
00017
00018 #include "itkAdvancedTransform.h"
00019 #include "itkIndex.h"
00020
00021 namespace itk
00022 {
00023
00034 template <class TScalarType,
00035 unsigned int NInputDimensions = 3,
00036 unsigned int NOutputDimensions = 3>
00037 class StackTransform
00038 : public AdvancedTransform< TScalarType, NInputDimensions, NOutputDimensions >
00039 {
00040 public:
00042 typedef StackTransform Self;
00043 typedef AdvancedTransform< TScalarType,
00044 NInputDimensions,
00045 NOutputDimensions > Superclass;
00046 typedef SmartPointer< Self > Pointer;
00047 typedef SmartPointer< const Self > ConstPointer;
00048
00050 itkNewMacro( Self );
00051
00053 itkTypeMacro( StackTransform, AdvancedTransform );
00054
00056 itkStaticConstMacro( InputSpaceDimension, unsigned int, NInputDimensions );
00057 itkStaticConstMacro( OutputSpaceDimension, unsigned int, NOutputDimensions );
00058 itkStaticConstMacro( ReducedInputSpaceDimension, unsigned int, NInputDimensions - 1 );
00059 itkStaticConstMacro( ReducedOutputSpaceDimension, unsigned int, NOutputDimensions - 1 );
00060
00062 typedef typename Superclass::ScalarType ScalarType;
00063 typedef typename Superclass::ParametersType ParametersType;
00064 typedef typename Superclass::JacobianType JacobianType;
00065 typedef typename Superclass::InputPointType InputPointType;
00066 typedef typename Superclass::OutputPointType OutputPointType;
00067 typedef typename
00068 Superclass::NonZeroJacobianIndicesType NonZeroJacobianIndicesType;
00069
00071 typedef AdvancedTransform< TScalarType,
00072 itkGetStaticConstMacro( ReducedInputSpaceDimension ),
00073 itkGetStaticConstMacro( ReducedOutputSpaceDimension ) > SubTransformType;
00074 typedef typename SubTransformType::Pointer SubTransformPointer;
00075 typedef std::vector< SubTransformPointer > SubTransformContainerType;
00076 typedef typename SubTransformType::JacobianType SubTransformJacobianType;
00077
00079 typedef typename SubTransformType::InputPointType SubTransformInputPointType;
00080 typedef typename SubTransformType::OutputPointType SubTransformOutputPointType;
00081
00083 virtual OutputPointType TransformPoint( const InputPointType & ipp ) const;
00084
00090 virtual void GetJacobian(
00091 const InputPointType & ipp,
00092 JacobianType & jac,
00093 NonZeroJacobianIndicesType & nzji ) const;
00094
00096 virtual const JacobianType & GetJacobian( const InputPointType & ipp) const;
00097
00100 virtual void SetParameters( const ParametersType & param );
00101
00104 virtual const ParametersType & GetParameters ( void ) const;
00105
00107 virtual unsigned int GetNumberOfParameters(void) const
00108 {
00109 if ( this->m_SubTransformContainer.size() == 0 )
00110 {
00111 return 0;
00112 }
00113 else
00114 {
00115 return this->m_SubTransformContainer.size() * m_SubTransformContainer[ 0 ]->GetNumberOfParameters();
00116 }
00117 }
00118
00120 virtual void SetNumberOfSubTransforms( const unsigned int num )
00121 {
00122 if ( this->m_NumberOfSubTransforms != num )
00123 {
00124 this->m_NumberOfSubTransforms = num;
00125 this->m_SubTransformContainer.clear();
00126 this->m_SubTransformContainer.resize( num );
00127 this->Modified();
00128 }
00129 }
00130 itkGetMacro( NumberOfSubTransforms, unsigned int );
00131
00133 itkSetMacro( StackSpacing, TScalarType );
00134 itkGetConstMacro( StackSpacing, TScalarType );
00135 itkSetMacro( StackOrigin, TScalarType );
00136 itkGetConstMacro( StackOrigin, TScalarType );
00137
00139 virtual void SetSubTransform( unsigned int i, SubTransformType * transform )
00140 {
00141 this->m_SubTransformContainer[ i ] = transform;
00142 this->Modified();
00143 }
00144
00146 virtual void SetAllSubTransforms( SubTransformType * transform ) {
00147 for ( unsigned int t = 0; t < this->m_NumberOfSubTransforms; ++t )
00148 {
00149
00150 SubTransformPointer transformcopy = dynamic_cast< SubTransformType * >( transform->CreateAnother().GetPointer() );
00151 transformcopy->SetFixedParameters( transform->GetFixedParameters() );
00152 transformcopy->SetParameters( transform->GetParameters() );
00153
00154 this->m_SubTransformContainer[ t ] = transformcopy;
00155 }
00156 }
00157
00159 virtual SubTransformPointer GetSubTransform( unsigned int i )
00160 {
00161 return this->m_SubTransformContainer[ i ];
00162 }
00163
00165 virtual unsigned long GetNumberOfNonZeroJacobianIndices( void ) const;
00166
00167 protected:
00168 StackTransform();
00169 virtual ~StackTransform() {};
00170
00171 private:
00172
00173 StackTransform(const Self&);
00174 void operator=(const Self&);
00175
00176
00177 unsigned int m_NumberOfSubTransforms;
00178 SubTransformContainerType m_SubTransformContainer;
00179
00180
00181 TScalarType m_StackSpacing, m_StackOrigin;
00182
00183 };
00184
00185 }
00186
00187
00188
00189
00190 #define ITK_TEMPLATE_StackTransform(_, EXPORT, x, y) namespace itk { \
00191 _(3(class EXPORT StackTransform< ITK_TEMPLATE_3 x >)) \
00192 namespace Templates { typedef StackTransform< ITK_TEMPLATE_3 x > StackTransform##y; } \
00193 }
00194
00195 #if ITK_TEMPLATE_EXPLICIT
00196 # include "Templates/itkStackTransform+-.h"
00197 #endif
00198
00199 #if ITK_TEMPLATE_TXX
00200 # include "itkStackTransform.txx"
00201 #endif
00202
00203 #endif