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 "itkImageGridSampler.h"
00022 #include "itkNearestNeighborInterpolateImageFunction.h"
00023 #include "itkAdvancedImageToImageMetric.h"
00024 
00025 namespace itk
00026 {
00027 
00053 template < class TFixedImage, class TMovingImage >
00054 class AdvancedMeanSquaresImageToImageMetric :
00055     public AdvancedImageToImageMetric< TFixedImage, TMovingImage>
00056 {
00057 public:
00058 
00060   typedef AdvancedMeanSquaresImageToImageMetric   Self;
00061   typedef AdvancedImageToImageMetric<
00062     TFixedImage, TMovingImage >                   Superclass;
00063   typedef SmartPointer<Self>                      Pointer;
00064   typedef SmartPointer<const Self>                ConstPointer;
00065 
00067   itkNewMacro( Self );
00068 
00070   itkTypeMacro( AdvancedMeanSquaresImageToImageMetric, AdvancedImageToImageMetric );
00071 
00073   typedef typename
00074     Superclass::CoordinateRepresentationType              CoordinateRepresentationType;
00075   typedef typename Superclass::MovingImageType            MovingImageType;
00076   typedef typename Superclass::MovingImagePixelType       MovingImagePixelType;
00077   typedef typename Superclass::MovingImageConstPointer    MovingImageConstPointer;
00078   typedef typename Superclass::FixedImageType             FixedImageType;
00079   typedef typename Superclass::FixedImageConstPointer     FixedImageConstPointer;
00080   typedef typename Superclass::FixedImageRegionType       FixedImageRegionType;
00081   typedef typename Superclass::TransformType              TransformType;
00082   typedef typename Superclass::TransformPointer           TransformPointer;
00083   typedef typename Superclass::InputPointType             InputPointType;
00084   typedef typename Superclass::OutputPointType            OutputPointType;
00085   typedef typename Superclass::TransformParametersType    TransformParametersType;
00086   typedef typename Superclass::TransformJacobianType      TransformJacobianType;
00087   typedef typename Superclass::InterpolatorType           InterpolatorType;
00088   typedef typename Superclass::InterpolatorPointer        InterpolatorPointer;
00089   typedef typename Superclass::RealType                   RealType;
00090   typedef typename Superclass::GradientPixelType          GradientPixelType;
00091   typedef typename Superclass::GradientImageType          GradientImageType;
00092   typedef typename Superclass::GradientImagePointer       GradientImagePointer;
00093   typedef typename Superclass::GradientImageFilterType    GradientImageFilterType;
00094   typedef typename Superclass::GradientImageFilterPointer GradientImageFilterPointer;
00095   typedef typename Superclass::FixedImageMaskType         FixedImageMaskType;
00096   typedef typename Superclass::FixedImageMaskPointer      FixedImageMaskPointer;
00097   typedef typename Superclass::MovingImageMaskType        MovingImageMaskType;
00098   typedef typename Superclass::MovingImageMaskPointer     MovingImageMaskPointer;
00099   typedef typename Superclass::MeasureType                MeasureType;
00100   typedef typename Superclass::DerivativeType             DerivativeType;
00101   typedef typename Superclass::ParametersType             ParametersType;
00102   typedef typename Superclass::FixedImagePixelType        FixedImagePixelType;
00103   typedef typename Superclass::MovingImageRegionType      MovingImageRegionType;
00104   typedef typename Superclass::ImageSamplerType           ImageSamplerType;
00105   typedef typename Superclass::ImageSamplerPointer        ImageSamplerPointer;
00106   typedef typename Superclass::ImageSampleContainerType   ImageSampleContainerType;
00107   typedef typename
00108     Superclass::ImageSampleContainerPointer               ImageSampleContainerPointer;
00109   typedef typename Superclass::FixedImageLimiterType      FixedImageLimiterType;
00110   typedef typename Superclass::MovingImageLimiterType     MovingImageLimiterType;
00111   typedef typename
00112     Superclass::FixedImageLimiterOutputType               FixedImageLimiterOutputType;
00113   typedef typename
00114     Superclass::MovingImageLimiterOutputType              MovingImageLimiterOutputType;
00115   typedef typename
00116     Superclass::MovingImageDerivativeScalesType           MovingImageDerivativeScalesType;
00117 
00119   typedef typename Superclass::HessianValueType           HessianValueType;
00120   typedef typename Superclass::HessianType                HessianType;
00121 
00123   itkStaticConstMacro( FixedImageDimension, unsigned int,
00124     FixedImageType::ImageDimension );
00125 
00127   itkStaticConstMacro( MovingImageDimension, unsigned int,
00128     MovingImageType::ImageDimension );
00129 
00131   virtual MeasureType GetValue( const TransformParametersType & parameters ) const;
00132 
00134   virtual void GetDerivative( const TransformParametersType & parameters,
00135     DerivativeType & derivative ) const;
00136 
00138   virtual void GetValueAndDerivative( const TransformParametersType & parameters,
00139     MeasureType& Value, DerivativeType& Derivative ) const;
00140 
00142   virtual void GetSelfHessian( const TransformParametersType & parameters, HessianType & H ) const;
00143 
00145   itkSetMacro( SelfHessianSmoothingSigma, double );
00146   itkGetConstMacro( SelfHessianSmoothingSigma, double );
00147 
00149   itkSetMacro( SelfHessianNoiseRange, double );
00150   itkGetConstMacro( SelfHessianNoiseRange, double );
00151 
00153   itkSetMacro( NumberOfSamplesForSelfHessian, unsigned int );
00154   itkGetConstMacro( NumberOfSamplesForSelfHessian, unsigned int );
00155 
00160   virtual void Initialize(void) throw ( ExceptionObject );
00161 
00169   itkSetMacro( UseNormalization, bool );
00170   itkGetConstMacro( UseNormalization, bool );
00171 
00172 protected:
00173   AdvancedMeanSquaresImageToImageMetric();
00174   virtual ~AdvancedMeanSquaresImageToImageMetric() {};
00175   void PrintSelf( std::ostream& os, Indent indent ) const;
00176 
00180   typedef typename Superclass::FixedImageIndexType                FixedImageIndexType;
00181   typedef typename Superclass::FixedImageIndexValueType           FixedImageIndexValueType;
00182   typedef typename Superclass::MovingImageIndexType               MovingImageIndexType;
00183   typedef typename Superclass::FixedImagePointType                FixedImagePointType;
00184   typedef typename Superclass::MovingImagePointType               MovingImagePointType;
00185   typedef typename Superclass::MovingImageContinuousIndexType     MovingImageContinuousIndexType;
00186   typedef typename Superclass::BSplineInterpolatorType            BSplineInterpolatorType;
00187   typedef typename Superclass::CentralDifferenceGradientFilterType CentralDifferenceGradientFilterType;
00188   typedef typename Superclass::MovingImageDerivativeType          MovingImageDerivativeType;
00189   typedef typename Superclass::NonZeroJacobianIndicesType         NonZeroJacobianIndicesType;
00190 
00192   typedef SmoothingRecursiveGaussianImageFilter<
00193     FixedImageType, FixedImageType>                               SmootherType;
00194   typedef BSplineInterpolateImageFunction<
00195     FixedImageType, CoordinateRepresentationType>                 FixedImageInterpolatorType;
00196   typedef NearestNeighborInterpolateImageFunction<
00197     FixedImageType, CoordinateRepresentationType >                DummyFixedImageInterpolatorType;
00198   //typedef ImageRandomCoordinateSampler<FixedImageType>            SelfHessianSamplerType;
00199   typedef ImageGridSampler<FixedImageType>                        SelfHessianSamplerType;
00200 
00201   double m_NormalizationFactor;
00202 
00206   void EvaluateTransformJacobianInnerProduct(
00207     const TransformJacobianType & jacobian,
00208     const MovingImageDerivativeType & movingImageDerivative,
00209     DerivativeType & imageJacobian) const;
00210 
00213   void UpdateValueAndDerivativeTerms(
00214     const RealType fixedImageValue,
00215     const RealType movingImageValue,
00216     const DerivativeType & imageJacobian,
00217     const NonZeroJacobianIndicesType & nzji,
00218     MeasureType & measure,
00219     DerivativeType & deriv ) const;
00220 
00223   void UpdateSelfHessianTerms(
00224     const DerivativeType & imageJacobian,
00225     const NonZeroJacobianIndicesType & nzji,
00226     HessianType & H) const;
00227 
00228 private:
00229   AdvancedMeanSquaresImageToImageMetric(const Self&); //purposely not implemented
00230   void operator=(const Self&); //purposely not implemented
00231 
00232   bool m_UseNormalization;
00233   double m_SelfHessianSmoothingSigma;
00234   double m_SelfHessianNoiseRange;
00235   unsigned int m_NumberOfSamplesForSelfHessian;
00236 
00237 }; // end class AdvancedMeanSquaresImageToImageMetric
00238 
00239 } // end namespace itk
00240 
00241 #ifndef ITK_MANUAL_INSTANTIATION
00242 #include "itkAdvancedMeanSquaresImageToImageMetric.hxx"
00243 #endif
00244 
00245 #endif // end #ifndef __itkAdvancedMeanSquaresImageToImageMetric_h
00246 


Generated on 11-05-2012 for elastix by doxygen 1.7.6.1 elastix logo