go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkVarianceOverLastDimensionImageMetric.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 __itkVarianceOverLastDimensionImageMetric_h
00017 #define __itkVarianceOverLastDimensionImageMetric_h
00018 
00019 #include "itkSmoothingRecursiveGaussianImageFilter.h"
00020 #include "itkImageRandomCoordinateSampler.h"
00021 #include "itkNearestNeighborInterpolateImageFunction.h"
00022 #include "itkAdvancedImageToImageMetric.h"
00023 
00024 namespace itk
00025 {
00026 
00048 template < class TFixedImage, class TMovingImage >
00049 class VarianceOverLastDimensionImageMetric :
00050     public AdvancedImageToImageMetric< TFixedImage, TMovingImage>
00051 {
00052 public:
00053 
00055   typedef VarianceOverLastDimensionImageMetric    Self;
00056   typedef AdvancedImageToImageMetric<
00057     TFixedImage, TMovingImage >                   Superclass;
00058   typedef SmartPointer<Self>                      Pointer;
00059   typedef SmartPointer<const Self>                ConstPointer;
00060 
00061   typedef typename Superclass::FixedImageRegionType       FixedImageRegionType;
00062   typedef typename FixedImageRegionType::SizeType         FixedImageSizeType;
00063 
00065   itkNewMacro( Self );
00066 
00068   itkTypeMacro( VarianceOverLastDimensionImageMetric, AdvancedImageToImageMetric );
00069 
00071   itkSetMacro( SampleLastDimensionRandomly, bool );
00072   itkSetMacro( NumSamplesLastDimension, unsigned int );
00073   itkSetMacro( NumAdditionalSamplesFixed, unsigned int );
00074   itkSetMacro( ReducedDimensionIndex, unsigned int );
00075   itkSetMacro( SubtractMean, bool );
00076   itkSetMacro( GridSize, FixedImageSizeType );
00077   itkSetMacro( TransformIsStackTransform, bool );
00078 
00080   itkGetConstMacro(SampleLastDimensionRandomly, bool);
00081   itkGetConstMacro(NumSamplesLastDimension, int);
00082 
00084   typedef typename
00085     Superclass::CoordinateRepresentationType              CoordinateRepresentationType;
00086   typedef typename Superclass::MovingImageType            MovingImageType;
00087   typedef typename Superclass::MovingImagePixelType       MovingImagePixelType;
00088   typedef typename Superclass::MovingImageConstPointer    MovingImageConstPointer;
00089   typedef typename Superclass::FixedImageType             FixedImageType;
00090   typedef typename Superclass::FixedImageConstPointer     FixedImageConstPointer;
00091   typedef typename Superclass::TransformType              TransformType;
00092   typedef typename Superclass::TransformPointer           TransformPointer;
00093   typedef typename Superclass::InputPointType             InputPointType;
00094   typedef typename Superclass::OutputPointType            OutputPointType;
00095   typedef typename Superclass::TransformParametersType    TransformParametersType;
00096   typedef typename Superclass::TransformJacobianType      TransformJacobianType;
00097   typedef typename Superclass::InterpolatorType           InterpolatorType;
00098   typedef typename Superclass::InterpolatorPointer        InterpolatorPointer;
00099   typedef typename Superclass::RealType                   RealType;
00100   typedef typename Superclass::GradientPixelType          GradientPixelType;
00101   typedef typename Superclass::GradientImageType          GradientImageType;
00102   typedef typename Superclass::GradientImagePointer       GradientImagePointer;
00103   typedef typename Superclass::GradientImageFilterType    GradientImageFilterType;
00104   typedef typename Superclass::GradientImageFilterPointer GradientImageFilterPointer;
00105   typedef typename Superclass::FixedImageMaskType         FixedImageMaskType;
00106   typedef typename Superclass::FixedImageMaskPointer      FixedImageMaskPointer;
00107   typedef typename Superclass::MovingImageMaskType        MovingImageMaskType;
00108   typedef typename Superclass::MovingImageMaskPointer     MovingImageMaskPointer;
00109   typedef typename Superclass::MeasureType                MeasureType;
00110   typedef typename Superclass::DerivativeType             DerivativeType;
00111   typedef typename Superclass::ParametersType             ParametersType;
00112   typedef typename Superclass::FixedImagePixelType        FixedImagePixelType;
00113   typedef typename Superclass::MovingImageRegionType      MovingImageRegionType;
00114   typedef typename Superclass::ImageSamplerType           ImageSamplerType;
00115   typedef typename Superclass::ImageSamplerPointer        ImageSamplerPointer;
00116   typedef typename Superclass::ImageSampleContainerType   ImageSampleContainerType;
00117   typedef typename
00118     Superclass::ImageSampleContainerPointer               ImageSampleContainerPointer;
00119   typedef typename Superclass::FixedImageLimiterType      FixedImageLimiterType;
00120   typedef typename Superclass::MovingImageLimiterType     MovingImageLimiterType;
00121   typedef typename
00122     Superclass::FixedImageLimiterOutputType               FixedImageLimiterOutputType;
00123   typedef typename
00124     Superclass::MovingImageLimiterOutputType              MovingImageLimiterOutputType;
00125   typedef typename
00126     Superclass::MovingImageDerivativeScalesType           MovingImageDerivativeScalesType;
00127 
00129   itkStaticConstMacro( FixedImageDimension, unsigned int,
00130     FixedImageType::ImageDimension );
00131 
00133   itkStaticConstMacro( MovingImageDimension, unsigned int,
00134     MovingImageType::ImageDimension );
00135 
00137   virtual MeasureType GetValue( const TransformParametersType & parameters ) const;
00138 
00140   virtual void GetDerivative( const TransformParametersType & parameters,
00141     DerivativeType & derivative ) const;
00142 
00144   virtual void GetValueAndDerivative( const TransformParametersType & parameters,
00145     MeasureType& Value, DerivativeType& Derivative ) const;
00146 
00150   virtual void Initialize(void) throw ( ExceptionObject );
00151 
00152 protected:
00153   VarianceOverLastDimensionImageMetric();
00154   virtual ~VarianceOverLastDimensionImageMetric() {};
00155   void PrintSelf( std::ostream& os, Indent indent ) const;
00156 
00160   typedef typename Superclass::FixedImageIndexType                FixedImageIndexType;
00161   typedef typename Superclass::FixedImageIndexValueType           FixedImageIndexValueType;
00162   typedef typename Superclass::MovingImageIndexType               MovingImageIndexType;
00163   typedef typename Superclass::FixedImagePointType                FixedImagePointType;
00164   typedef typename itk::ContinuousIndex< CoordinateRepresentationType, FixedImageDimension >
00165                                                                   FixedImageContinuousIndexType;
00166   typedef typename Superclass::MovingImagePointType               MovingImagePointType;
00167   typedef typename Superclass::MovingImageContinuousIndexType     MovingImageContinuousIndexType;
00168   typedef typename Superclass::BSplineInterpolatorType            BSplineInterpolatorType;
00169   typedef typename Superclass::CentralDifferenceGradientFilterType CentralDifferenceGradientFilterType;
00170   typedef typename Superclass::MovingImageDerivativeType          MovingImageDerivativeType;
00171   typedef typename Superclass::NonZeroJacobianIndicesType         NonZeroJacobianIndicesType;
00172 
00176   void EvaluateTransformJacobianInnerProduct(
00177     const TransformJacobianType & jacobian,
00178     const MovingImageDerivativeType & movingImageDerivative,
00179     DerivativeType & imageJacobian) const;
00180 
00181 private:
00182   VarianceOverLastDimensionImageMetric(const Self&); //purposely not implemented
00183   void operator=(const Self&); //purposely not implemented
00184 
00186   void SampleRandom (const int n, const int m, std::vector<int> & numbers) const;
00187 
00189   bool m_SampleLastDimensionRandomly;
00190   unsigned int m_NumSamplesLastDimension;
00191   unsigned int m_NumAdditionalSamplesFixed;
00192   unsigned int m_ReducedDimensionIndex;
00193 
00195   bool m_SubtractMean;
00196 
00198   float m_InitialVariance;
00199 
00201   FixedImageSizeType m_GridSize;
00202 
00204   bool m_TransformIsStackTransform;
00205 
00206 }; // end class VarianceOverLastDimensionImageMetric
00207 
00208 } // end namespace itk
00209 
00210 #ifndef ITK_MANUAL_INSTANTIATION
00211 #include "itkVarianceOverLastDimensionImageMetric.hxx"
00212 #endif
00213 
00214 #endif // end #ifndef __itkVarianceOverLastDimensionImageMetric_h


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