go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkCombinationImageToImageMetric.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 #ifndef __itkCombinationImageToImageMetric_h
00016 #define __itkCombinationImageToImageMetric_h
00017 
00018 #include "itkAdvancedImageToImageMetric.h"
00019 #include "itkSingleValuedPointSetToPointSetMetric.h"
00020 
00021 namespace itk
00022 {
00023 
00055 template <class TFixedImage, class TMovingImage>
00056 class CombinationImageToImageMetric :
00057   public AdvancedImageToImageMetric< TFixedImage, TMovingImage >
00058 {
00059 public:
00061   typedef CombinationImageToImageMetric   Self;
00062   typedef AdvancedImageToImageMetric<
00063     TFixedImage, TMovingImage >           Superclass;
00064   typedef SmartPointer<Self>              Pointer;
00065   typedef SmartPointer<const Self>        ConstPointer;
00066 
00068   itkTypeMacro( CombinationImageToImageMetric, AdvancedImageToImageMetric );
00069 
00071   itkNewMacro( Self );
00072 
00074   itkStaticConstMacro( MovingImageDimension, unsigned int,
00075     TMovingImage::ImageDimension );
00076   itkStaticConstMacro( FixedImageDimension, unsigned int,
00077     TFixedImage::ImageDimension );
00078 
00080   typedef typename Superclass::CoordinateRepresentationType CoordinateRepresentationType;
00081   typedef typename Superclass::MovingImageType            MovingImageType;
00082   typedef typename Superclass::MovingImagePixelType       MovingImagePixelType;
00083   //typedef typename Superclass::MovingImagePointer         MovingImagePointer;
00084   typedef typename Superclass::MovingImageConstPointer    MovingImageConstPointer;
00085   typedef typename Superclass::FixedImageType             FixedImageType;
00086   //typedef typename Superclass::FixedImagePointer          FixedImagePointer;
00087   typedef typename Superclass::FixedImageConstPointer     FixedImageConstPointer;
00088   typedef typename Superclass::FixedImageRegionType       FixedImageRegionType;
00089   typedef typename Superclass::AdvancedTransformType      TransformType;
00090   typedef typename TransformType::Pointer                 TransformPointer;
00091   typedef typename Superclass::InputPointType             InputPointType;
00092   typedef typename Superclass::OutputPointType            OutputPointType;
00093   typedef typename Superclass::TransformParametersType    TransformParametersType;
00094   typedef typename Superclass::TransformJacobianType      TransformJacobianType;
00095   typedef typename Superclass::InterpolatorType           InterpolatorType;
00096   typedef typename Superclass::InterpolatorPointer        InterpolatorPointer;
00097   typedef typename Superclass::RealType                   RealType;
00098   typedef typename Superclass::GradientPixelType          GradientPixelType;
00099   typedef typename Superclass::GradientImageType          GradientImageType;
00100   typedef typename Superclass::GradientImagePointer       GradientImagePointer;
00101   typedef typename Superclass::GradientImageFilterType    GradientImageFilterType;
00102   typedef typename Superclass::GradientImageFilterPointer GradientImageFilterPointer;
00103   typedef typename Superclass::FixedImageMaskType         FixedImageMaskType;
00104   typedef typename Superclass::FixedImageMaskPointer      FixedImageMaskPointer;
00105   typedef typename Superclass::MovingImageMaskType        MovingImageMaskType;
00106   typedef typename Superclass::MovingImageMaskPointer     MovingImageMaskPointer;
00107   typedef typename Superclass::MeasureType                MeasureType;
00108   typedef typename Superclass::DerivativeType             DerivativeType;
00109   //typedef typename Superclass::DerivativeValueType        DerivativeValueType;
00110   typedef typename Superclass::ParametersType             ParametersType;
00111 
00113   typedef typename Superclass::HessianValueType           HessianValueType;
00114   typedef typename Superclass::HessianType                HessianType;
00115 
00130   typedef Superclass                                      ImageMetricType;
00131   typedef typename ImageMetricType::Pointer               ImageMetricPointer;
00132   typedef SingleValuedCostFunction                        SingleValuedCostFunctionType;
00133   typedef typename SingleValuedCostFunctionType::Pointer  SingleValuedCostFunctionPointer;
00134 
00135   typedef typename FixedImageType::PixelType              FixedImagePixelType;
00136   typedef typename MovingImageType::RegionType            MovingImageRegionType;
00137   typedef FixedArray< double,
00138     itkGetStaticConstMacro(MovingImageDimension) >        MovingImageDerivativeScalesType;
00139 
00141   typedef PointSet< CoordinateRepresentationType,
00142     TFixedImage::ImageDimension,
00143     DefaultStaticMeshTraits<
00144       CoordinateRepresentationType,
00145       TFixedImage::ImageDimension,
00146       TFixedImage::ImageDimension,
00147       CoordinateRepresentationType, CoordinateRepresentationType,
00148       CoordinateRepresentationType > >                    FixedPointSetType;
00149   typedef PointSet< CoordinateRepresentationType,
00150     TMovingImage::ImageDimension,
00151     DefaultStaticMeshTraits<
00152       CoordinateRepresentationType,
00153       TMovingImage::ImageDimension,
00154       TMovingImage::ImageDimension,
00155       CoordinateRepresentationType, CoordinateRepresentationType,
00156       CoordinateRepresentationType > >                    MovingPointSetType;
00157   typedef SingleValuedPointSetToPointSetMetric<
00158     FixedPointSetType, MovingPointSetType >               PointSetMetricType;
00159 
00165   void SetNumberOfMetrics( unsigned int count );
00166 
00168   itkGetConstMacro( NumberOfMetrics, unsigned int );
00169 
00174   void SetMetric( SingleValuedCostFunctionType * metric, unsigned int pos );
00175 
00177   SingleValuedCostFunctionType * GetMetric( unsigned int count ) const;
00178 
00180   void SetMetricWeight( double weight, unsigned int pos );
00181 
00183   double GetMetricWeight( unsigned int pos ) const;
00184 
00186   void SetMetricRelativeWeight( double weight, unsigned int pos );
00187 
00189   double GetMetricRelativeWeight( unsigned int pos ) const;
00190 
00192   itkSetMacro( UseRelativeWeights, bool );
00193   itkGetMacro( UseRelativeWeights, bool );
00194 
00200   void SetUseMetric( const bool use, const unsigned int pos );
00201 
00203   void SetUseAllMetrics( void );
00204 
00206   bool GetUseMetric( const unsigned int pos ) const;
00207 
00209   MeasureType GetMetricValue( unsigned int pos ) const;
00210 
00212   const DerivativeType & GetMetricDerivative( unsigned int pos ) const;
00213 
00215   double GetMetricDerivativeMagnitude( unsigned int pos ) const;
00216 
00218   std::size_t GetMetricComputationTime( unsigned int pos ) const;
00219 
00225   virtual void SetTransform( TransformType * _arg );
00226 
00237   virtual void SetTransform( TransformType * _arg, unsigned int pos );
00238 
00242   virtual const TransformType * GetTransform( unsigned int pos ) const;
00243 
00245   virtual const TransformType * GetTransform( void ) const
00246   {
00247     return this->GetTransform( 0 );
00248   };
00249 
00251   virtual void SetInterpolator( InterpolatorType *_arg );
00252 
00254   virtual void SetInterpolator( InterpolatorType * _arg, unsigned int pos );
00255 
00259   virtual const InterpolatorType * GetInterpolator( unsigned int pos ) const;
00260 
00262   virtual const InterpolatorType * GetInterpolator( void ) const
00263   {
00264     return this->GetInterpolator(0);
00265   };
00266 
00268   virtual void SetFixedImage( const FixedImageType *_arg );
00269 
00271   virtual void SetFixedImage( const FixedImageType *_arg, unsigned int pos );
00272 
00276   virtual const FixedImageType * GetFixedImage( unsigned int pos ) const;
00277 
00279   virtual const FixedImageType * GetFixedImage( void ) const
00280   {
00281     return this->GetFixedImage(0);
00282   };
00283 
00285   virtual void SetFixedImageMask( FixedImageMaskType *_arg );
00286 
00288   virtual void SetFixedImageMask( FixedImageMaskType *_arg, unsigned int pos );
00289 
00293   virtual const FixedImageMaskType * GetFixedImageMask( unsigned int pos ) const;
00294 
00296   virtual const FixedImageMaskType * GetFixedImageMask( void ) const
00297   {
00298     return this->GetFixedImageMask(0);
00299   };
00300 
00302   virtual void SetFixedImageRegion( const FixedImageRegionType _arg );
00303 
00305   virtual void SetFixedImageRegion( const FixedImageRegionType _arg, unsigned int pos );
00306 
00310   virtual const FixedImageRegionType & GetFixedImageRegion( unsigned int pos ) const;
00311 
00313   virtual const FixedImageRegionType & GetFixedImageRegion( void ) const
00314   {
00315     return this->GetFixedImageRegion(0);
00316   };
00317 
00319   virtual void SetMovingImage( const MovingImageType *_arg );
00320 
00322   virtual void SetMovingImage( const MovingImageType *_arg, unsigned int pos );
00323 
00327   virtual const MovingImageType * GetMovingImage( unsigned int pos ) const;
00328 
00330   virtual const MovingImageType * GetMovingImage( void ) const
00331   {
00332     return this->GetMovingImage(0);
00333   };
00334 
00336   virtual void SetMovingImageMask( MovingImageMaskType *_arg );
00337 
00339   virtual void SetMovingImageMask( MovingImageMaskType *_arg, unsigned int pos );
00340 
00344   virtual const MovingImageMaskType * GetMovingImageMask( unsigned int pos ) const;
00345 
00347   virtual const MovingImageMaskType * GetMovingImageMask( void ) const
00348   {
00349     return this->GetMovingImageMask(0);
00350   };
00351 
00355   virtual const unsigned long & GetNumberOfPixelsCounted( void ) const;
00356 
00358   virtual void Initialize( void ) throw ( ExceptionObject );
00359 
00365   virtual MeasureType GetValue( const ParametersType & parameters ) const;
00366 
00368   virtual void GetDerivative(
00369     const ParametersType & parameters,
00370     DerivativeType & derivative ) const;
00371 
00373   virtual void GetValueAndDerivative(
00374     const ParametersType & parameters,
00375     MeasureType & value,
00376     DerivativeType & derivative ) const;
00377 
00379   virtual void GetSelfHessian(
00380     const TransformParametersType & parameters,
00381     HessianType & H ) const;
00382 
00386   virtual unsigned long GetMTime() const;
00387 
00388 protected:
00389   CombinationImageToImageMetric();
00390   virtual ~CombinationImageToImageMetric() {};
00391   void PrintSelf( std::ostream& os, Indent indent ) const;
00392 
00394   unsigned int                                      m_NumberOfMetrics;
00395   std::vector< SingleValuedCostFunctionPointer >    m_Metrics;
00396   std::vector< double >                             m_MetricWeights;
00397   std::vector< double >                             m_MetricRelativeWeights;
00398   bool                                              m_UseRelativeWeights;
00399   std::vector< bool >                               m_UseMetric;
00400   mutable std::vector< MeasureType >                m_MetricValues;
00401   mutable std::vector< DerivativeType >             m_MetricDerivatives;
00402   mutable std::vector< double >                     m_MetricDerivativesMagnitude;
00403   mutable std::vector< std::size_t >                m_MetricComputationTime;
00404 
00406   FixedImageRegionType        m_NullFixedImageRegion;
00407   DerivativeType              m_NullDerivative;
00408 
00409 private:
00410   CombinationImageToImageMetric(const Self&); //purposely not implemented
00411   void operator=(const Self&); //purposely not implemented
00412 
00413 }; // end class CombinationImageToImageMetric
00414 
00415 } // end namespace itk
00416 
00417 #ifndef ITK_MANUAL_INSTANTIATION
00418 #include "itkCombinationImageToImageMetric.txx"
00419 #endif
00420 
00421 #endif // end #ifndef __itkCombinationImageToImageMetric_h
00422 
00423 
00424 


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