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

itkImageToSpatialObjectMetric.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkImageToSpatialObjectMetric.h,v $
00005   Language:  C++
00006   Date:      $Date: 2006-04-18 14:50:07 $
00007   Version:   $Revision: 1.10 $
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 __itkImageToSpatialObjectMetric_h
00018 #define __itkImageToSpatialObjectMetric_h
00019 
00020 #include "itkSingleValuedCostFunction.h"
00021 #include "itkMinimumMaximumImageCalculator.h"
00022 #include "itkLinearInterpolateImageFunction.h"
00023 #include "vnl/vnl_vector_fixed.h"
00024 
00025 namespace itk
00026 {
00027   
00058 template < class TFixedImage, class TMovingSpatialObject> 
00059 class ITK_EXPORT ImageToSpatialObjectMetric 
00060   : public SingleValuedCostFunction
00061 {
00062 public:
00064   typedef ImageToSpatialObjectMetric  Self;
00065 
00067   typedef SingleValuedCostFunction  Superclass;
00068 
00070   typedef SmartPointer<Self>   Pointer;
00071   typedef SmartPointer<const Self>  ConstPointer;
00072 
00074   typedef TFixedImage          FixedImageType;
00075 
00077   typedef TMovingSpatialObject  MovingSpatialObjectType;
00078 
00080   typedef Superclass::ParametersValueType CoordinateRepresentationType;
00081 
00083   itkStaticConstMacro(ImageDimension, unsigned int,
00084                       FixedImageType::ImageDimension);
00085 
00087   itkStaticConstMacro(ObjectDimension, unsigned int,
00088                       MovingSpatialObjectType::ObjectDimension);
00089 
00091   typedef Transform<CoordinateRepresentationType, 
00092                     itkGetStaticConstMacro(ObjectDimension),
00093                     itkGetStaticConstMacro(ImageDimension) > TransformType;
00094 
00095   typedef typename TransformType::Pointer            TransformPointer;
00096   typedef typename TransformType::InputPointType     InputPointType;
00097   typedef typename TransformType::OutputPointType    OutputPointType;
00098   typedef typename TransformType::ParametersType     TransformParametersType;
00099   typedef typename TransformType::JacobianType       TransformJacobianType;
00100 
00102   typedef LinearInterpolateImageFunction<
00103     TFixedImage,
00104     CoordinateRepresentationType > InterpolatorType;
00105 
00106   typedef typename InterpolatorType::Pointer         InterpolatorPointer;
00107 
00109   typedef vnl_vector_fixed<double,
00110                            itkGetStaticConstMacro(ObjectDimension)> VectorType;
00111 
00113   typedef Superclass::MeasureType          MeasureType;
00114 
00116   typedef Superclass::DerivativeType   DerivativeType; 
00117 
00119   typedef typename FixedImageType::Pointer    FixedImagePointer;
00120 
00122   typedef typename MovingSpatialObjectType::Pointer  
00123   MovingSpatialObjectPointer;
00124 
00126   typedef typename FixedImageType::ConstPointer   FixedImageConstPointer;
00127 
00129   typedef typename MovingSpatialObjectType::ConstPointer    
00130   MovingSpatialObjectConstPointer;
00131 
00134   typedef Superclass::ParametersType         ParametersType;
00135 
00137   itkTypeMacro(ImageToSpatialObjectMetric, Object);
00138 
00140   itkSetConstObjectMacro( FixedImage, FixedImageType );
00141 
00143   itkGetConstObjectMacro( FixedImage, FixedImageType );
00144 
00146   itkSetConstObjectMacro( MovingSpatialObject, MovingSpatialObjectType );
00147 
00149   itkGetConstObjectMacro( MovingSpatialObject, MovingSpatialObjectType );
00150 
00152   itkSetObjectMacro( Interpolator, InterpolatorType );
00153 
00155   itkGetObjectMacro( Interpolator, InterpolatorType );
00156 
00158   virtual void GetDerivative( const ParametersType & parameters,
00159                               DerivativeType & derivative ) const = 0;
00160 
00162   virtual MeasureType    GetValue( const ParametersType & parameters ) const =0;
00163 
00165   virtual void GetValueAndDerivative( const ParametersType & parameters,
00166                                       MeasureType & Value, 
00167                                       DerivativeType  & Derivative ) const =0;
00168 
00170   virtual void Initialize(void) throw (ExceptionObject);
00171 
00174   itkGetConstReferenceMacro( LastTransformParameters, ParametersType );
00175 
00177   itkSetObjectMacro( Transform, TransformType );
00178 
00179 protected:
00180 
00181   ImageToSpatialObjectMetric();
00182   virtual ~ImageToSpatialObjectMetric() {};
00183   ImageToSpatialObjectMetric(const Self&) {}
00184   void operator=(const Self&) {}
00185   void PrintSelf(std::ostream& os, Indent indent) const;
00186 
00187   MeasureType                 m_MatchMeasure;
00188   DerivativeType              m_MatchMeasureDerivatives;
00189   mutable TransformPointer    m_Transform;
00190   InterpolatorPointer         m_Interpolator;
00191 
00192   MovingSpatialObjectConstPointer   m_MovingSpatialObject;
00193   FixedImageConstPointer            m_FixedImage;
00194   ParametersType                    m_LastTransformParameters;
00195 
00196 };
00197 
00198 } // end namespace itk
00199 
00200 #ifndef ITK_MANUAL_INSTANTIATION
00201 #include "itkImageToSpatialObjectMetric.txx"
00202 #endif
00203 
00204 #endif
00205 
00206 
00207 

Generated at Mon Apr 14 13:09:55 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000