/*========================================================================= Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkModImageToImageMetric2.h,v $ Language: C++ Date: $Date: 2007/09/28 21:38:43 $ Version: $Revision: 1.18 $ Copyright (c) Insight Software Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef __itkModImageToImageMetric_h #define __itkModImageToImageMetric_h #include "itkImageToImageMetric.h" #include "itkArray2D.h" #include "itkContinuousIndex.h" #include "itkCentralDifferenceImageFunction.h" #include "itkBSplineInterpolateImageFunction.h" #include "itkResampleImageFilter.h" namespace itk { /** \class ModImageToImageMetric * \brief This modification to ImageToImageMetric adds a * general ComputeGradient method * * \ingroup RegistrationMetrics * */ template class ITK_EXPORT ModImageToImageMetric : public ImageToImageMetric { public: /** Standard class typedefs. */ typedef ModImageToImageMetric Self; typedef ImageToImageMetric Superclass; typedef SmartPointer Pointer; typedef SmartPointer ConstPointer; /** Type used for representing point components */ typedef typename Superclass::ParametersValueType CoordinateRepresentationType; /** Run-time type information (and related methods). */ itkTypeMacro(ModImageToImageMetric, ImageToImageMetric); /* unsigned int m_NumberOfChannels; mutable unsigned long m_TotalPixelsProcessed; unsigned long m_NumberOfSpatialSamples; unsigned long m_NumberOfAvailableSamples; int m_RandomSeed; PerformanceProfileTable m_PerformanceProfile; PriorityImageType * m_PriorityImage; itkSetObjectMacro(PriorityImage,PriorityImageType); itkSetMacro(NumberOfChannels,unsigned int); itkSetMacro(TotalPixelsProcessed,unsigned long); itkGetMacro(TotalPixelsProcessed,unsigned long); itkGetMacro(NumberOfAvailableSamples,unsigned long); itkSetMacro(RandomSeed,int); itkSetMacro(NumberOfEvaluations,unsigned long); itkGetMacro(NumberOfEvaluations,unsigned long); itkSetMacro(NumberOfValueEvaluations,unsigned long); itkGetMacro(NumberOfValueEvaluations,unsigned long); itkSetMacro(NumberOfDerivativeEvaluations,unsigned long); itkGetMacro(NumberOfDerivativeEvaluations,unsigned long); itkSetMacro(NumberOfHessianEvaluations,unsigned long); itkGetMacro(NumberOfHessianEvaluations,unsigned long); itkGetConstReferenceMacro(NumberOfChannels,unsigned int); */ enum GradientCalculationMethod{GradientImage,BSpline,Calculator,Inverse,ESM,InverseCompositional}; GradientCalculationMethod m_GradientMethod; itkGetMacro(GradientMethod,GradientCalculationMethod); itkSetMacro(GradientMethod,GradientCalculationMethod); typedef typename Superclass::FixedImageType FixedImageType; typedef typename Superclass::MovingImageType MovingImageType; typedef typename Superclass::TransformType TransformType; typedef typename Superclass::TransformPointer TransformPointer; typedef typename Superclass::InputPointType InputPointType; typedef typename Superclass::OutputPointType OutputPointType; typedef typename Superclass::TransformParametersType TransformParametersType; typedef typename Superclass::TransformJacobianType TransformJacobianType; typedef typename Superclass::InterpolatorType InterpolatorType; typedef typename Superclass::RealType RealType; typedef typename Superclass::GradientImageType GradientImageType; typedef typename Superclass::GradientPixelType GradientPixelType; typedef typename Superclass::GradientImagePointer GradientImagePointer; typedef typename Superclass::GradientImageFilterType GradientImageFilterType; typedef typename Superclass::GradientImageFilterPointer GradientImageFilterPointer; typedef typename Superclass::InterpolatorPointer InterpolatorPointer; typedef typename Superclass::FixedImageMaskType FixedImageMaskType; typedef typename Superclass::FixedImageMaskPointer FixedImageMaskPointer; typedef typename Superclass::MovingImageMaskType MovingImageMaskType; typedef typename Superclass::MovingImageMaskPointer MovingImageMaskPointer; typedef typename Superclass::MeasureType MeasureType; typedef typename Superclass::DerivativeType DerivativeType; typedef typename Superclass::ParametersType ParametersType; /** Index and Point typedef support. */ typedef typename FixedImageType::IndexType FixedImageIndexType; typedef typename FixedImageType::PixelType FixedImagePixelType; typedef typename FixedImageIndexType::IndexValueType FixedImageIndexValueType; typedef typename MovingImageType::IndexType MovingImageIndexType; typedef typename TransformType::InputPointType FixedImagePointType; typedef typename TransformType::OutputPointType MovingImagePointType; //typedef typename Superclass::OutputPointType OutputPointType; typedef typename OutputPointType::CoordRepType CoordRepType; typedef ContinuousIndex MovingImageContinuousIndexType; // typedef typename Superclass::RandomIterator RandomIterator; public: /** Typedefs for using central difference calculator. */ typedef CentralDifferenceImageFunction DerivativeFunctionType; /** Pointer to central difference calculator. */ typename DerivativeFunctionType::Pointer m_DerivativeCalculator; void Initialize(void) throw ( ExceptionObject ); /** Boolean to indicate if the interpolator BSpline. */ bool m_InterpolatorIsBSpline; /** Typedefs for using BSpline interpolator. */ typedef BSplineInterpolateImageFunction BSplineInterpolatorType; /** Pointer to BSplineInterpolator. */ typename BSplineInterpolatorType::Pointer m_BSplineInterpolator; protected: ModImageToImageMetric(){ m_GradientMethod=GradientImage; m_DerivativeCalculator = NULL; m_InterpolatorIsBSpline = false; }; virtual ~ModImageToImageMetric() {}; /** Compute image derivatives at a point. */ virtual void ComputeImageDerivatives( const MovingImagePointType& mappedPoint, GradientPixelType& gradient ) const; // virtual void ComputeImageDerivatives( const FixedImageIndexType& fixedIndex, // const FixedImagePointType& fixedPoint, // const MovingImagePointType& mappedPoint, // ParametersType& parametergradient, // const MovingImageContinuousIndexType& tempindex) const; // virtual void ComputeImageDerivatives2( typename FixedImageSpatialSampleContainer::const_iterator fiter, // const MovingImagePointType& mappedPoint, // ParametersType& parametergradient, // const MovingImageContinuousIndexType& tempindex) const; private: void operator=(const Self&); }; } // end namespace itk #ifndef ITK_MANUAL_INSTANTIATION #include "itkModImageToImageMetric.txx" #endif #endif