KWStyle - itkCenteredTransformInitializer.h
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkCenteredTransformInitializer.h.html,v $
5   Language:  C++
6   Date:      $Date: 2006/01/17 19:15:33 $
7   Version:   $Revision: 1.4 $
8
9   Copyright (c) Insight Software Consortium. All rights reserved.
10   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11
12      This software is distributed WITHOUT ANY WARRANTY; without even 
13      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14      PURPOSE.  See the above copyright notices for more information.
15
16 =========================================================================*/
17
18 #ifndef __itkCenteredTransformInitializer_h
19 #define __itkCenteredTransformInitializer_h
20
21 #include "itkObject.h"
22 #include "itkObjectFactory.h"
23 #include "itkImageMomentsCalculator.h"
24
25 #include <iostream>
26
27 namespace itk
28 {
29
30 /** \brief CenteredTransformInitializer is a helper class intended to
31  * initialize the center of rotation and the translation of Transforms having
32  * the center of rotation among their parameters.
33  * 
34  * This class is connected to the fixed image, moving image and transform
35  * involved in the registration. Two modes of operation are possible:
36  * 
37  * - Geometrical, 
38  * - Center of mass
39  *
40  * In the first mode, the geometrical center of the moving image is passed as
41  * initial center of rotation to the transform and the vector from the center
42  * of the  fixed image to the center of the moving image is passed as the
43  * initial translation. This mode basically assumes that the anatomical objects
44  * to be registered are centered in their respective images. Hence the best
45  * initial guess for the registration is the one that superimposes those two
46  * centers.
47  *
48  * In the second mode, the moments of gray level values are computed
49  * for both images. The center of mass of the moving image is then
50  * used as center of rotation. The vector between the two centers of
51  * mass is passes as the initial translation to the transform. This
52  * second approach assumes that the moments of the anatomical objects
53  * are similar for both images and hence the best initial guess for
54  * registration is to superimpose both mass centers.  Note that this
55  * assumption will probably not hold in multi-modality registration.
56  * 
57  * \ingroup Transforms
58  */
59 template < class TTransform,     
60            class TFixedImage,
61            class TMovingImage > 
62 MCM class ITK_EXPORT CenteredTransformInitializer : 
63 IND ************public Object
64 {
65 public:
66   /** Standard class typedefs. */
67   typedef CenteredTransformInitializer     Self;
68   typedef Object                           Superclass;
69   typedef SmartPointer<Self>               Pointer;
70   typedef SmartPointer<const Self>         ConstPointer;
71     
72   /** New macro for creation of through a Smart Pointer. */
73   itkNewMacro( Self );
74
75   /** Run-time type information (and related methods). */
76   itkTypeMacro( CenteredTransformInitializer, Object );
77
78   /** Type of the transform to initialize */
79   typedef TTransform                        TransformType;
80   typedef typename TransformType::Pointer   TransformPointer;
81
82   /** Dimension of parameters. */
83 LEN   itkStaticConstMacro(SpaceDimension, unsigned int, TransformType::SpaceDimension);
84 LEN   itkStaticConstMacro(InputSpaceDimension, unsigned int, TransformType::InputSpaceDimension);
85 LEN   itkStaticConstMacro(OutputSpaceDimension, unsigned int, TransformType::OutputSpaceDimension);
86
87   
88   /** Image Types to use in the initialization of the transform */
89   typedef   TFixedImage              FixedImageType;
90   typedef   TMovingImage             MovingImageType;
91
92   typedef   typename FixedImageType::ConstPointer   FixedImagePointer;
93   typedef   typename MovingImageType::ConstPointer  MovingImagePointer;
94
95   /** Moment calculators */
96   typedef ImageMomentsCalculator< FixedImageType >   FixedImageCalculatorType;
97   typedef ImageMomentsCalculator< MovingImageType >  MovingImageCalculatorType;
98
99 LEN   typedef   typename FixedImageCalculatorType::Pointer    FixedImageCalculatorPointer;
100 LEN   typedef   typename MovingImageCalculatorType::Pointer   MovingImageCalculatorPointer;
101
102
103   /** Offset type. */
104   typedef typename TransformType::OffsetType  OffsetType;
105
106   /** Point type. */
107   typedef typename TransformType::InputPointType   InputPointType;
108   
109   /** Vector type. */
110   typedef typename TransformType::OutputVectorType  OutputVectorType;
111   
112   /** Set the transform to be initialized */
113   itkSetObjectMacro( Transform,   TransformType   );
114
115   /** Set the fixed image used in the registration process */
116   itkSetConstObjectMacro( FixedImage,  FixedImageType  );
117
118   /** Set the moving image used in the registration process */
119   itkSetConstObjectMacro( MovingImage, MovingImageType );
120
121
122   /** Initialize the transform using data from the images */
123   virtual void InitializeTransform() const;
124
125   /** Select between using the geometrical center of the images or 
126 IND ******using the center of mass given by the image intensities. */
127   void GeometryOn() { m_UseMoments = false; }
128   void MomentsOn()  { m_UseMoments = true; }
129
130   /** Get() access to the moments calculators */
131   itkGetConstObjectMacro( FixedCalculator,  FixedImageCalculatorType  );
132   itkGetConstObjectMacro( MovingCalculator, MovingImageCalculatorType );
133
134 protected:
135   CenteredTransformInitializer();
136   ~CenteredTransformInitializer(){};
137
138   void PrintSelf(std::ostream &os, Indent indent) const;
139
140 private:
141   CenteredTransformInitializer(const Self&); //purposely not implemented
142   void operator=(const Self&); //purposely not implemented
143
144   TransformPointer    m_Transform;
145
146   FixedImagePointer   m_FixedImage;
147
148   MovingImagePointer  m_MovingImage;
149
150   bool                m_UseMoments;
151
152   FixedImageCalculatorPointer    m_FixedCalculator;
153   MovingImageCalculatorPointer   m_MovingCalculator;
154
155 }; //class CenteredTransformInitializer
156
157
158 }  // namespace itk
159
160
161 #ifndef ITK_MANUAL_INSTANTIATION
162 #include "itkCenteredTransformInitializer.txx"
163 #endif
164
165 #endif /* __itkCenteredTransformInitializer_h */
166

Generated by KWStyle 1.0b on Tuesday January,17 at 02:14:01PM
© Kitware Inc.