go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkAdvancedMeanSquaresImageToImageMetric.h
Go to the documentation of this file.
00001 /*======================================================================
00002 
00003   This file is part of the elastix software.
00004 
00005   Copyright (c) University Medical Center Utrecht. All rights reserved.
00006   See src/CopyrightElastix.txt or http://elastix.isi.uu.nl/legal.php for
00007   details.
00008 
00009      This software is distributed WITHOUT ANY WARRANTY; without even
00010      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00011      PURPOSE. See the above copyright notices for more information.
00012 
00013 ======================================================================*/
00014 
00015 
00016 #ifndef __itkAdvancedMeanSquaresImageToImageMetric_h
00017 #define __itkAdvancedMeanSquaresImageToImageMetric_h
00018 
00019 #include "itkSmoothingRecursiveGaussianImageFilter.h"
00020 #include "itkImageRandomCoordinateSampler.h"
00021 #include "itkNearestNeighborInterpolateImageFunction.h"
00022 #include "itkAdvancedImageToImageMetric.h"
00023 
00024 namespace itk
00025 {
00026 
00052 template < class TFixedImage, class TMovingImage >
00053 class AdvancedMeanSquaresImageToImageMetric :
00054     public AdvancedImageToImageMetric< TFixedImage, TMovingImage>
00055 {
00056 public:
00057 
00059   typedef AdvancedMeanSquaresImageToImageMetric   Self;
00060   typedef AdvancedImageToImageMetric<
00061     TFixedImage, TMovingImage >                   Superclass;
00062   typedef SmartPointer<Self>                      Pointer;
00063   typedef SmartPointer<const Self>                ConstPointer;
00064 
00066   itkNewMacro( Self );
00067 
00069   itkTypeMacro( AdvancedMeanSquaresImageToImageMetric, AdvancedImageToImageMetric );
00070 
00072   typedef typename
00073     Superclass::CoordinateRepresentationType              CoordinateRepresentationType;
00074   typedef typename Superclass::MovingImageType            MovingImageType;
00075   typedef typename Superclass::MovingImagePixelType       MovingImagePixelType;
00076   typedef typename Superclass::MovingImageConstPointer    MovingImageConstPointer;
00077   typedef typename Superclass::FixedImageType             FixedImageType;
00078   typedef typename Superclass::FixedImageConstPointer     FixedImageConstPointer;
00079   typedef typename Superclass::FixedImageRegionType       FixedImageRegionType;
00080   typedef typename Superclass::TransformType              TransformType;
00081   typedef typename Superclass::TransformPointer           TransformPointer;
00082   typedef typename Superclass::InputPointType             InputPointType;
00083   typedef typename Superclass::OutputPointType            OutputPointType;
00084   typedef typename Superclass::TransformParametersType    TransformParametersType;
00085   typedef typename Superclass::TransformJacobianType      TransformJacobianType;
00086   typedef typename Superclass::InterpolatorType           InterpolatorType;
00087   typedef typename Superclass::InterpolatorPointer        InterpolatorPointer;
00088   typedef typename Superclass::RealType                   RealType;
00089   typedef typename Superclass::GradientPixelType          GradientPixelType;
00090   typedef typename Superclass::GradientImageType          GradientImageType;
00091   typedef typename Superclass::GradientImagePointer       GradientImagePointer;
00092   typedef typename Superclass::GradientImageFilterType    GradientImageFilterType;
00093   typedef typename Superclass::GradientImageFilterPointer GradientImageFilterPointer;
00094   typedef typename Superclass::FixedImageMaskType         FixedImageMaskType;
00095   typedef typename Superclass::FixedImageMaskPointer      FixedImageMaskPointer;
00096   typedef typename Superclass::MovingImageMaskType        MovingImageMaskType;
00097   typedef typename Superclass::MovingImageMaskPointer     MovingImageMaskPointer;
00098   typedef typename Superclass::MeasureType                MeasureType;
00099   typedef typename Superclass::DerivativeType             DerivativeType;
00100   typedef typename Superclass::ParametersType             ParametersType;
00101   typedef typename Superclass::FixedImagePixelType        FixedImagePixelType;
00102   typedef typename Superclass::MovingImageRegionType      MovingImageRegionType;
00103   typedef typename Superclass::ImageSamplerType           ImageSamplerType;
00104   typedef typename Superclass::ImageSamplerPointer        ImageSamplerPointer;
00105   typedef typename Superclass::ImageSampleContainerType   ImageSampleContainerType;
00106   typedef typename
00107     Superclass::ImageSampleContainerPointer               ImageSampleContainerPointer;
00108   typedef typename Superclass::FixedImageLimiterType      FixedImageLimiterType;
00109   typedef typename Superclass::MovingImageLimiterType     MovingImageLimiterType;
00110   typedef typename
00111     Superclass::FixedImageLimiterOutputType               FixedImageLimiterOutputType;
00112   typedef typename
00113     Superclass::MovingImageLimiterOutputType              MovingImageLimiterOutputType;
00114   typedef typename
00115     Superclass::MovingImageDerivativeScalesType           MovingImageDerivativeScalesType;
00116 
00118   typedef typename Superclass::HessianValueType           HessianValueType;
00119   typedef typename Superclass::HessianType                HessianType;
00120 
00122   itkStaticConstMacro( FixedImageDimension, unsigned int,
00123     FixedImageType::ImageDimension );
00124 
00126   itkStaticConstMacro( MovingImageDimension, unsigned int,
00127     MovingImageType::ImageDimension );
00128 
00130   virtual MeasureType GetValue( const TransformParametersType & parameters ) const;
00131 
00133   virtual void GetDerivative( const TransformParametersType & parameters,
00134     DerivativeType & derivative ) const;
00135 
00137   virtual void GetValueAndDerivative( const TransformParametersType & parameters,
00138     MeasureType& Value, DerivativeType& Derivative ) const;
00139 
00141   virtual void GetSelfHessian( const TransformParametersType & parameters, HessianType & H ) const;
00142 
00144   itkSetMacro( SelfHessianSmoothingSigma, double );
00145   itkGetConstMacro( SelfHessianSmoothingSigma, double );
00146 
00148   itkSetMacro( SelfHessianNoiseRange, double );
00149   itkGetConstMacro( SelfHessianNoiseRange, double );
00150 
00152   itkSetMacro( NumberOfSamplesForSelfHessian, unsigned int );
00153   itkGetConstMacro( NumberOfSamplesForSelfHessian, unsigned int );
00154 
00159   virtual void Initialize(void) throw ( ExceptionObject );
00160 
00168   itkSetMacro( UseNormalization, bool );
00169   itkGetConstMacro( UseNormalization, bool );
00170 
00171 protected:
00172   AdvancedMeanSquaresImageToImageMetric();
00173   virtual ~AdvancedMeanSquaresImageToImageMetric() {};
00174   void PrintSelf( std::ostream& os, Indent indent ) const;
00175 
00179   typedef typename Superclass::FixedImageIndexType                FixedImageIndexType;
00180   typedef typename Superclass::FixedImageIndexValueType           FixedImageIndexValueType;
00181   typedef typename Superclass::MovingImageIndexType               MovingImageIndexType;
00182   typedef typename Superclass::FixedImagePointType                FixedImagePointType;
00183   typedef typename Superclass::MovingImagePointType               MovingImagePointType;
00184   typedef typename Superclass::MovingImageContinuousIndexType     MovingImageContinuousIndexType;
00185   typedef typename Superclass::BSplineInterpolatorType            BSplineInterpolatorType;
00186   typedef typename Superclass::CentralDifferenceGradientFilterType CentralDifferenceGradientFilterType;
00187   typedef typename Superclass::MovingImageDerivativeType          MovingImageDerivativeType;
00188   typedef typename Superclass::NonZeroJacobianIndicesType         NonZeroJacobianIndicesType;
00189 
00191   typedef SmoothingRecursiveGaussianImageFilter<
00192     FixedImageType, FixedImageType>                               SmootherType;
00193   typedef BSplineInterpolateImageFunction<
00194     FixedImageType, CoordinateRepresentationType>                 FixedImageInterpolatorType;
00195   typedef NearestNeighborInterpolateImageFunction<
00196     FixedImageType, CoordinateRepresentationType >                DummyFixedImageInterpolatorType;
00197   typedef ImageRandomCoordinateSampler<FixedImageType>            SelfHessianSamplerType;
00198 
00199   double m_NormalizationFactor;
00200 
00204   void EvaluateTransformJacobianInnerProduct(
00205     const TransformJacobianType & jacobian,
00206     const MovingImageDerivativeType & movingImageDerivative,
00207     DerivativeType & imageJacobian) const;
00208 
00211   void UpdateValueAndDerivativeTerms(
00212     const RealType fixedImageValue,
00213     const RealType movingImageValue,
00214     const DerivativeType & imageJacobian,
00215     const NonZeroJacobianIndicesType & nzji,
00216     MeasureType & measure,
00217     DerivativeType & deriv ) const;
00218 
00221   void UpdateSelfHessianTerms(
00222     const DerivativeType & imageJacobian,
00223     const NonZeroJacobianIndicesType & nzji,
00224     HessianType & H) const;
00225 
00226 private:
00227   AdvancedMeanSquaresImageToImageMetric(const Self&); //purposely not implemented
00228   void operator=(const Self&); //purposely not implemented
00229 
00230   bool m_UseNormalization;
00231   double m_SelfHessianSmoothingSigma;
00232   double m_SelfHessianNoiseRange;
00233   unsigned int m_NumberOfSamplesForSelfHessian;
00234 
00235 }; // end class AdvancedMeanSquaresImageToImageMetric
00236 
00237 } // end namespace itk
00238 
00239 #ifndef ITK_MANUAL_INSTANTIATION
00240 #include "itkAdvancedMeanSquaresImageToImageMetric.hxx"
00241 #endif
00242 
00243 #endif // end #ifndef __itkAdvancedMeanSquaresImageToImageMetric_h
00244 


Generated on 11-05-2011 for elastix by doxygen 1.7.4 elastix logo