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

itkPointSetToImageMetric.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkPointSetToImageMetric.h,v $
00005   Language:  C++
00006   Date:      $Date: 2004/12/21 22:47:28 $
00007   Version:   $Revision: 1.7 $
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 #ifndef __itkPointSetToImageMetric_h
00018 #define __itkPointSetToImageMetric_h
00019 
00020 #include "itkImageBase.h"
00021 #include "itkTransform.h"
00022 #include "itkInterpolateImageFunction.h"
00023 #include "itkSingleValuedCostFunction.h"
00024 #include "itkExceptionObject.h"
00025 #include "itkGradientRecursiveGaussianImageFilter.h"
00026 
00027 namespace itk
00028 {
00029   
00046 template <class TFixedPointSet,  class TMovingImage> 
00047 class ITK_EXPORT PointSetToImageMetric : public SingleValuedCostFunction 
00048 {
00049 public:
00051   typedef PointSetToImageMetric           Self;
00052   typedef SingleValuedCostFunction        Superclass;
00053   typedef SmartPointer<Self>              Pointer;
00054   typedef SmartPointer<const Self>        ConstPointer;
00055 
00057   typedef Superclass::ParametersValueType CoordinateRepresentationType;
00058 
00060   itkTypeMacro(PointSetToImageMetric, SingleValuedCostFunction);
00061 
00063   typedef TMovingImage                               MovingImageType;
00064   typedef typename TMovingImage::PixelType           MovingImagePixelType;
00065   typedef typename MovingImageType::ConstPointer     MovingImageConstPointer;
00066 
00068   typedef TFixedPointSet                             FixedPointSetType;
00069   typedef typename FixedPointSetType::ConstPointer   FixedPointSetConstPointer;
00070 
00072   itkStaticConstMacro(MovingImageDimension, unsigned int,
00073                       TMovingImage::ImageDimension);
00074   itkStaticConstMacro(FixedPointSetDimension, unsigned int,
00075                       TFixedPointSet::PointDimension);
00076   
00077   typedef typename FixedPointSetType::PointsContainer::ConstIterator        PointIterator;
00078   typedef typename FixedPointSetType::PointDataContainer::ConstIterator     PointDataIterator;
00079 
00081   typedef Transform<CoordinateRepresentationType, 
00082                     itkGetStaticConstMacro(MovingImageDimension),
00083                     itkGetStaticConstMacro(FixedPointSetDimension)> TransformType;
00084 
00085   typedef typename TransformType::Pointer            TransformPointer;
00086   typedef typename TransformType::InputPointType     InputPointType;
00087   typedef typename TransformType::OutputPointType    OutputPointType;
00088   typedef typename TransformType::ParametersType     TransformParametersType;
00089   typedef typename TransformType::JacobianType       TransformJacobianType;
00090 
00092   typedef InterpolateImageFunction<
00093     MovingImageType,
00094     CoordinateRepresentationType > InterpolatorType;
00095 
00096 
00098   typedef typename NumericTraits<MovingImagePixelType>::RealType RealType;
00099   typedef CovariantVector<RealType,
00100                           itkGetStaticConstMacro(MovingImageDimension)> GradientPixelType;
00101   typedef Image<GradientPixelType,
00102                 itkGetStaticConstMacro(MovingImageDimension)> GradientImageType;
00103   typedef SmartPointer<GradientImageType>     GradientImagePointer;
00104   typedef GradientRecursiveGaussianImageFilter< MovingImageType,
00105                                                 GradientImageType >
00106   GradientImageFilterType;  
00107   typedef typename GradientImageFilterType::Pointer GradientImageFilterPointer;
00108 
00109 
00110   typedef typename InterpolatorType::Pointer         InterpolatorPointer;
00111 
00113   typedef Superclass::MeasureType                    MeasureType;
00114 
00116   typedef Superclass::DerivativeType                 DerivativeType;
00117 
00119   typedef Superclass::ParametersType                 ParametersType;
00120 
00122   itkSetConstObjectMacro( FixedPointSet, FixedPointSetType );
00123 
00125   itkGetConstObjectMacro( FixedPointSet, FixedPointSetType );
00126 
00128   itkSetConstObjectMacro( MovingImage, MovingImageType );
00129 
00131   itkGetConstObjectMacro( MovingImage, MovingImageType );
00132 
00134   itkSetObjectMacro( Transform, TransformType );
00135 
00137   itkGetObjectMacro( Transform, TransformType );
00138  
00140   itkSetObjectMacro( Interpolator, InterpolatorType );
00141 
00143   itkGetObjectMacro( Interpolator, InterpolatorType );
00144 
00146   itkGetConstObjectMacro( GradientImage, GradientImageType );
00147 
00149   itkGetConstReferenceMacro( NumberOfPixelsCounted, unsigned long );
00150 
00152   void SetTransformParameters( const ParametersType & parameters ) const;
00153 
00161   itkSetMacro(      ComputeGradient, bool );
00162   itkGetConstReferenceMacro( ComputeGradient, bool );
00163 
00165   unsigned int GetNumberOfParameters(void) const 
00166   { return m_Transform->GetNumberOfParameters(); }
00167 
00170   virtual void Initialize(void) throw ( ExceptionObject );
00171 
00172 protected:
00173   PointSetToImageMetric();
00174   virtual ~PointSetToImageMetric() {};
00175   void PrintSelf(std::ostream& os, Indent indent) const;
00176 
00177   mutable unsigned long       m_NumberOfPixelsCounted;
00178 
00179   FixedPointSetConstPointer   m_FixedPointSet;
00180   MovingImageConstPointer     m_MovingImage;
00181 
00182   mutable TransformPointer    m_Transform;
00183   InterpolatorPointer         m_Interpolator;
00184 
00185   bool                        m_ComputeGradient;
00186   GradientImagePointer        m_GradientImage;
00187 
00188 private:
00189   PointSetToImageMetric(const Self&); //purposely not implemented
00190   void operator=(const Self&); //purposely not implemented
00191   
00192 };
00193 
00194 } // end namespace itk
00195 
00196 #ifndef ITK_MANUAL_INSTANTIATION
00197 #include "itkPointSetToImageMetric.txx"
00198 #endif
00199 
00200 #endif
00201 
00202 
00203 

Generated at Wed May 24 23:52:06 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000