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);
00076
00077 typedef typename FixedPointSetType::PointsContainer::ConstIterator PointIterator;
00078 typedef typename FixedPointSetType::PointDataContainer::ConstIterator PointDataIterator;
00079
00081 typedef Transform<CoordinateRepresentationType,
00082 itkGetStaticConstMacro(MovingImageDimension),
00083 itkGetStaticConstMacro(FixedPointSetDimension)> TransformType;
00084
00085 typedef typename TransformType::Pointer TransformPointer;
00086 typedef typename TransformType::InputPointType InputPointType;
00087 typedef typename TransformType::OutputPointType OutputPointType;
00088 typedef typename TransformType::ParametersType TransformParametersType;
00089 typedef typename TransformType::JacobianType TransformJacobianType;
00090
00092 typedef InterpolateImageFunction<
00093 MovingImageType,
00094 CoordinateRepresentationType > InterpolatorType;
00095
00096
00098 typedef typename NumericTraits<MovingImagePixelType>::RealType RealType;
00099 typedef CovariantVector<RealType,
00100 itkGetStaticConstMacro(MovingImageDimension)> GradientPixelType;
00101 typedef Image<GradientPixelType,
00102 itkGetStaticConstMacro(MovingImageDimension)> GradientImageType;
00103 typedef SmartPointer<GradientImageType> GradientImagePointer;
00104 typedef GradientRecursiveGaussianImageFilter< MovingImageType,
00105 GradientImageType >
00106 GradientImageFilterType;
00107 typedef typename GradientImageFilterType::Pointer GradientImageFilterPointer;
00108
00109
00110 typedef typename InterpolatorType::Pointer InterpolatorPointer;
00111
00113 typedef Superclass::MeasureType MeasureType;
00114
00116 typedef Superclass::DerivativeType DerivativeType;
00117
00119 typedef Superclass::ParametersType ParametersType;
00120
00122 itkSetConstObjectMacro( FixedPointSet, FixedPointSetType );
00123
00125 itkGetConstObjectMacro( FixedPointSet, FixedPointSetType );
00126
00128 itkSetConstObjectMacro( MovingImage, MovingImageType );
00129
00131 itkGetConstObjectMacro( MovingImage, MovingImageType );
00132
00134 itkSetObjectMacro( Transform, TransformType );
00135
00137 itkGetObjectMacro( Transform, TransformType );
00138
00140 itkSetObjectMacro( Interpolator, InterpolatorType );
00141
00143 itkGetObjectMacro( Interpolator, InterpolatorType );
00144
00146 itkGetConstMacro( NumberOfPixelsCounted, unsigned long );
00147
00149 void SetTransformParameters( const ParametersType & parameters ) const;
00150
00158 itkSetMacro( ComputeGradient, bool );
00159 itkGetConstMacro( ComputeGradient, bool );
00160
00162 unsigned int GetNumberOfParameters(void) const
00163 { return m_Transform->GetNumberOfParameters(); }
00164
00167 virtual void Initialize(void) throw ( ExceptionObject );
00168
00169 protected:
00170 PointSetToImageMetric();
00171 virtual ~PointSetToImageMetric() {};
00172 void PrintSelf(std::ostream& os, Indent indent) const;
00173
00174 mutable unsigned long m_NumberOfPixelsCounted;
00175
00176 FixedPointSetConstPointer m_FixedPointSet;
00177 MovingImageConstPointer m_MovingImage;
00178
00179 mutable TransformPointer m_Transform;
00180 InterpolatorPointer m_Interpolator;
00181
00182 bool m_ComputeGradient;
00183 GradientImagePointer m_GradientImage;
00184
00185 private:
00186 PointSetToImageMetric(const Self&);
00187 void operator=(const Self&);
00188
00189 };
00190
00191 }
00192
00193 #ifndef ITK_MANUAL_INSTANTIATION
00194 #include "itkPointSetToImageMetric.txx"
00195 #endif
00196
00197 #endif
00198
00199
00200