ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkImageToImageMetricv4.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkImageToImageMetricv4_h
00019 #define __itkImageToImageMetricv4_h
00020 
00021 #include "itkCovariantVector.h"
00022 #include "itkImageFunction.h"
00023 #include "itkObjectToObjectMetric.h"
00024 #include "itkInterpolateImageFunction.h"
00025 #include "itkSpatialObject.h"
00026 #include "itkResampleImageFilter.h"
00027 #include "itkThreadedIndexedContainerPartitioner.h"
00028 #include "itkThreadedImageRegionPartitioner.h"
00029 #include "itkImageToImageFilter.h"
00030 #include "itkImageToImageMetricv4GetValueAndDerivativeThreader.h"
00031 #include "itkGradientRecursiveGaussianImageFilter.h"
00032 #include "itkPointSet.h"
00033 
00034 namespace itk
00035 {
00188 template<class TFixedImage,class TMovingImage,class TVirtualImage = TFixedImage>
00189 class ITK_EXPORT ImageToImageMetricv4 : public ObjectToObjectMetric
00190 {
00191 public:
00192 
00194   typedef ImageToImageMetricv4       Self;
00195   typedef ObjectToObjectMetric       Superclass;
00196   typedef SmartPointer<Self>         Pointer;
00197   typedef SmartPointer<const Self>   ConstPointer;
00198 
00200   itkTypeMacro(ImageToImageMetricv4, ObjectToObjectMetric);
00201 
00203   typedef typename Superclass::InternalComputationValueType
00204                                                   InternalComputationValueType;
00205 
00207   typedef typename Superclass::CoordinateRepresentationType
00208                                                   CoordinateRepresentationType;
00209 
00211   typedef typename Superclass::ParametersType       ParametersType;
00212   typedef typename Superclass::ParametersValueType  ParametersValueType;
00213 
00215   typedef typename Superclass::GradientSourceType GradientSourceType;
00216 
00218   typedef TFixedImage                             FixedImageType;
00219   typedef typename FixedImageType::PixelType      FixedImagePixelType;
00220   typedef typename FixedImageType::Pointer        FixedImagePointer;
00221   typedef typename FixedImageType::ConstPointer   FixedImageConstPointer;
00222   typedef typename FixedImageType::PointType      FixedImagePointType;
00223   typedef typename FixedImageType::IndexType      FixedImageIndexType;
00224   typedef TMovingImage                            MovingImageType;
00225   typedef typename MovingImageType::PixelType     MovingImagePixelType;
00226   typedef typename MovingImageType::Pointer       MovingImagePointer;
00227   typedef typename MovingImageType::ConstPointer  MovingImageConstPointer;
00228   typedef typename MovingImageType::PointType     MovingImagePointType;
00229   typedef typename MovingImageType::RegionType    MovingImageRegionType;
00230   typedef typename MovingImageType::IndexType     MovingImageIndexType;
00231 
00233   typedef TVirtualImage                             VirtualImageType;
00234   typedef typename VirtualImageType::PixelType      VirtualImagePixelType;
00235   typedef typename VirtualImageType::Pointer        VirtualImagePointer;
00236   typedef typename VirtualImageType::RegionType     VirtualRegionType;
00237   typedef typename VirtualRegionType::SizeType      VirtualSizeType;
00238   typedef typename VirtualImageType::SpacingType    VirtualSpacingType;
00239   typedef typename VirtualImageType::PointType      VirtualOriginType;
00240   typedef typename VirtualImageType::PointType      VirtualPointType;
00241   typedef typename VirtualImageType::DirectionType  VirtualDirectionType;
00242   typedef typename VirtualImageType::SizeType       VirtualRadiusType;
00243   typedef typename VirtualImageType::IndexType      VirtualIndexType;
00244 
00245   /* Image dimension accessors */
00246   typedef unsigned int   ImageDimensionType;
00247   itkStaticConstMacro(FixedImageDimension, ImageDimensionType,
00248       ::itk::GetImageDimension<FixedImageType>::ImageDimension);
00249   itkStaticConstMacro(MovingImageDimension, ImageDimensionType,
00250       ::itk::GetImageDimension<MovingImageType>::ImageDimension);
00251   itkStaticConstMacro(VirtualImageDimension, ImageDimensionType,
00252       ::itk::GetImageDimension<VirtualImageType>::ImageDimension);
00253 
00255   typedef Transform<CoordinateRepresentationType,
00256     itkGetStaticConstMacro( MovingImageDimension ),
00257     itkGetStaticConstMacro( VirtualImageDimension )> MovingTransformType;
00258 
00259   typedef Transform<CoordinateRepresentationType,
00260     itkGetStaticConstMacro( FixedImageDimension ),
00261     itkGetStaticConstMacro( VirtualImageDimension )> FixedTransformType;
00262 
00263   typedef typename FixedTransformType::Pointer         FixedTransformPointer;
00264   typedef typename FixedTransformType::InputPointType  FixedInputPointType;
00265   typedef typename FixedTransformType::OutputPointType FixedOutputPointType;
00266   typedef typename FixedTransformType::ParametersType
00267                                                 FixedTransformParametersType;
00268 
00269   typedef typename MovingTransformType::Pointer         MovingTransformPointer;
00270   typedef typename MovingTransformType::InputPointType  MovingInputPointType;
00271   typedef typename MovingTransformType::OutputPointType MovingOutputPointType;
00272   typedef typename MovingTransformType::ParametersType
00273                                                 MovingTransformParametersType;
00274 
00276   typedef typename FixedTransformType::JacobianType     JacobianType;
00277   typedef typename FixedTransformType::JacobianType     FixedTransformJacobianType;
00278   typedef typename MovingTransformType::JacobianType    MovingTransformJacobianType;
00279 
00282   typedef SpatialObject< itkGetStaticConstMacro(FixedImageDimension) >
00283                                                        FixedImageMaskType;
00284   typedef typename FixedImageMaskType::Pointer         FixedImageMaskPointer;
00285   typedef typename FixedImageMaskType::ConstPointer
00286                                                   FixedImageMaskConstPointer;
00287 
00290   typedef SpatialObject< itkGetStaticConstMacro(MovingImageDimension) >
00291                                                         MovingImageMaskType;
00292   typedef typename MovingImageMaskType::Pointer         MovingImageMaskPointer;
00293   typedef typename MovingImageMaskType::ConstPointer
00294                                                    MovingImageMaskConstPointer;
00295 
00297   typedef PointSet<typename FixedImageType::PixelType,
00298                    itkGetStaticConstMacro(FixedImageDimension)>
00299                                                      FixedSampledPointSetType;
00300   typedef typename FixedSampledPointSetType::Pointer FixedSampledPointSetPointer;
00301   typedef typename FixedSampledPointSetType::ConstPointer FixedSampledPointSetConstPointer;
00302 
00303   typedef PointSet<typename VirtualImageType::PixelType,
00304                    itkGetStaticConstMacro(VirtualImageDimension)>
00305                                                      VirtualSampledPointSetType;
00306 
00307   typedef typename VirtualSampledPointSetType::Pointer VirtualSampledPointSetPointer;
00308 
00310   typedef InterpolateImageFunction< FixedImageType,
00311                                     CoordinateRepresentationType >
00312                                                       FixedInterpolatorType;
00313   typedef InterpolateImageFunction< MovingImageType,
00314                                     CoordinateRepresentationType >
00315                                                       MovingInterpolatorType;
00316   typedef typename FixedInterpolatorType::Pointer     FixedInterpolatorPointer;
00317   typedef typename MovingInterpolatorType::Pointer    MovingInterpolatorPointer;
00318 
00320   typedef   CovariantVector< CoordinateRepresentationType,
00321                              itkGetStaticConstMacro(FixedImageDimension) >
00322                                                       FixedImageGradientType;
00323   typedef   CovariantVector< CoordinateRepresentationType,
00324                              itkGetStaticConstMacro(MovingImageDimension) >
00325                                                       MovingImageGradientType;
00327 
00328   typedef   CovariantVector< CoordinateRepresentationType,
00329                              itkGetStaticConstMacro(VirtualImageDimension) >
00330                                                       VirtualImageGradientType;
00331 
00335   typedef typename NumericTraits< FixedImagePixelType >::RealType
00336                                                     FixedRealType;
00337   typedef CovariantVector< FixedRealType,
00338                            itkGetStaticConstMacro(FixedImageDimension) >
00339                                                     FixedGradientPixelType;
00340   typedef Image< FixedGradientPixelType,
00341                  itkGetStaticConstMacro(FixedImageDimension) >
00342                                                 FixedImageGradientImageType;
00343   typedef typename FixedImageGradientImageType::Pointer
00344                                                 FixedImageGradientImagePointer;
00346 
00347   typedef ImageToImageFilter< FixedImageType, FixedImageGradientImageType >
00348                                                  FixedImageGradientFilterType;
00349 
00350   typedef typename NumericTraits< MovingImagePixelType >::RealType
00351                                                  MovingRealType;
00352   typedef CovariantVector< MovingRealType,
00353                            itkGetStaticConstMacro(MovingImageDimension) >
00354                                                  MovingGradientPixelType;
00355   typedef Image< MovingGradientPixelType,
00356                  itkGetStaticConstMacro(MovingImageDimension) >
00357                                                     MovingImageGradientImageType;
00358   typedef typename MovingImageGradientImageType::Pointer MovingImageGradientImagePointer;
00359 
00360   typedef ImageToImageFilter< MovingImageType, MovingImageGradientImageType >
00361                                                  MovingImageGradientFilterType;
00362   typedef typename FixedImageGradientFilterType::Pointer
00363                                               FixedImageGradientFilterPointer;
00364   typedef typename MovingImageGradientFilterType::Pointer
00365                                               MovingImageGradientFilterPointer;
00366 
00368   typedef GradientRecursiveGaussianImageFilter< FixedImageType,
00369                                                 FixedImageGradientImageType >
00370                                                   DefaultFixedImageGradientFilter;
00371   typedef GradientRecursiveGaussianImageFilter< MovingImageType,
00372                                                 MovingImageGradientImageType >
00373                                                   DefaultMovingImageGradientFilter;
00374 
00377   typedef ImageFunction<FixedImageType,
00378                         CovariantVector<double,
00379                                   itkGetStaticConstMacro( FixedImageDimension )>,
00380                         CoordinateRepresentationType>
00381                                             FixedImageGradientCalculatorType;
00382   typedef ImageFunction<MovingImageType,
00383                         CovariantVector<double,
00384                                   itkGetStaticConstMacro( MovingImageDimension )>,
00385                         CoordinateRepresentationType>
00386                                             MovingImageGradientCalculatorType;
00388 
00389   typedef typename FixedImageGradientCalculatorType::Pointer
00390                                             FixedImageGradientCalculatorPointer;
00391   typedef typename MovingImageGradientCalculatorType::Pointer
00392                                             MovingImageGradientCalculatorPointer;
00393 
00395   typedef ResampleImageFilter< MovingImageType,
00396                                VirtualImageType,
00397                                MovingRealType >
00398                                              MovingWarpResampleImageFilterType;
00399   typedef typename MovingWarpResampleImageFilterType::Pointer
00400                                           MovingWarpResampleImageFilterPointer;
00401   typedef ResampleImageFilter< FixedImageType,
00402                                VirtualImageType,
00403                                FixedRealType >
00404                                              FixedWarpResampleImageFilterType;
00405   typedef typename FixedWarpResampleImageFilterType::Pointer
00406                                           FixedWarpResampleImageFilterPointer;
00407 
00409   typedef typename Superclass::MeasureType    MeasureType;
00410 
00412   typedef typename Superclass::DerivativeType DerivativeType;
00413   typedef typename DerivativeType::ValueType  DerivativeValueType;
00414 
00417   typedef typename Superclass::NumberOfParametersType   NumberOfParametersType;
00418 
00419   /* Set/get images */
00421   itkSetConstObjectMacro(FixedImage, FixedImageType);
00422 
00424   itkGetConstObjectMacro(FixedImage, FixedImageType);
00425 
00427   itkSetConstObjectMacro(MovingImage, MovingImageType);
00428 
00430   itkGetConstObjectMacro(MovingImage, MovingImageType);
00431 
00447   void CreateVirtualDomainImage( VirtualSpacingType & spacing,
00448                                     VirtualOriginType & origin,
00449                                     VirtualDirectionType & direction,
00450                                     VirtualRegionType & region );
00451 
00457   void SetVirtualDomainImage( VirtualImageType * virtualImage);
00458 
00460   itkGetConstObjectMacro(VirtualDomainImage, VirtualImageType);
00461 
00464   const VirtualSpacingType    GetVirtualDomainSpacing( void ) const;
00465   const VirtualOriginType     GetVirtualDomainOrigin( void ) const;
00466   const VirtualDirectionType  GetVirtualDomainDirection( void ) const;
00467   const VirtualRegionType     GetVirtualDomainRegion( void ) const;
00469 
00471   itkSetObjectMacro(FixedTransform, FixedTransformType);
00472 
00474   itkGetConstObjectMacro(FixedTransform, FixedTransformType);
00475 
00477   itkSetObjectMacro(MovingTransform, MovingTransformType);
00478 
00480   itkGetConstObjectMacro(MovingTransform, MovingTransformType);
00481 
00484   void SetTransform( MovingTransformType* transform );
00485 
00487   const MovingTransformType * GetTransform();
00488 
00490   itkSetObjectMacro(FixedInterpolator, FixedInterpolatorType);
00491 
00493   itkGetConstObjectMacro(FixedInterpolator, FixedInterpolatorType);
00494 
00496   itkSetObjectMacro(MovingInterpolator, MovingInterpolatorType);
00497 
00499   itkGetConstObjectMacro(MovingInterpolator, MovingInterpolatorType);
00500 
00502   itkSetObjectMacro(MovingImageMask, MovingImageMaskType);
00503   itkSetConstObjectMacro(MovingImageMask, MovingImageMaskType);
00504   itkGetConstObjectMacro(MovingImageMask, MovingImageMaskType);
00506 
00508   itkSetObjectMacro(FixedImageMask, FixedImageMaskType);
00509   itkSetConstObjectMacro(FixedImageMask, FixedImageMaskType);
00510   itkGetConstObjectMacro(FixedImageMask, FixedImageMaskType);
00512 
00516   itkSetObjectMacro(FixedSampledPointSet, FixedSampledPointSetType);
00517   itkSetConstObjectMacro(FixedSampledPointSet, FixedSampledPointSetType);
00518   itkGetConstObjectMacro(FixedSampledPointSet, FixedSampledPointSetType);
00520 
00522   itkSetMacro(UseFixedSampledPointSet, bool);
00523   itkGetConstReferenceMacro(UseFixedSampledPointSet, bool);
00524   itkBooleanMacro(UseFixedSampledPointSet);
00526 
00528   itkGetConstObjectMacro(VirtualSampledPointSet, VirtualSampledPointSetType);
00529 
00531   itkSetObjectMacro( FixedImageGradientFilter, FixedImageGradientFilterType );
00532   itkGetObjectMacro( FixedImageGradientFilter, FixedImageGradientFilterType );
00533   itkSetObjectMacro( MovingImageGradientFilter, MovingImageGradientFilterType );
00534   itkGetObjectMacro( MovingImageGradientFilter, MovingImageGradientFilterType );
00536 
00538   itkSetObjectMacro( FixedImageGradientCalculator, FixedImageGradientCalculatorType);
00539   itkGetObjectMacro( FixedImageGradientCalculator, FixedImageGradientCalculatorType);
00540   itkSetObjectMacro( MovingImageGradientCalculator, MovingImageGradientCalculatorType);
00541   itkGetObjectMacro( MovingImageGradientCalculator, MovingImageGradientCalculatorType);
00543 
00546   itkSetMacro(UseFixedImageGradientFilter, bool);
00547   itkGetConstReferenceMacro(UseFixedImageGradientFilter, bool);
00548   itkBooleanMacro(UseFixedImageGradientFilter);
00550 
00552   itkSetMacro(UseMovingImageGradientFilter, bool);
00553   itkGetConstReferenceMacro(UseMovingImageGradientFilter, bool);
00554   itkBooleanMacro(UseMovingImageGradientFilter);
00556 
00558   itkSetMacro(DoFixedImagePreWarp, bool);
00559   itkGetConstReferenceMacro(DoFixedImagePreWarp, bool);
00560   itkBooleanMacro(DoFixedImagePreWarp);
00562 
00564   itkSetMacro(DoMovingImagePreWarp, bool);
00565   itkGetConstReferenceMacro(DoMovingImagePreWarp, bool);
00566   itkBooleanMacro(DoMovingImagePreWarp);
00568 
00570   itkGetConstObjectMacro( MovingWarpedImage, MovingImageType );
00571   itkGetConstObjectMacro( FixedWarpedImage, FixedImageType );
00573 
00576   ThreadIdType GetNumberOfThreadsUsed() const;
00577 
00581   void SetMaximumNumberOfThreads( const ThreadIdType threads );
00582   ThreadIdType GetMaximumNumberOfThreads() const;
00584 
00586   itkGetConstObjectMacro(FixedImageGradientImage, FixedImageGradientImageType);
00587 
00589   itkGetConstObjectMacro(MovingImageGradientImage, MovingImageGradientImageType);
00590 
00592   itkGetConstMacro( NumberOfValidPoints, SizeValueType );
00593 
00598   SizeValueType GetNumberOfDomainPoints() const;
00599 
00604   itkSetMacro( FloatingPointCorrectionResolution, DerivativeValueType );
00605   itkGetConstMacro( FloatingPointCorrectionResolution, DerivativeValueType );
00607 
00615   virtual NumberOfParametersType GetNumberOfParameters() const;
00616 
00618   virtual void SetParameters( ParametersType & params );
00619 
00621   virtual const ParametersType & GetParameters() const;
00622 
00629   virtual void UpdateTransformParameters( DerivativeType & derivative,
00630                                           ParametersValueType factor = NumericTraits< ParametersValueType >::One );
00631 
00633   virtual NumberOfParametersType GetNumberOfLocalParameters() const;
00634 
00636   virtual bool HasLocalSupport() const;
00637 
00638   /* Initialize the metric before calling GetValue or GetDerivative.
00639    * Derived classes must call this Superclass version if they override
00640    * this to perform their own initialization.
00641    * \note This is meant to be called once for a particular metric setup.
00642    * That is, when used in registration, this method would be called once
00643    * before entering the registration loop, during which GetValue or
00644    * GetDerivative will be called repeatedly. It must be called again if
00645    * metric settings are changed before beginning a new registration. */
00646   virtual void Initialize(void) throw ( itk::ExceptionObject );
00647 
00648   /* Computes an offset for accessing parameter data from a virtual domain
00649    * index. Relevant for metrics with local-support transforms, to access
00650    * parameter or derivative memory that is stored linearly in a 1D array.
00651    * The result is the offset (1D array index) to the first of N parameters
00652    * corresponding to the given virtual index, where N is the number of
00653    * local parameters. */
00654   OffsetValueType ComputeParameterOffsetFromVirtualDomainIndex( const VirtualIndexType & index, const NumberOfParametersType numberOfLocalParameters ) const;
00655 
00658   virtual MeasureType GetValue() const;
00659 
00665   virtual void GetValueAndDerivative( MeasureType & value,
00666                                       DerivativeType & derivative ) const;
00667 
00671   itkGetConstReferenceMacro(NumberOfSkippedFixedSampledPoints, SizeValueType);
00672 
00678   MeasureType GetCurrentValue();
00679 
00680 protected:
00681   /* Interpolators for image gradient filters. */
00682   typedef LinearInterpolateImageFunction< FixedImageGradientImageType,
00683                                           CoordinateRepresentationType >
00684                                                   FixedImageGradientInterpolatorType;
00685   typedef LinearInterpolateImageFunction< MovingImageGradientImageType,
00686                                           CoordinateRepresentationType >
00687                                                   MovingImageGradientInterpolatorType;
00688 
00689   friend class ImageToImageMetricv4GetValueAndDerivativeThreaderBase< ThreadedImageRegionPartitioner< VirtualImageDimension >, Self >;
00690   friend class ImageToImageMetricv4GetValueAndDerivativeThreaderBase< ThreadedIndexedContainerPartitioner, Self >;
00691   friend class ImageToImageMetricv4GetValueAndDerivativeThreader< ThreadedImageRegionPartitioner< VirtualImageDimension >, Self >;
00692   friend class ImageToImageMetricv4GetValueAndDerivativeThreader< ThreadedIndexedContainerPartitioner, Self >;
00693 
00694   /* A DenseGetValueAndDerivativeThreader
00695    * Derived classes must define this class and assign it in their constructor
00696    * if threaded processing in GetValueAndDerivative is performed. */
00697   typename ImageToImageMetricv4GetValueAndDerivativeThreader< ThreadedImageRegionPartitioner< VirtualImageDimension >, Self >::Pointer m_DenseGetValueAndDerivativeThreader;
00698   /* A SparseGetValueAndDerivativeThreader
00699    * Derived classes must define this class and assign it in their constructor
00700    * if threaded processing in GetValueAndDerivative is performed. */
00701   typename ImageToImageMetricv4GetValueAndDerivativeThreader< ThreadedIndexedContainerPartitioner, Self >::Pointer m_SparseGetValueAndDerivativeThreader;
00702 
00707   virtual void InitializeForIteration() const;
00708 
00721   bool TransformAndEvaluateFixedPoint(
00722                            const VirtualIndexType & index,
00723                            const VirtualPointType & point,
00724                            const bool computeImageGradient,
00725                            FixedImagePointType & mappedFixedPoint,
00726                            FixedImagePixelType & mappedFixedPixelValue,
00727                            FixedImageGradientType & mappedFixedImageGradient ) const;
00728 
00730   bool TransformAndEvaluateMovingPoint(
00731                            const VirtualIndexType & index,
00732                            const VirtualPointType & point,
00733                            const bool computeImageGradient,
00734                            MovingImagePointType & mappedMovingPoint,
00735                            MovingImagePixelType & mappedMovingPixelValue,
00736                            MovingImageGradientType & mappedMovingImageGradient ) const;
00737 
00742   virtual void ComputeFixedImageGradientAtPoint(
00743                                     const FixedImagePointType & mappedPoint,
00744                                     FixedImageGradientType & gradient ) const;
00745 
00747   virtual void ComputeMovingImageGradientAtPoint(
00748                                     const MovingImagePointType & mappedPoint,
00749                                     MovingImageGradientType & gradient ) const;
00750 
00756   virtual void ComputeFixedImageGradientAtIndex(
00757                                     const VirtualIndexType & index,
00758                                     FixedImageGradientType & gradient ) const;
00759 
00761   virtual void ComputeMovingImageGradientAtIndex(
00762                                     const VirtualIndexType & index,
00763                                     MovingImageGradientType & gradient ) const;
00764 
00770   virtual void ComputeFixedImageGradientFilterImage();
00771 
00777   virtual void ComputeMovingImageGradientFilterImage() const;
00778 
00785   virtual void GetValueAndDerivativeExecute() const;
00786 
00789   virtual void InitializeDefaultFixedImageGradientFilter(void);
00790   virtual void InitializeDefaultMovingImageGradientFilter(void);
00792 
00793   FixedImageConstPointer  m_FixedImage;
00794   FixedTransformPointer   m_FixedTransform;
00795   MovingImageConstPointer m_MovingImage;
00796   MovingTransformPointer  m_MovingTransform;
00797   VirtualImagePointer     m_VirtualDomainImage;
00798 
00800   FixedInterpolatorPointer                                m_FixedInterpolator;
00801   MovingInterpolatorPointer                               m_MovingInterpolator;
00802   typename FixedImageGradientInterpolatorType::Pointer    m_FixedImageGradientInterpolator;
00803   typename MovingImageGradientInterpolatorType::Pointer   m_MovingImageGradientInterpolator;
00804 
00807   bool                          m_UseFixedImageGradientFilter;
00808   bool                          m_UseMovingImageGradientFilter;
00809 
00811   FixedImageGradientFilterPointer   m_FixedImageGradientFilter;
00812   MovingImageGradientFilterPointer  m_MovingImageGradientFilter;
00813 
00816   typename DefaultFixedImageGradientFilter::Pointer
00817                                              m_DefaultFixedImageGradientFilter;
00818   typename DefaultMovingImageGradientFilter::Pointer
00819                                              m_DefaultMovingImageGradientFilter;
00820 
00822   mutable FixedImageGradientImagePointer    m_FixedImageGradientImage;
00823   mutable MovingImageGradientImagePointer   m_MovingImageGradientImage;
00824 
00826   FixedImageGradientCalculatorPointer   m_FixedImageGradientCalculator;
00827   MovingImageGradientCalculatorPointer  m_MovingImageGradientCalculator;
00828 
00830   bool                               m_DoFixedImagePreWarp;
00831 
00833   bool                               m_DoMovingImagePreWarp;
00834 
00836   mutable FixedImagePointer   m_FixedWarpedImage;
00837   mutable MovingImagePointer  m_MovingWarpedImage;
00838 
00840   MovingWarpResampleImageFilterPointer    m_MovingWarpResampleImageFilter;
00841   FixedWarpResampleImageFilterPointer     m_FixedWarpResampleImageFilter;
00842 
00847   mutable DerivativeType *                m_DerivativeResult;
00848 
00851   mutable SizeValueType                   m_NumberOfValidPoints;
00852 
00855   bool                                    m_UserHasProvidedVirtualDomainImage;
00856 
00858   FixedImageMaskConstPointer              m_FixedImageMask;
00859   MovingImageMaskConstPointer             m_MovingImageMask;
00860 
00862   FixedSampledPointSetConstPointer        m_FixedSampledPointSet;
00863   VirtualSampledPointSetPointer           m_VirtualSampledPointSet;
00864 
00866   bool                                    m_UseFixedSampledPointSet;
00867 
00869   mutable MeasureType                     m_Value;
00870 
00871   ImageToImageMetricv4();
00872   virtual ~ImageToImageMetricv4();
00873 
00874   void PrintSelf(std::ostream& os, Indent indent) const;
00875 
00878   virtual void VerifyDisplacementFieldSizeAndPhysicalSpace();
00879 
00886   bool VerifyNumberOfValidPoints( MeasureType & value, DerivativeType & derivative ) const;
00887 
00888 private:
00890   void MapFixedSampledPointSetToVirtual( void );
00891 
00894   void DoFixedImagePreWarp( void ) const;
00895   void DoMovingImagePreWarp( void ) const;
00897 
00900   mutable bool m_HaveMadeGetValueWarning;
00901 
00902   ImageToImageMetricv4(const Self &); //purposely not implemented
00903   void operator=(const Self &); //purposely not implemented
00904 
00905   //Sample point coordinates from the virtual image domain
00906   std::vector<VirtualPointType> m_VirtualImageCornerPoints;
00907 
00908   /* Keep track of the number of sampled fixed points that are
00909    * deemed invalid during conversion to virtual domain.
00910    * For informational purposes. */
00911   SizeValueType m_NumberOfSkippedFixedSampledPoints;
00912 
00913   DerivativeValueType m_FloatingPointCorrectionResolution;
00914 
00918   #ifdef ITK_USE_CONCEPT_CHECKING
00919   typedef typename PixelTraits<FixedImagePixelType>::ValueType  FixedImagePixelValueType;
00920   typedef typename PixelTraits<MovingImagePixelType>::ValueType MovingImagePixelValueType;
00921   itkConceptMacro( OnlyDefinedForFloatingPointTypes0, ( itk::Concept::IsFloatingPoint<FixedImagePixelValueType> ) );
00922   itkConceptMacro( OnlyDefinedForFloatingPointTypes1, ( itk::Concept::IsFloatingPoint<MovingImagePixelValueType> ) );
00923   #endif // ITK_USE_CONCEPT_CHECKING
00924 
00925 
00926 };
00927 }//namespace itk
00928 
00929 #ifndef ITK_MANUAL_INSTANTIATION
00930 #include "itkImageToImageMetricv4.hxx"
00931 #endif
00932 
00933 #endif
00934