Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkScaleTransform.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkScaleTransform.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-04-09 09:23:21 $
00007   Version:   $Revision: 1.29 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 
00018 #ifndef __itkScaleTransform_h
00019 #define __itkScaleTransform_h
00020 
00021 #include <iostream>
00022 #include "itkTransform.h"
00023 #include "itkExceptionObject.h"
00024 #include "itkMatrix.h"
00025 
00026 namespace itk
00027 {
00028 
00038 template <
00039     class TScalarType=float, // Type for cordinate representation type (float or double)
00040     unsigned int NDimensions=3  >  // Number of dimensions
00041 class ITK_EXPORT ScaleTransform : public Transform< TScalarType, 
00042                                          NDimensions,
00043                                          NDimensions >
00044 {
00045 public:
00047   typedef ScaleTransform                                      Self;
00048   typedef Transform< TScalarType, NDimensions, NDimensions >  Superclass;
00049   typedef SmartPointer<Self>                                  Pointer;
00050   typedef SmartPointer<const Self>                            ConstPointer;
00051 
00053   itkNewMacro( Self );
00054 
00056   itkTypeMacro( ScaleTransform, Transform );
00057 
00059   itkStaticConstMacro(SpaceDimension, unsigned int, NDimensions);
00060   itkStaticConstMacro(ParametersDimension, unsigned int, NDimensions);
00062 
00064   typedef typename Superclass::ScalarType  ScalarType;
00065 
00067   typedef typename Superclass::ParametersType  ParametersType;
00068 
00070   typedef typename Superclass::JacobianType  JacobianType;
00071 
00073   typedef FixedArray<TScalarType, itkGetStaticConstMacro(SpaceDimension)> ScaleType;
00074 
00076   typedef Vector<TScalarType, itkGetStaticConstMacro(SpaceDimension)> InputVectorType;
00077   typedef Vector<TScalarType, itkGetStaticConstMacro(SpaceDimension)> OutputVectorType;
00079 
00081   typedef CovariantVector<TScalarType, itkGetStaticConstMacro(SpaceDimension)> InputCovariantVectorType;
00082   typedef CovariantVector<TScalarType, itkGetStaticConstMacro(SpaceDimension)> OutputCovariantVectorType;
00084 
00086   typedef vnl_vector_fixed<TScalarType, itkGetStaticConstMacro(SpaceDimension)> InputVnlVectorType;
00087   typedef vnl_vector_fixed<TScalarType, itkGetStaticConstMacro(SpaceDimension)> OutputVnlVectorType;
00089 
00091   typedef Point<TScalarType, itkGetStaticConstMacro(SpaceDimension)> InputPointType;
00092   typedef Point<TScalarType, itkGetStaticConstMacro(SpaceDimension)> OutputPointType;
00094 
00097   typedef typename Superclass::InverseTransformBaseType InverseTransformBaseType;
00098   typedef typename InverseTransformBaseType::Pointer    InverseTransformBasePointer;
00099 
00104   void SetParameters(const ParametersType & parameters);
00105 
00110   const ParametersType & GetParameters( void ) const;
00111 
00113   const JacobianType & GetJacobian( const InputPointType & point ) const;
00114 
00123   void SetScale( const ScaleType & scale )
00124     { this->Modified(); m_Scale = scale; }
00125 
00127   void Compose(const Self * other, bool pre=false);
00128 
00132   void Scale(const ScaleType & scale, bool pre=false );
00133 
00138   OutputPointType     TransformPoint(const InputPointType  &point ) const;
00139   OutputVectorType    TransformVector(const InputVectorType &vector) const;
00140   OutputVnlVectorType TransformVector(const InputVnlVectorType &vector) const;
00141   OutputCovariantVectorType TransformCovariantVector(
00142                                  const InputCovariantVectorType &vector) const;
00144 
00149   inline InputPointType     BackTransform(const OutputPointType  &point ) const;
00150   inline InputVectorType    BackTransform(const OutputVectorType &vector) const;
00151   inline InputVnlVectorType BackTransform(const OutputVnlVectorType &vector) const;
00152   inline InputCovariantVectorType BackTransform(
00153                                      const OutputCovariantVectorType &vector) const;
00155 
00160   bool GetInverse(Self* inverse) const;
00161 
00163   virtual InverseTransformBasePointer GetInverseTransform() const;
00164 
00168   void SetIdentity( void )
00169     { m_Scale.Fill( 1.0 ); }
00170 
00171 
00173   itkSetMacro( Center, InputPointType );
00174   itkGetConstReferenceMacro( Center, InputPointType );
00176 
00177 
00179   itkGetConstReferenceMacro( Scale, ScaleType );
00180 
00186   virtual bool IsLinear() const { return true; }
00187 
00188 protected:
00190   ScaleTransform();
00191 
00193   ~ScaleTransform();
00194 
00196   void PrintSelf(std::ostream &os, Indent indent) const;
00197 
00198   
00199 private:
00200   ScaleTransform(const Self & other); //purposely not implemented
00201   const Self & operator=( const Self & ); //purposely not implemented
00202 
00203   ScaleType   m_Scale;  // Scales of the transformation
00204 
00205   InputPointType   m_Center; // Scaling center
00206 
00207 }; //class ScaleTransform
00208 
00209 // Back transform a point
00210 template<class ScalarType, unsigned int NDimensions>
00211 inline
00212 typename ScaleTransform<ScalarType, NDimensions>::InputPointType
00213 ScaleTransform<ScalarType, NDimensions>::
00214 BackTransform(const OutputPointType &point) const {
00215   InputPointType result;
00216   for( unsigned int i=0; i<SpaceDimension; i++ )
00217     {
00218     result[i] = ( point[i] + m_Center[i] ) / m_Scale[i] - m_Center[i]; 
00219     }
00220   return result;
00221 }
00222 
00223 // Back transform a vector
00224 template<class ScalarType, unsigned int NDimensions>
00225 inline
00226 typename ScaleTransform<ScalarType, NDimensions>::InputVectorType
00227 ScaleTransform<ScalarType, NDimensions>::
00228 BackTransform(const OutputVectorType &vect ) const 
00229 {
00230   InputVectorType result;
00231   for( unsigned int i=0; i<SpaceDimension; i++ )
00232     {
00233     result[i] = vect[i] / m_Scale[i];
00234     }
00235   return result;
00236 }
00237 
00238 // Back transform a vnl_vector
00239 template<class ScalarType, unsigned int NDimensions>
00240 inline
00241 typename ScaleTransform<ScalarType, NDimensions>::InputVnlVectorType
00242 ScaleTransform<ScalarType, NDimensions>::
00243 BackTransform(const OutputVnlVectorType &vect ) const 
00244 {
00245   InputVnlVectorType result;
00246   for( unsigned int i=0; i<SpaceDimension; i++ )
00247     {
00248     result[i] = vect[i] / m_Scale[i];
00249     }
00250   return result;
00251 }
00252 
00253 
00254 // Back Transform a CovariantVector
00255 template<class ScalarType, unsigned int NDimensions>
00256 inline
00257 typename ScaleTransform<ScalarType, NDimensions>::InputCovariantVectorType
00258 ScaleTransform<ScalarType, NDimensions>::
00259 BackTransform(const OutputCovariantVectorType &vect) const 
00260 {
00261   // Covariant Vectors are scaled by the inverse
00262   InputCovariantVectorType result;
00263   for( unsigned int i=0; i<SpaceDimension; i++ )
00264     {
00265     result[i] = vect[i] * m_Scale[i];
00266     }
00267   return result;
00268 }
00269 
00270 }  // namespace itk
00271 
00272 // Define instantiation macro for this template.
00273 #define ITK_TEMPLATE_ScaleTransform(_, EXPORT, x, y) namespace itk { \
00274   _(2(class EXPORT ScaleTransform< ITK_TEMPLATE_2 x >)) \
00275   namespace Templates { typedef ScaleTransform< ITK_TEMPLATE_2 x > ScaleTransform##y; } \
00276   }
00277 
00278 #if ITK_TEMPLATE_EXPLICIT
00279 # include "Templates/itkScaleTransform+-.h"
00280 #endif
00281 
00282 #if ITK_TEMPLATE_TXX
00283 # include "itkScaleTransform.txx"
00284 #endif
00285 
00286 
00287 #endif /* __itkScaleTransform_h */
00288 

Generated at Mon Jul 12 2010 19:47:08 for ITK by doxygen 1.7.1 written by Dimitri van Heesch, © 1997-2000