ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkPCAShapeSignedDistanceFunction.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkPCAShapeSignedDistanceFunction_h
00019 #define __itkPCAShapeSignedDistanceFunction_h
00020 
00021 #include "itkShapeSignedDistanceFunction.h"
00022 #include "itkImage.h"
00023 #include "itkInterpolateImageFunction.h"
00024 #include "itkExtrapolateImageFunction.h"
00025 #include "itkTransform.h"
00026 
00027 namespace itk
00028 {
00065 template< typename TCoordRep,
00066           unsigned int VSpaceDimension,
00067           typename TImage = Image< double, VSpaceDimension > >
00068 class ITK_EXPORT PCAShapeSignedDistanceFunction:
00069   public ShapeSignedDistanceFunction< TCoordRep, VSpaceDimension >
00070 {
00071 public:
00073   typedef PCAShapeSignedDistanceFunction Self;
00074   typedef ShapeSignedDistanceFunction<
00075     TCoordRep, VSpaceDimension >                   Superclass;
00076 
00077   typedef SmartPointer< Self >       Pointer;
00078   typedef SmartPointer< const Self > ConstPointer;
00079 
00081   itkTypeMacro(PCAShapeSignedDistanceFunction, ShapeSignedDistancFunction);
00082 
00084   itkNewMacro(Self);
00085 
00087   itkStaticConstMacro(SpaceDimension, unsigned int, Superclass::SpaceDimension);
00088 
00090   typedef typename Superclass::CoordRepType CoordRepType;
00091 
00093   typedef typename Superclass::InputType InputType;
00094 
00096   typedef typename Superclass::OutputType OutputType;
00097 
00099   typedef typename Superclass::PointType PointType;
00100 
00102   typedef typename Superclass::ParametersType ParametersType;
00103 
00105   typedef TImage                      ImageType;
00106   typedef typename ImageType::Pointer ImagePointer;
00107   typedef std::vector< ImagePointer > ImagePointerVector;
00108 
00110   typedef Transform< CoordRepType,
00111                      itkGetStaticConstMacro(SpaceDimension),
00112                      itkGetStaticConstMacro(SpaceDimension) > TransformType;
00113 
00115   typedef InterpolateImageFunction< ImageType, CoordRepType > InterpolatorType;
00116   typedef typename InterpolatorType::Pointer                  InterpolatorPointer;
00117   typedef std::vector< InterpolatorPointer >                  InterpolatorPointerVector;
00118 
00120   typedef ExtrapolateImageFunction< ImageType, CoordRepType > ExtrapolatorType;
00121   typedef typename ExtrapolatorType::Pointer                  ExtrapolatorPointer;
00122   typedef std::vector< ExtrapolatorPointer >                  ExtrapolatorPointerVector;
00123 
00125   typedef ImageFunction< ImageType, double, CoordRepType > FunctionType;
00126   typedef typename FunctionType::Pointer                   FunctionPointer;
00127   typedef std::vector< FunctionPointer >                   FunctionPointerVector;
00128 
00131   void SetNumberOfPrincipalComponents(unsigned int n);
00132 
00133   itkGetConstMacro(NumberOfPrincipalComponents, unsigned int);
00134 
00136   itkSetObjectMacro(MeanImage, ImageType);
00137   itkGetObjectMacro(MeanImage, ImageType);
00139 
00141   void SetPrincipalComponentImages(ImagePointerVector v)
00142   { m_PrincipalComponentImages = v; }
00143 //  ImagePointerVector & GetPrincipalComponentImages()
00144 //    { return m_PrincipalComponentImages; }
00146 
00149   itkSetMacro(PrincipalComponentStandardDeviations, ParametersType);
00150   itkGetConstMacro(PrincipalComponentStandardDeviations, ParametersType);
00152 
00154   itkSetObjectMacro(Transform, TransformType);
00155   itkGetObjectMacro(Transform, TransformType);
00157 
00159   virtual void SetParameters(const ParametersType &);
00160 
00161   virtual unsigned int GetNumberOfShapeParameters(void) const
00162   { return m_NumberOfPrincipalComponents; }
00163   virtual unsigned int GetNumberOfPoseParameters(void) const
00164   { return m_Transform ? m_Transform->GetNumberOfParameters() : 0; }
00165 
00167   virtual OutputType Evaluate(const PointType & point) const;
00168 
00171   virtual void Initialize()
00172   throw ( ExceptionObject );
00173 
00174 protected:
00175   PCAShapeSignedDistanceFunction();
00176   ~PCAShapeSignedDistanceFunction(){}
00177 
00178   void PrintSelf(std::ostream & os, Indent indent) const;
00179 
00180 private:
00181   PCAShapeSignedDistanceFunction(const Self &); //purposely not implemented
00182   void operator=(const Self &);                 //purposely not implemented
00183 
00185   unsigned int m_NumberOfPrincipalComponents;
00186   unsigned int m_NumberOfTransformParameters;
00187 
00188   ImagePointer       m_MeanImage;
00189   ImagePointerVector m_PrincipalComponentImages;
00190   ParametersType     m_PrincipalComponentStandardDeviations;
00191 
00193   typename TransformType::Pointer m_Transform;
00194 
00195   InterpolatorPointerVector     m_Interpolators;
00196   ExtrapolatorPointerVector     m_Extrapolators;
00197   mutable FunctionPointerVector m_Selectors;
00198 
00200   ParametersType m_WeightOfPrincipalComponents;
00201   ParametersType m_TransformParameters;
00202 };
00203 } // end namespace itk
00204 
00205 // Define instantiation macro for this template.
00206 #define ITK_TEMPLATE_PCAShapeSignedDistanceFunction(_, EXPORT, TypeX, TypeY)     \
00207   namespace itk                                                                  \
00208   {                                                                              \
00209   _( 3 ( class EXPORT PCAShapeSignedDistanceFunction< ITK_TEMPLATE_3 TypeX > ) ) \
00210   namespace Templates                                                            \
00211   {                                                                              \
00212   typedef PCAShapeSignedDistanceFunction< ITK_TEMPLATE_3 TypeX >                 \
00213   PCAShapeSignedDistanceFunction##TypeY;                                       \
00214   }                                                                              \
00215   }
00216 
00217 #if ITK_TEMPLATE_EXPLICIT
00218 #include "Templates/itkPCAShapeSignedDistanceFunction+-.h"
00219 #endif
00220 
00221 #if ITK_TEMPLATE_TXX
00222 #include "itkPCAShapeSignedDistanceFunction.hxx"
00223 #endif
00224 
00225 #endif
00226