Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef __itkMultiInputImageToImageMetricBase_h
00015 #define __itkMultiInputImageToImageMetricBase_h
00016
00017 #include "itkAdvancedImageToImageMetric.h"
00018 #include <vector>
00019
00021 #define itkSetNumberOfMacro( name ) \
00022 virtual void SetNumberOf##name##s( const unsigned int _arg ) \
00023 { \
00024 if ( this->m_NumberOf##name##s != _arg ) \
00025 { \
00026 this->m_##name##Vector.resize( _arg ); \
00027 this->m_NumberOf##name##s = _arg; \
00028 this->Modified(); \
00029 } \
00030 } // comments for allowing ; after calling the macro
00031
00032
00033 namespace itk
00034 {
00035
00045 template <class TFixedImage, class TMovingImage>
00046 class MultiInputImageToImageMetricBase :
00047 public AdvancedImageToImageMetric< TFixedImage, TMovingImage >
00048 {
00049 public:
00050
00052 typedef MultiInputImageToImageMetricBase Self;
00053 typedef AdvancedImageToImageMetric<
00054 TFixedImage, TMovingImage > Superclass;
00055 typedef SmartPointer<Self> Pointer;
00056 typedef SmartPointer<const Self> ConstPointer;
00057
00059 itkTypeMacro( MultiInputImageToImageMetricBase, AdvancedImageToImageMetric );
00060
00062 itkStaticConstMacro( MovingImageDimension, unsigned int,
00063 TMovingImage::ImageDimension );
00064 itkStaticConstMacro( FixedImageDimension, unsigned int,
00065 TFixedImage::ImageDimension );
00066
00068 typedef typename Superclass::CoordinateRepresentationType CoordinateRepresentationType;
00069 typedef typename Superclass::MovingImageType MovingImageType;
00070 typedef typename Superclass::MovingImagePixelType MovingImagePixelType;
00071 typedef typename Superclass::MovingImagePointer MovingImagePointer;
00072 typedef typename Superclass::MovingImageConstPointer MovingImageConstPointer;
00073 typedef typename Superclass::FixedImageType FixedImageType;
00074 typedef typename Superclass::FixedImagePointer FixedImagePointer;
00075 typedef typename Superclass::FixedImageConstPointer FixedImageConstPointer;
00076 typedef typename Superclass::FixedImageRegionType FixedImageRegionType;
00077 typedef typename Superclass::TransformType TransformType;
00078 typedef typename Superclass::TransformPointer TransformPointer;
00079 typedef typename Superclass::InputPointType InputPointType;
00080 typedef typename Superclass::OutputPointType OutputPointType;
00081 typedef typename Superclass::TransformParametersType TransformParametersType;
00082 typedef typename Superclass::TransformJacobianType TransformJacobianType;
00083 typedef typename Superclass::InterpolatorType InterpolatorType;
00084 typedef typename Superclass::InterpolatorPointer InterpolatorPointer;
00085 typedef typename Superclass::RealType RealType;
00086 typedef typename Superclass::GradientPixelType GradientPixelType;
00087 typedef typename Superclass::GradientImageType GradientImageType;
00088 typedef typename Superclass::GradientImagePointer GradientImagePointer;
00089 typedef typename Superclass::GradientImageFilterType GradientImageFilterType;
00090 typedef typename Superclass::GradientImageFilterPointer GradientImageFilterPointer;
00091 typedef typename Superclass::FixedImageMaskType FixedImageMaskType;
00092 typedef typename Superclass::FixedImageMaskPointer FixedImageMaskPointer;
00093 typedef typename Superclass::MovingImageMaskType MovingImageMaskType;
00094 typedef typename Superclass::MovingImageMaskPointer MovingImageMaskPointer;
00095 typedef typename Superclass::MeasureType MeasureType;
00096 typedef typename Superclass::DerivativeType DerivativeType;
00097 typedef typename Superclass::ParametersType ParametersType;
00098
00099 typedef InterpolateImageFunction<
00100 FixedImageType, CoordinateRepresentationType > FixedImageInterpolatorType;
00101 typedef typename FixedImageInterpolatorType::Pointer FixedImageInterpolatorPointer;
00102
00104 typedef std::vector< FixedImageConstPointer > FixedImageVectorType;
00105 typedef std::vector< FixedImageMaskPointer > FixedImageMaskVectorType;
00106 typedef std::vector< FixedImageRegionType > FixedImageRegionVectorType;
00107 typedef std::vector< MovingImageConstPointer > MovingImageVectorType;
00108 typedef std::vector< MovingImageMaskPointer > MovingImageMaskVectorType;
00109 typedef std::vector< InterpolatorPointer > InterpolatorVectorType;
00110 typedef std::vector< FixedImageInterpolatorPointer > FixedImageInterpolatorVectorType;
00111
00115 virtual void SetFixedImage( const FixedImageType *_arg, unsigned int pos );
00116
00118 virtual void SetFixedImage( const FixedImageType *_arg )
00119 {
00120 this->SetFixedImage( _arg, 0 );
00121 };
00122
00124 virtual const FixedImageType * GetFixedImage( unsigned int pos ) const;
00125
00127 virtual const FixedImageType * GetFixedImage( void ) const
00128 {
00129 return this->GetFixedImage( 0 );
00130 };
00131
00133 itkSetNumberOfMacro( FixedImage );
00134
00136 itkGetConstMacro( NumberOfFixedImages, unsigned int );
00137
00141 virtual void SetFixedImageMask( FixedImageMaskType *_arg, unsigned int pos );
00142
00144 virtual void SetFixedImageMask( FixedImageMaskType *_arg )
00145 {
00146 this->SetFixedImageMask( _arg, 0 );
00147 };
00148
00150 virtual FixedImageMaskType * GetFixedImageMask( unsigned int pos ) const;
00151
00153 virtual FixedImageMaskType * GetFixedImageMask( void ) const
00154 {
00155 return this->GetFixedImageMask( 0 );
00156 };
00157
00159 itkSetNumberOfMacro( FixedImageMask );
00160
00162 itkGetConstMacro( NumberOfFixedImageMasks, unsigned int );
00163
00167 virtual void SetFixedImageRegion( const FixedImageRegionType _arg, unsigned int pos );
00168
00170 virtual void SetFixedImageRegion( const FixedImageRegionType _arg )
00171 {
00172 this->SetFixedImageRegion( _arg, 0 );
00173 };
00174
00176 virtual const FixedImageRegionType & GetFixedImageRegion( unsigned int pos ) const;
00177
00179 virtual const FixedImageRegionType & GetFixedImageRegion( void ) const
00180 {
00181 return this->GetFixedImageRegion( 0 );
00182 };
00183
00185 itkSetNumberOfMacro( FixedImageRegion );
00186
00188 itkGetConstMacro( NumberOfFixedImageRegions, unsigned int );
00189
00193 virtual void SetMovingImage( const MovingImageType *_arg, unsigned int pos );
00194
00196 virtual void SetMovingImage( const MovingImageType *_arg )
00197 {
00198 this->SetMovingImage( _arg, 0 );
00199 };
00200
00202 virtual const MovingImageType * GetMovingImage( unsigned int pos ) const;
00203
00205 virtual const MovingImageType * GetMovingImage( void ) const
00206 {
00207 return this->GetMovingImage( 0 );
00208 };
00209
00211 itkSetNumberOfMacro( MovingImage );
00212
00214 itkGetConstMacro( NumberOfMovingImages, unsigned int );
00215
00219 virtual void SetMovingImageMask( MovingImageMaskType *_arg, unsigned int pos );
00220
00222 virtual void SetMovingImageMask( MovingImageMaskType *_arg )
00223 {
00224 this->SetMovingImageMask( _arg, 0 );
00225 };
00226
00228 virtual MovingImageMaskType * GetMovingImageMask( unsigned int pos ) const;
00229
00231 virtual MovingImageMaskType * GetMovingImageMask( void ) const
00232 {
00233 return this->GetMovingImageMask( 0 );
00234 };
00235
00237 itkSetNumberOfMacro( MovingImageMask );
00238
00240 itkGetConstMacro( NumberOfMovingImageMasks, unsigned int );
00241
00247 virtual void SetInterpolator( InterpolatorType *_arg, unsigned int pos );
00248
00250 virtual void SetInterpolator( InterpolatorType *_arg )
00251 {
00252 return this->SetInterpolator( _arg, 0 );
00253 };
00254
00256 virtual InterpolatorType * GetInterpolator( unsigned int pos ) const;
00257
00259 virtual InterpolatorType * GetInterpolator( void ) const
00260 {
00261 return this->GetInterpolator( 0 );
00262 };
00263
00265 itkSetNumberOfMacro( Interpolator );
00266
00268 itkGetConstMacro( NumberOfInterpolators, unsigned int );
00269
00271 itkGetConstMacro( InterpolatorsAreBSpline, bool );
00272
00278 virtual void SetFixedImageInterpolator( FixedImageInterpolatorType *_arg, unsigned int pos );
00279
00281 virtual void SetFixedImageInterpolator( FixedImageInterpolatorType *_arg )
00282 {
00283 return this->SetFixedImageInterpolator( _arg, 0 );
00284 };
00285
00287 virtual FixedImageInterpolatorType * GetFixedImageInterpolator( unsigned int pos ) const;
00288
00290 virtual FixedImageInterpolatorType * GetFixedImageInterpolator( void ) const
00291 {
00292 return this->GetFixedImageInterpolator( 0 );
00293 };
00294
00296 itkSetNumberOfMacro( FixedImageInterpolator );
00297
00299 itkGetConstMacro( NumberOfFixedImageInterpolators, unsigned int );
00300
00304 virtual void Initialize( void ) throw ( ExceptionObject );
00305
00306 protected:
00307
00309 MultiInputImageToImageMetricBase();
00310
00312 virtual ~MultiInputImageToImageMetricBase() {};
00313
00315 typedef typename Superclass::MovingImagePointType MovingImagePointType;
00316 typedef typename Superclass::MovingImageIndexType MovingImageIndexType;
00317 typedef typename Superclass::MovingImageDerivativeType MovingImageDerivativeType;
00318 typedef typename Superclass::MovingImageContinuousIndexType MovingImageContinuousIndexType;
00319
00321 typedef typename Superclass::BSplineInterpolatorType BSplineInterpolatorType;
00322 typedef typename BSplineInterpolatorType::Pointer BSplineInterpolatorPointer;
00323 typedef std::vector<BSplineInterpolatorPointer> BSplineInterpolatorVectorType;
00324
00326 virtual void InitializeImageSampler( void ) throw ( ExceptionObject );
00327
00331 virtual void CheckForBSplineInterpolators( void );
00332
00336 virtual bool EvaluateMovingImageValueAndDerivative(
00337 const MovingImagePointType & mappedPoint,
00338 RealType & movingImageValue,
00339 MovingImageDerivativeType * gradient ) const;
00340
00342 virtual bool IsInsideMovingMask(
00343 const MovingImagePointType & mappedPoint ) const;
00344
00346 FixedImageVectorType m_FixedImageVector;
00347 FixedImageMaskVectorType m_FixedImageMaskVector;
00348 FixedImageRegionVectorType m_FixedImageRegionVector;
00349 MovingImageVectorType m_MovingImageVector;
00350 MovingImageMaskVectorType m_MovingImageMaskVector;
00351 InterpolatorVectorType m_InterpolatorVector;
00352 FixedImageInterpolatorVectorType m_FixedImageInterpolatorVector;
00353
00354 bool m_InterpolatorsAreBSpline;
00355 BSplineInterpolatorVectorType m_BSplineInterpolatorVector;
00356
00357 private:
00358
00359 MultiInputImageToImageMetricBase(const Self&);
00360 void operator=(const Self&);
00361
00363 FixedImageRegionType m_DummyFixedImageRegion;
00364
00365 unsigned int m_NumberOfFixedImages;
00366 unsigned int m_NumberOfFixedImageMasks;
00367 unsigned int m_NumberOfFixedImageRegions;
00368 unsigned int m_NumberOfMovingImages;
00369 unsigned int m_NumberOfMovingImageMasks;
00370 unsigned int m_NumberOfInterpolators;
00371 unsigned int m_NumberOfFixedImageInterpolators;
00372
00373 };
00374
00375 }
00376
00377 #undef itkSetNumberOfMacro
00378
00379 #ifndef ITK_MANUAL_INSTANTIATION
00380 #include "itkMultiInputImageToImageMetricBase.txx"
00381 #endif
00382
00383 #endif // end #ifndef __itkMultiInputImageToImageMetricBase_h
00384