/*========================================================================= Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkMeanSquaresAnytimeImageToImageMetric2.h,v $ Language: C++ Date: $Date: 2007/09/28 21:38:43 $ Version: $Revision: 1.8 $ 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 __itkMeanSquaresAnytimeImageToImageMetric2_h #define __itkMeanSquaresAnytimeImageToImageMetric2_h #include "itkAnytimeImageToImageMetric2.h" #include "itkCovariantVector.h" #include "itkPoint.h" namespace itk { /** \class MeanSquaresAnytimeImageToImageMetric2 * \brief Computes similarity between two objects to be registered * * This Class is templated over the type of the fixed and moving * images to be compared. * * This metric computes the sum of squared differenced between pixels in * the moving image and pixels in the fixed image. The spatial correspondance * between both images is established through a Transform. Pixel values are * taken from the Moving image. Their positions are mapped to the Fixed image * and result in general in non-grid position on it. Values at these non-grid * position of the Fixed image are interpolated using a user-selected Interpolator. * * \ingroup RegistrationMetrics */ template < class TFixedImage, class TMovingImage > class ITK_EXPORT MeanSquaresAnytimeImageToImageMetric2 : public AnytimeImageToImageMetric2< TFixedImage, TMovingImage> { public: /** Standard class typedefs. */ typedef MeanSquaresAnytimeImageToImageMetric2 Self; typedef AnytimeImageToImageMetric2 Superclass; typedef SmartPointer Pointer; typedef SmartPointer ConstPointer; /** Method for creation through the object factory. */ itkNewMacro(Self); /** Run-time type information (and related methods). */ itkTypeMacro(MeanSquaresAnytimeImageToImageMetric2, AnytimeImageToImageMetric2); /** Types transferred from the base class */ typedef typename Superclass::RealType RealType; typedef typename Superclass::TransformType TransformType; typedef typename Superclass::TransformPointer TransformPointer; typedef typename Superclass::TransformParametersType TransformParametersType; typedef typename Superclass::ParametersType ParametersType; typedef typename Superclass::TransformJacobianType TransformJacobianType; typedef typename Superclass::GradientPixelType GradientPixelType; typedef typename Superclass::MeasureType MeasureType; typedef typename Superclass::DerivativeType DerivativeType; typedef typename Superclass::HessianType HessianType; typedef typename Superclass::FixedImageType FixedImageType; typedef typename Superclass::MovingImageType MovingImageType; typedef typename Superclass::FixedImageConstPointer FixedImageConstPointer; typedef typename Superclass::MovingImageConstPointer MovingImageConstPointer; typedef typename Superclass::RandomIterator RandomIterator; typedef typename Superclass::FixedImageSpatialSampleContainer FixedImageSpatialSampleContainer; typedef typename Superclass::FixedImageSpatialSample FixedImageSpatialSample; typedef typename Superclass::MovingImageContinuousIndexType MovingImageContinuousIndexType; /** Get the derivatives of the match measure. */ //void GetDerivative( const ParametersType & parameters, // DerivativeType & derivative, int channel ) const; /** Get the value for single valued optimizers. */ //MeasureType GetValue( const ParametersType & parameters,const int channel ) const; /** Get value and derivatives for multiple valued optimizers. */ //void GetValueAndDerivative( const ParametersType & parameters, // MeasureType& Value, DerivativeType& Derivative, // int channel ) const; /** Get the derivatives of the match measure. */ //void GetHessian( const ParametersType & parameters, // HessianType & Hessian, const int channel ) const; /** Get the derivatives of the match measure. */ //void GetValueAndHessian( const ParametersType & parameters, // MeasureType& value, HessianType & Hessian, const int channel ) const; /** Get the derivatives of the match measure. */ //void GetDerivativeAndHessian( const ParametersType & parameters, // DerivativeType& derivative, HessianType & Hessian, const int channel ) const; /** Get the derivatives of the match measure. */ //void GetValueAndDerivativeAndHessian( const ParametersType & parameters, // MeasureType& value, DerivativeType & derivative, // HessianType & Hessian, const int channel ) const; virtual void GetValueAndDerivativeAndHessian_calc(bool calcvalue,bool calcderivative,bool calchessian, bool fixedmask,bool movingmask,const ParametersType & parameters, MeasureType & value, DerivativeType & derivative, HessianType & H, int channel) const; template < bool calcvalue,bool calcderivative,bool calchessian, bool fixedmask,bool movingmask> void GetValueAndDerivativeAndHessian_calc(const TransformParametersType & parameters, MeasureType & value, DerivativeType & derivative,HessianType & Hessian, int channel) const; virtual void Initialize(void) throw (ExceptionObject); protected: MeanSquaresAnytimeImageToImageMetric2(); virtual ~MeanSquaresAnytimeImageToImageMetric2() {}; mutable MeasureType m_SumCache[NUMCHANNELS]; mutable DerivativeType* m_DerivativeSumCache[NUMCHANNELS]; mutable DerivativeType* m_DerivativeSumCacheESM[NUMCHANNELS]; private: MeanSquaresAnytimeImageToImageMetric2(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented //typedef itk::ImageRandomConstIteratorWithIndex FixedIteratorType; // FixedIteratorType *ti; }; } // end namespace itk #ifndef ITK_MANUAL_INSTANTIATION #include "itkMeanSquaresAnytimeImageToImageMetric2.txx" #endif #endif