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,
00057 FixedImageType::ImageDimension);
00058
00060 itkStaticConstMacro(ObjectDimension, unsigned int,
00061 MovingSpatialObjectType::ObjectDimension);
00062
00064 typedef Transform<CoordinateRepresentationType,
00065 itkGetStaticConstMacro(ObjectDimension),
00066 itkGetStaticConstMacro(ImageDimension) > TransformType;
00067
00068 typedef typename TransformType::Pointer TransformPointer;
00069 typedef typename TransformType::InputPointType InputPointType;
00070 typedef typename TransformType::OutputPointType OutputPointType;
00071 typedef typename TransformType::ParametersType TransformParametersType;
00072 typedef typename TransformType::JacobianType TransformJacobianType;
00073
00075 typedef LinearInterpolateImageFunction<
00076 TFixedImage,
00077 CoordinateRepresentationType > InterpolatorType;
00078
00079 typedef typename InterpolatorType::Pointer InterpolatorPointer;
00080
00082 typedef vnl_vector_fixed<double,
00083 itkGetStaticConstMacro(ObjectDimension)> VectorType;
00084
00086 typedef Superclass::MeasureType MeasureType;
00087
00089 typedef Superclass::DerivativeType DerivativeType;
00090
00092 typedef typename FixedImageType::Pointer FixedImagePointer;
00093
00095 typedef typename MovingSpatialObjectType::Pointer
00096 MovingSpatialObjectPointer;
00097
00099 typedef typename FixedImageType::ConstPointer FixedImageConstPointer;
00100
00102 typedef typename MovingSpatialObjectType::ConstPointer
00103 MovingSpatialObjectConstPointer;
00104
00107 typedef Superclass::ParametersType ParametersType;
00108
00110 itkTypeMacro(ImageToSpatialObjectMetric, Object);
00111
00113 itkSetConstObjectMacro( FixedImage, FixedImageType );
00114
00116 itkGetConstObjectMacro( FixedImage, FixedImageType );
00117
00119 itkSetConstObjectMacro( MovingSpatialObject, MovingSpatialObjectType );
00120
00122 itkGetConstObjectMacro( MovingSpatialObject, MovingSpatialObjectType );
00123
00125 itkSetObjectMacro( Interpolator, InterpolatorType );
00126
00128 itkGetObjectMacro( Interpolator, InterpolatorType );
00129
00131 virtual void GetDerivative( const ParametersType & parameters,
00132 DerivativeType & derivative ) const = 0;
00133
00135 virtual MeasureType GetValue( const ParametersType & parameters ) const =0;
00136
00138 virtual void GetValueAndDerivative( const ParametersType & parameters,
00139 MeasureType & Value,
00140 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