/*========================================================================= Program: Insight Segmentation & Registration Toolkit Module: $RCSfile: itkMeanSquaresImageToImageMetric2.h,v $ Language: C++ Date: $Date: 2003/09/10 14:28:35 $ Version: $Revision: 1.27 $ 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 __itkMeanSquaresImageToImageMetric2_h #define __itkMeanSquaresImageToImageMetric2_h #include "itkImageToImageMetric.h" #include "itkCovariantVector.h" #include "itkPoint.h" #include "itkBSplineDeformableTransform.h" #include "itkCentralDifferenceImageFunction.h" namespace itk { /** \class MeanSquaresImageToImageMetric2 * \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. * * The difference between this class and MeanSquaresImageToImageMetric is * that optimization have been added to improve performance when used * in registration with a BSplineDeformableTransform. * * \ingroup RegistrationMetrics */ template < class TFixedImage, class TMovingImage > class ITK_EXPORT MeanSquaresImageToImageMetric2 : public ImageToImageMetric< TFixedImage, TMovingImage> { public: /** Standard class typedefs. */ typedef MeanSquaresImageToImageMetric2 Self; typedef ImageToImageMetric Superclass; typedef SmartPointer Pointer; typedef SmartPointer ConstPointer; /** Method for creation through the object factory. */ itkNewMacro(Self); /** Run-time type information (and related methods). */ itkTypeMacro(MeanSquaresImageToImageMetric2, ImageToImageMetric); /** 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::TransformJacobianType TransformJacobianType; typedef typename Superclass::GradientPixelType GradientPixelType; typedef typename Superclass::MeasureType MeasureType; typedef typename Superclass::DerivativeType DerivativeType; typedef typename Superclass::FixedImageType FixedImageType; typedef typename Superclass::MovingImageType MovingImageType; typedef typename Superclass::FixedImageConstPointer FixedImageConstPointer; typedef typename Superclass::MovingImageConstPointer MovingImageConstPointer; typedef typename Superclass::CoordinateRepresentationType CoordinateRepresentationType; /** Initialize the metric */ virtual void Initialize(void) throw ( ExceptionObject ); /** Get the derivatives of the match measure. */ void GetDerivative( const TransformParametersType & parameters, DerivativeType & derivative ) const; /** Get the value for single valued optimizers. */ MeasureType GetValue( const TransformParametersType & parameters ) const; /** Get value and derivatives for multiple valued optimizers. */ void GetValueAndDerivative( const TransformParametersType & parameters, MeasureType& Value, DerivativeType& Derivative ) const; protected: MeanSquaresImageToImageMetric2(); virtual ~MeanSquaresImageToImageMetric2() {}; private: MeanSquaresImageToImageMetric2(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented /** Boolean to indicate if the transform is BSpline deformable. */ bool m_TransformIsBSpline; /** * Enum of the deformabtion field spline order. */ enum { DeformationSplineOrder = 3 }; /** * Typedefs for the BSplineDeformableTransform. */ typedef BSplineDeformableTransform< CoordinateRepresentationType, ::itk::GetImageDimension::ImageDimension, DeformationSplineOrder> BSplineTransformType; typedef typename BSplineTransformType::WeightsType BSplineTransformWeightsType; typedef typename BSplineTransformType::ParameterIndexArrayType BSplineTransformIndexArrayType; /** * Variables used when transform is of type BSpline deformable. */ typename BSplineTransformType::Pointer m_BSplineTransform; /** Typedefs for using central difference calculator. */ typedef CentralDifferenceImageFunction DerivativeFunctionType; /** Pointer to central difference calculator. */ typename DerivativeFunctionType::Pointer m_DerivativeCalculator; }; } // end namespace itk #ifndef ITK_MANUAL_INSTANTIATION #include "itkMeanSquaresImageToImageMetric2.txx" #endif #endif