00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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 }
00172
00173 #ifndef ITK_MANUAL_INSTANTIATION
00174 #include "itkImageToSpatialObjectMetric.txx"
00175 #endif
00176
00177 #endif
00178
00179