KWStyle - itkPCAShapeSignedDistanceFunction.h
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkPCAShapeSignedDistanceFunction.h.html,v $
5   Language:  C++
6   Date:      $Date: 2006/01/17 19:15:43 $
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 DEF #ifndef _itkPCAShapeSignedDistanceFunction_h
18 DEF #define _itkPCAShapeSignedDistanceFunction_h
19
20
21 #include "itkShapeSignedDistanceFunction.h"
22 #include "itkImage.h"
23 #include "itkInterpolateImageFunction.h"
24 #include "itkExtrapolateImageFunction.h"
25 #include "itkTransform.h"
26
27 namespace itk
28 {
29
30
31 /** \class PCAShapeSignedDistanceFunction
32  * \brief Compute the signed distance from a N-dimensional PCA Shape.
33  *
34  * This class computes the signed distance from a N-dimensional shape defined
35  * by:
36  * (1) a mean signed distance image \f$ M(x) \f$, 
37  * (2) the first \f$ q \f$ principal components images 
38  * \f$ P_i(x) \f$ and 
39  * (3) a transform \f$ T(x) \f$ to define the pose 
40  * (i.e. position or orientation of the shape).
41  *
42 LEN  * A particular instance of the shape is defined by a set of parameters \f$ p \f$. 
43 LEN  * The first \f$ q \f$ parameters defines the weights applied to each principal components 
44  * and the remaining parameters is used to define the transform. The user
45 LEN  * should refer to the documentation of the particular Transform class being used.
46  * The first set of parameters are called the ShapeParameters and the remaining
47  * parameters the PoseParameters.
48  *
49  * The method Evaluate( point x ) returns the approximate signed to the 
50  * shape at point x such that:
51  *
52  * \f[ s = M(T(x)) + \sum_i^{q} p[i] * \sigma[i] * P_i(T(x)) \f]
53  * 
54 LEN  * Where \sigma[i] are the square root of the eigenvalues. These are defined using
55  * method SetPrincipalComponentStandardDeviations().
56  *
57  * This class is templated over the coordinate representation type 
58  * (e.g. float or double) and the space dimension.
59  *
60  * \sa ShapeSignedDistanceFunction
61  * \sa Transform
62  * \ingroup ImageFunctions
63  * 
64  * */
65 template< typename TCoordRep, 
66           unsigned int VSpaceDimension,
67           typename TImage = Image<double,VSpaceDimension> >
68 class ITK_EXPORT PCAShapeSignedDistanceFunction : 
69 IND **public ShapeSignedDistanceFunction<TCoordRep, VSpaceDimension>
70 {
71
72 public:
73   /** Standard class typedefs. */
74   typedef PCAShapeSignedDistanceFunction          Self;
75   typedef ShapeSignedDistanceFunction<
76     TCoordRep, VSpaceDimension>                   Superclass;
77   typedef SmartPointer<Self>                      Pointer;
78   typedef SmartPointer<const Self>                ConstPointer;
79   
80
81   /** Run-time type information (and related methods). */
82   itkTypeMacro(PCAShapeSignedDistanceFunction, ShapeSignedDistancFunction);
83
84   /** New macro for creation of through the object factory. */
85   itkNewMacro(Self);
86
87   /** Dimension underlying input image. */
88   itkStaticConstMacro(SpaceDimension,unsigned int,Superclass::SpaceDimension);
89
90
91   /** CoordRep typedef support. */
92   typedef typename Superclass::CoordRepType       CoordRepType;
93
94   /** InputeType typedef support. */
95   typedef typename Superclass::InputType          InputType;
96
97   /** OutputType typedef support. */
98   typedef typename Superclass::OutputType         OutputType;
99   
100   /** Point typedef support. */
101   typedef typename Superclass::PointType          PointType;
102
103   /** Parameters typedef support. */
104   typedef typename Superclass::ParametersType     ParametersType;
105
106
107   /** Image typedef support. */
108   typedef TImage                                  ImageType;
109   typedef typename ImageType::Pointer             ImagePointer;
110   typedef std::vector<ImagePointer>               ImagePointerVector;
111
112   /** Transform typedef support. */
113   typedef Transform<CoordRepType, 
114                     itkGetStaticConstMacro(SpaceDimension), 
115                     itkGetStaticConstMacro(SpaceDimension)> TransformType;
116
117   /** Interpolator typedef support. */
118   typedef InterpolateImageFunction<ImageType, CoordRepType> InterpolatorType;
119   typedef typename InterpolatorType::Pointer                InterpolatorPointer;
120 LEN   typedef std::vector<InterpolatorPointer>                  InterpolatorPointerVector;
121
122   /** extrapolator typedef support. */
123   typedef ExtrapolateImageFunction<ImageType, CoordRepType> ExtrapolatorType;
124   typedef typename ExtrapolatorType::Pointer                ExtrapolatorPointer;
125 LEN   typedef std::vector<ExtrapolatorPointer>                  ExtrapolatorPointerVector;
126
127   /** function typedef support. */
128   typedef ImageFunction<ImageType, double, CoordRepType> FunctionType;
129   typedef typename FunctionType::Pointer                 FunctionPointer;
130   typedef std::vector<FunctionPointer>                   FunctionPointerVector;
131
132
133   /** Set/Get the number of principal components 
134    * SetNumberOfPrincipalComponents must be called before SetParameters */
135   void SetNumberOfPrincipalComponents(unsigned int n);
136   itkGetMacro(NumberOfPrincipalComponents, unsigned int);
137
138   /** Set/Get the mean image. */
139   itkSetObjectMacro(MeanImage, ImageType);
140   itkGetObjectMacro(MeanImage, ImageType);
141
142   /** Set/Get the principal component images. */
143   void SetPrincipalComponentImages(ImagePointerVector v)
144     { m_PrincipalComponentImages = v; }
145 IND //  ImagePointerVector & GetPrincipalComponentImages()
146 IND //    { return m_PrincipalComponentImages; }
147
148 LEN   /** Set/Get the principal component standard deviations. These values corresponds
149    * to the square root of the eigenvalues of the principal components. */
150   itkSetMacro(PrincipalComponentStandardDeviations, ParametersType);
151   itkGetMacro(PrincipalComponentStandardDeviations, ParametersType);
152
153   /** Set/Get transform. */
154   itkSetObjectMacro(Transform, TransformType);
155   itkGetObjectMacro(Transform, TransformType);
156
157
158   /** A PCAShape is defined by a set of shape and pose parameters. */
159   virtual void SetParameters( const ParametersType & );
160   virtual unsigned int GetNumberOfShapeParameters(void) const
161     { return m_NumberOfPrincipalComponents; }
162   virtual unsigned int GetNumberOfPoseParameters(void) const
163     { return m_Transform ? m_Transform->GetNumberOfParameters() : 0; }
164
165   /** Evaluate the signed distance from a shape at a given position. */
166   virtual OutputType Evaluate(const PointType& point) const;
167
168   /** Initialize must be called before the first call of  
169 IND ***Evaluate() to allow the class to validate any inputs. */
170   virtual void Initialize() throw ( ExceptionObject );
171
172
173 protected:
174   PCAShapeSignedDistanceFunction();
175   ~PCAShapeSignedDistanceFunction(){};
176
177   void PrintSelf(std::ostream& os, Indent indent) const;
178
179
180 private:
181   PCAShapeSignedDistanceFunction(const Self&); //purposely not implemented
182   void operator=( const Self& ); //purposely not implemented
183
184
185   /** intrinsic data members */
186   unsigned int                  m_NumberOfPrincipalComponents;
187   unsigned int                  m_NumberOfTransformParameters;
188
189   ImagePointer                  m_MeanImage;
190   ImagePointerVector            m_PrincipalComponentImages;
191   ParametersType                m_PrincipalComponentStandardDeviations;
192
193   /** transform and interpolator/extrapolator for image interpolation */
194   typename TransformType::Pointer        m_Transform;
195   InterpolatorPointerVector              m_Interpolators;
196   ExtrapolatorPointerVector              m_Extrapolators;
197   mutable FunctionPointerVector          m_Selectors;
198
199   /** shape and pose parameters */
200   ParametersType                m_WeightOfPrincipalComponents;
201   ParametersType                m_TransformParameters;         
202
203 };
204
205 // namespace itk
206
207 #ifndef ITK_MANUAL_INSTANTIATION
208 #include "itkPCAShapeSignedDistanceFunction.txx"
209 #endif
210
211 #endif
212

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