00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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);
00077
00078 typedef typename FixedPointSetType::PointsContainer::ConstIterator PointIterator;
00079 typedef typename FixedPointSetType::PointDataContainer::ConstIterator PointDataIterator;
00080
00082 typedef Transform<CoordinateRepresentationType,
00083 itkGetStaticConstMacro(MovingImageDimension),
00084 itkGetStaticConstMacro(FixedPointSetDimension)> TransformType;
00085
00086 typedef typename TransformType::Pointer TransformPointer;
00087 typedef typename TransformType::InputPointType InputPointType;
00088 typedef typename TransformType::OutputPointType OutputPointType;
00089 typedef typename TransformType::ParametersType TransformParametersType;
00090 typedef typename TransformType::JacobianType TransformJacobianType;
00091
00093 typedef InterpolateImageFunction<
00094 MovingImageType,
00095 CoordinateRepresentationType > InterpolatorType;
00096
00097
00099 typedef typename NumericTraits<MovingImagePixelType>::RealType RealType;
00100 typedef CovariantVector<RealType,
00101 itkGetStaticConstMacro(MovingImageDimension)> GradientPixelType;
00102 typedef Image<GradientPixelType,
00103 itkGetStaticConstMacro(MovingImageDimension)> GradientImageType;
00104 typedef SmartPointer<GradientImageType> GradientImagePointer;
00105 typedef GradientRecursiveGaussianImageFilter< MovingImageType,
00106 GradientImageType >
00107 GradientImageFilterType;
00108 typedef typename GradientImageFilterType::Pointer GradientImageFilterPointer;
00110
00111
00112 typedef typename InterpolatorType::Pointer InterpolatorPointer;
00113
00115 typedef Superclass::MeasureType MeasureType;
00116
00118 typedef Superclass::DerivativeType DerivativeType;
00119
00121 typedef Superclass::ParametersType ParametersType;
00122
00124 itkSetConstObjectMacro( FixedPointSet, FixedPointSetType );
00125
00127 itkGetConstObjectMacro( FixedPointSet, FixedPointSetType );
00128
00130 itkSetConstObjectMacro( MovingImage, MovingImageType );
00131
00133 itkGetConstObjectMacro( MovingImage, MovingImageType );
00134
00136 itkSetObjectMacro( Transform, TransformType );
00137
00139 itkGetObjectMacro( Transform, TransformType );
00140
00142 itkSetObjectMacro( Interpolator, InterpolatorType );
00143
00145 itkGetObjectMacro( Interpolator, InterpolatorType );
00146
00148 itkGetConstObjectMacro( GradientImage, GradientImageType );
00149
00151 itkGetConstReferenceMacro( NumberOfPixelsCounted, unsigned long );
00152
00154 void SetTransformParameters( const ParametersType & parameters ) const;
00155
00163 itkSetMacro( ComputeGradient, bool );
00164 itkGetConstReferenceMacro( ComputeGradient, bool );
00166
00168 unsigned int GetNumberOfParameters(void) const
00169 { return m_Transform->GetNumberOfParameters(); }
00170
00173 virtual void Initialize(void) throw ( ExceptionObject );
00174
00175 protected:
00176 PointSetToImageMetric();
00177 virtual ~PointSetToImageMetric() {};
00178 void PrintSelf(std::ostream& os, Indent indent) const;
00179
00180 mutable unsigned long m_NumberOfPixelsCounted;
00181
00182 FixedPointSetConstPointer m_FixedPointSet;
00183 MovingImageConstPointer m_MovingImage;
00184
00185 mutable TransformPointer m_Transform;
00186 InterpolatorPointer m_Interpolator;
00187
00188 bool m_ComputeGradient;
00189 GradientImagePointer m_GradientImage;
00190
00191 private:
00192 PointSetToImageMetric(const Self&);
00193 void operator=(const Self&);
00194
00195 };
00196
00197 }
00198
00199 #ifndef ITK_MANUAL_INSTANTIATION
00200 #include "itkPointSetToImageMetric.txx"
00201 #endif
00202
00203 #endif
00204