go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkGradientDifferenceImageToImageMetric2.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   Program:   Insight Segmentation & Registration Toolkit
00017   Module:    $RCSfile: itkGradientDifferenceImageToImageMetric2.h,v $
00018   Language:  C++
00019   Date:      $Date: 2011-29-04 14:33 $
00020   Version:   $Revision: 2.0 $
00021 
00022   Copyright (c) Insight Software Consortium. All rights reserved.
00023   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00024 
00025      This software is distributed WITHOUT ANY WARRANTY; without even
00026      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00027      PURPOSE.  See the above copyright notices for more information.
00028 
00029 =========================================================================*/
00030 #ifndef __itkGradientDifferenceImageToImageMetric2_h
00031 #define __itkGradientDifferenceImageToImageMetric2_h
00032 
00033 #include "itkAdvancedImageToImageMetric.h"
00034 
00035 #include "itkSobelOperator.h"
00036 #include "itkNeighborhoodOperatorImageFilter.h"
00037 #include "itkPoint.h"
00038 #include "itkCastImageFilter.h"
00039 #include "itkResampleImageFilter.h"
00040 #include "itkOptimizer.h"
00041 #include "itkAdvancedCombinationTransform.h"
00042 #include "itkAdvancedRayCastInterpolateImageFunction.h"
00043 
00044 namespace itk
00045 {
00070 template < class TFixedImage, class TMovingImage >
00071 class ITK_EXPORT GradientDifferenceImageToImageMetric :
00072 public AdvancedImageToImageMetric< TFixedImage, TMovingImage>
00073 {
00074 public:
00075 
00077   typedef GradientDifferenceImageToImageMetric                    Self;
00078   typedef AdvancedImageToImageMetric<TFixedImage, TMovingImage >  Superclass;
00079 
00080   typedef SmartPointer<Self>         Pointer;
00081   typedef SmartPointer<const Self>   ConstPointer;
00082 
00084   itkNewMacro(Self);
00085 
00087   itkTypeMacro(GradientDifferenceImageToImageMetric, ImageToImageMetric);
00088 
00091   #if defined(_MSC_VER) && (_MSC_VER == 1300)
00092     typedef double RealType;
00093   #else
00094     typedef typename Superclass::RealType               RealType;
00095   #endif
00096   
00097   typedef typename Superclass::TransformType            TransformType;
00098   typedef typename TransformType::ScalarType            ScalarType;
00099   typedef typename Superclass::TransformPointer         TransformPointer;
00100   typedef typename Superclass::TransformParametersType  TransformParametersType;
00101   typedef typename Superclass::TransformJacobianType    TransformJacobianType;
00102   typedef typename Superclass::InterpolatorType         InterpolatorType;
00103   typedef typename InterpolatorType::Pointer            InterpolatorPointer;
00104   typedef typename Superclass::MeasureType              MeasureType;
00105   typedef typename Superclass::DerivativeType           DerivativeType;
00106   typedef typename Superclass::FixedImageType           FixedImageType;
00107   typedef typename Superclass::MovingImageType          MovingImageType;
00108   typedef typename Superclass::FixedImageConstPointer   FixedImageConstPointer;
00109   typedef typename Superclass::MovingImageConstPointer  MovingImageConstPointer;
00110   typedef typename TFixedImage::PixelType               FixedImagePixelType;
00111   typedef typename TMovingImage::PixelType              MovedImagePixelType;
00112   typedef typename MovingImageType::RegionType          MovingImageRegionType;
00113   typedef typename itk::Optimizer                       OptimizerType;
00114   typedef typename OptimizerType::ScalesType            ScalesType;
00115   
00116   itkStaticConstMacro( FixedImageDimension, unsigned int,
00117     FixedImageType::ImageDimension );
00118   itkStaticConstMacro( MovedImageDimension, unsigned int,
00119     MovingImageType::ImageDimension );
00120 
00121   typedef typename itk::AdvancedCombinationTransform< ScalarType, FixedImageDimension>
00122     CombinationTransformType;
00123   typedef typename CombinationTransformType::Pointer    CombinationTransformPointer;
00124   typedef itk::Image< FixedImagePixelType, itkGetStaticConstMacro( FixedImageDimension ) >
00125     TransformedMovingImageType;
00126   typedef itk::ResampleImageFilter< MovingImageType, TransformedMovingImageType >
00127     TransformMovingImageFilterType;
00128   typedef typename itk::AdvancedRayCastInterpolateImageFunction< 
00129     MovingImageType, ScalarType >             RayCastInterpolatorType;
00130   typedef typename RayCastInterpolatorType::Pointer   RayCastInterpolatorPointer;
00131   typedef itk::Image< RealType, itkGetStaticConstMacro( FixedImageDimension ) >
00132     FixedGradientImageType;
00133   typedef itk::CastImageFilter< FixedImageType, FixedGradientImageType >
00134     CastFixedImageFilterType;
00135   typedef typename CastFixedImageFilterType::Pointer CastFixedImageFilterPointer;
00136   typedef typename FixedGradientImageType::PixelType FixedGradientPixelType;
00137   typedef itk::Image< RealType, itkGetStaticConstMacro( MovedImageDimension ) >
00138     MovedGradientImageType;
00139   typedef itk::CastImageFilter< TransformedMovingImageType, MovedGradientImageType >
00140     CastMovedImageFilterType;
00141   typedef typename CastMovedImageFilterType::Pointer CastMovedImageFilterPointer;
00142   typedef typename MovedGradientImageType::PixelType MovedGradientPixelType;
00143 
00145   void GetDerivative( const TransformParametersType & parameters,
00146       DerivativeType  & derivative ) const;
00147 
00149   MeasureType GetValue( const TransformParametersType & parameters ) const;
00150 
00152   void GetValueAndDerivative( const TransformParametersType & parameters,
00153     MeasureType& Value, DerivativeType& derivative ) const;
00154 
00155   virtual void Initialize(void) throw ( ExceptionObject );
00156 
00158     void WriteGradientImagesToFiles(void) const;
00159 
00161   itkSetMacro( Scales , ScalesType );
00162   itkGetConstReferenceMacro( Scales, ScalesType );
00163 
00166   itkSetMacro( DerivativeDelta, double );
00167   itkGetConstReferenceMacro( DerivativeDelta, double );
00168 
00169 protected:
00170   GradientDifferenceImageToImageMetric();
00171   virtual ~GradientDifferenceImageToImageMetric() {};
00172   void PrintSelf(std::ostream& os, Indent indent) const;
00173 
00175   void ComputeMovedGradientRange( void ) const;
00176 
00178   void ComputeVariance( void ) const;
00179 
00181   MeasureType ComputeMeasure( const TransformParametersType &parameters,
00182     const double *subtractionFactor ) const;
00183 
00184   typedef NeighborhoodOperatorImageFilter<
00185     FixedGradientImageType, FixedGradientImageType > FixedSobelFilter;
00186 
00187   typedef NeighborhoodOperatorImageFilter<
00188     MovedGradientImageType, MovedGradientImageType > MovedSobelFilter;
00189 
00190 private:
00191   GradientDifferenceImageToImageMetric(const Self&); //purposely not implemented
00192   void operator=(const Self&); //purposely not implemented
00193 
00195   mutable MovedGradientPixelType m_Variance[FixedImageDimension];
00196 
00198   mutable MovedGradientPixelType m_MinMovedGradient[MovedImageDimension];
00199   mutable MovedGradientPixelType m_MaxMovedGradient[MovedImageDimension];
00200   
00202   mutable FixedGradientPixelType m_MinFixedGradient[FixedImageDimension];
00203   mutable FixedGradientPixelType m_MaxFixedGradient[FixedImageDimension];
00204 
00206   typename TransformMovingImageFilterType::Pointer m_TransformMovingImageFilter;
00207 
00209   CastFixedImageFilterPointer m_CastFixedImageFilter;
00210 
00211   SobelOperator< FixedGradientPixelType,
00212     itkGetStaticConstMacro(FixedImageDimension) >
00213     m_FixedSobelOperators[FixedImageDimension];
00214 
00215   typename FixedSobelFilter::Pointer m_FixedSobelFilters[itkGetStaticConstMacro
00216     ( FixedImageDimension )];
00217 
00218   ZeroFluxNeumannBoundaryCondition< MovedGradientImageType > m_MovedBoundCond;
00219   ZeroFluxNeumannBoundaryCondition< FixedGradientImageType > m_FixedBoundCond;
00220 
00222   CastMovedImageFilterPointer m_CastMovedImageFilter;
00223 
00224   SobelOperator< MovedGradientPixelType,
00225     itkGetStaticConstMacro(MovedImageDimension) >
00226     m_MovedSobelOperators[MovedImageDimension];
00227 
00228   typename MovedSobelFilter::Pointer m_MovedSobelFilters[itkGetStaticConstMacro
00229     ( MovedImageDimension )];
00230 
00231   ScalesType                    m_Scales;
00232   double                        m_DerivativeDelta;
00233   double                        m_Rescalingfactor;
00234   CombinationTransformPointer   m_CombinationTransform;
00235 
00236   };
00237 
00238 
00239 } // end namespace itk
00240 
00241 
00242 #ifndef ITK_MANUAL_INSTANTIATION
00243 #include "itkGradientDifferenceImageToImageMetric2.hxx"
00244 #endif
00245 
00246 
00247 #endif


Generated on 24-10-2011 for elastix by doxygen 1.7.4 elastix logo