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: 2003/01/23 16:52:13 $
00007   Version:   $Revision: 1.4 $
00008 
00009   Copyright (c) 2002 Insight 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   
00033 template < class TFixedImage, class TMovingSpatialObject> 
00034 class ITK_EXPORT ImageToSpatialObjectMetric 
00035                            : public SingleValuedCostFunction
00036 {
00037 public:
00039   typedef ImageToSpatialObjectMetric  Self;
00041   typedef SingleValuedCostFunction  Superclass;
00043   typedef SmartPointer<Self>   Pointer;
00044   typedef SmartPointer<const Self>  ConstPointer;
00045 
00047   typedef TFixedImage          FixedImageType;
00048  
00050   typedef TMovingSpatialObject  MovingSpatialObjectType;
00051 
00053   typedef Superclass::ParametersValueType CoordinateRepresentationType;
00054 
00056   itkStaticConstMacro(ImageDimension, unsigned int, FixedImageType::ImageDimension);
00057  
00059   itkStaticConstMacro(ObjectDimension, unsigned int, MovingSpatialObjectType::ObjectDimension);
00060  
00062   typedef Transform<CoordinateRepresentationType, 
00063     itkGetStaticConstMacro(ObjectDimension),
00064     itkGetStaticConstMacro(ImageDimension) > TransformType;
00065 
00066   typedef typename TransformType::Pointer            TransformPointer;
00067   typedef typename TransformType::InputPointType     InputPointType;
00068   typedef typename TransformType::OutputPointType    OutputPointType;
00069   typedef typename TransformType::ParametersType     TransformParametersType;
00070   typedef typename TransformType::JacobianType       TransformJacobianType;
00071 
00073   typedef LinearInterpolateImageFunction<
00074                       TFixedImage,
00075                       CoordinateRepresentationType > InterpolatorType;
00076 
00077   typedef typename InterpolatorType::Pointer         InterpolatorPointer;
00078 
00080   typedef vnl_vector_fixed<double,
00081                            itkGetStaticConstMacro(ObjectDimension)> VectorType;
00082 
00084   typedef Superclass::MeasureType          MeasureType;
00085 
00087   typedef Superclass::DerivativeType   DerivativeType; 
00088 
00090   typedef typename FixedImageType::Pointer    FixedImagePointer;
00091 
00093   typedef typename MovingSpatialObjectType::Pointer  
00094                                                MovingSpatialObjectPointer;
00095 
00097   typedef typename FixedImageType::ConstPointer   FixedImageConstPointer;
00098   
00100   typedef typename MovingSpatialObjectType::ConstPointer    
00101                                            MovingSpatialObjectConstPointer;
00102 
00105   typedef Superclass::ParametersType         ParametersType;
00106 
00108   itkTypeMacro(ImageToSpatialObjectMetric, Object);
00109 
00111   itkNewMacro(Self);
00112 
00114   itkSetConstObjectMacro( FixedImage, FixedImageType );
00115   
00117   itkGetConstObjectMacro( FixedImage, FixedImageType );
00118 
00120   itkSetConstObjectMacro( MovingSpatialObject, MovingSpatialObjectType );
00121   
00123   itkGetConstObjectMacro( MovingSpatialObject, MovingSpatialObjectType );
00124 
00126   itkSetObjectMacro( Interpolator, InterpolatorType );
00127   
00129   itkGetObjectMacro( Interpolator, InterpolatorType );
00130 
00132   virtual void GetDerivative( const ParametersType & parameters,
00133                                     DerivativeType & derivative ) const = 0;
00134 
00136   virtual MeasureType    GetValue( const ParametersType & parameters ) const =0;
00137 
00139   virtual void GetValueAndDerivative( const ParametersType & parameters,
00140        MeasureType & Value, DerivativeType  & Derivative ) const =0;
00141 
00143   virtual void Initialize(void) {}
00144  
00147   itkGetConstReferenceMacro( LastTransformParameters, ParametersType );
00148 
00150   itkSetObjectMacro( Transform, TransformType );
00151 
00152 protected:
00153 
00154   ImageToSpatialObjectMetric();
00155   virtual ~ImageToSpatialObjectMetric() {};
00156   ImageToSpatialObjectMetric(const Self&) {}
00157   void operator=(const Self&) {}
00158   void PrintSelf(std::ostream& os, Indent indent) const;
00159 
00160   MeasureType                 m_MatchMeasure;
00161   DerivativeType              m_MatchMeasureDerivatives;
00162   mutable TransformPointer    m_Transform;
00163   InterpolatorPointer         m_Interpolator;
00164 
00165   MovingSpatialObjectConstPointer   m_MovingSpatialObject;
00166   FixedImageConstPointer            m_FixedImage;
00167   ParametersType                    m_LastTransformParameters;
00168 
00169 };
00170 
00171 } // end namespace itk
00172 
00173 #ifndef ITK_MANUAL_INSTANTIATION
00174   #include "itkImageToSpatialObjectMetric.txx"
00175 #endif
00176 
00177 #endif
00178 
00179 

Generated at Fri May 21 01:14:56 2004 for ITK by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2000