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.
1 /*======================================================================
2 
3  This file is part of the elastix software.
4 
5  Copyright (c) University Medical Center Utrecht. All rights reserved.
6  See src/CopyrightElastix.txt or http://elastix.isi.uu.nl/legal.php for
7  details.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without even
10  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  PURPOSE. See the above copyright notices for more information.
12 
13 ======================================================================*/
14 #ifndef __itkCombinationImageToImageMetric_h
15 #define __itkCombinationImageToImageMetric_h
16 
19 
20 namespace itk
21 {
22 
54 template< class TFixedImage, class TMovingImage >
56  public AdvancedImageToImageMetric< TFixedImage, TMovingImage >
57 {
58 public:
59 
63  TFixedImage, TMovingImage > Superclass;
64  typedef SmartPointer< Self > Pointer;
65  typedef SmartPointer< const Self > ConstPointer;
66 
69 
71  itkNewMacro( Self );
72 
74  itkStaticConstMacro( MovingImageDimension, unsigned int,
75  TMovingImage::ImageDimension );
76  itkStaticConstMacro( FixedImageDimension, unsigned int,
77  TFixedImage::ImageDimension );
78 
83  //typedef typename Superclass::MovingImagePointer MovingImagePointer;
86  //typedef typename Superclass::FixedImagePointer FixedImagePointer;
90  typedef typename TransformType::Pointer TransformPointer;
97  typedef typename Superclass::RealType RealType;
111 
115 
131  typedef typename ImageMetricType::Pointer ImageMetricPointer;
132  typedef SingleValuedCostFunction SingleValuedCostFunctionType;
133  typedef typename SingleValuedCostFunctionType::Pointer SingleValuedCostFunctionPointer;
134 
135  typedef typename FixedImageType::PixelType FixedImagePixelType;
136  typedef typename MovingImageType::RegionType MovingImageRegionType;
137  typedef FixedArray< double,
138  itkGetStaticConstMacro( MovingImageDimension ) > MovingImageDerivativeScalesType;
139 
141  typedef PointSet< CoordinateRepresentationType,
142  TFixedImage::ImageDimension,
143  DefaultStaticMeshTraits<
145  TFixedImage::ImageDimension,
146  TFixedImage::ImageDimension,
149  typedef PointSet< CoordinateRepresentationType,
150  TMovingImage::ImageDimension,
151  DefaultStaticMeshTraits<
153  TMovingImage::ImageDimension,
154  TMovingImage::ImageDimension,
159 
163 
169  void SetNumberOfMetrics( unsigned int count );
170 
172  itkGetConstMacro( NumberOfMetrics, unsigned int );
173 
178  void SetMetric( SingleValuedCostFunctionType * metric, unsigned int pos );
179 
181  SingleValuedCostFunctionType * GetMetric( unsigned int count ) const;
182 
184  void SetMetricWeight( double weight, unsigned int pos );
185 
187  double GetMetricWeight( unsigned int pos ) const;
188 
190  void SetMetricRelativeWeight( double weight, unsigned int pos );
191 
193  double GetMetricRelativeWeight( unsigned int pos ) const;
194 
196  itkSetMacro( UseRelativeWeights, bool );
197  itkGetMacro( UseRelativeWeights, bool );
198 
200  itkSetMacro( UseMultiThread, bool );
201 
207  void SetUseMetric( const bool use, const unsigned int pos );
208 
210  void SetUseAllMetrics( void );
211 
213  bool GetUseMetric( const unsigned int pos ) const;
214 
216  MeasureType GetMetricValue( unsigned int pos ) const;
217 
219  const DerivativeType & GetMetricDerivative( unsigned int pos ) const;
220 
222  double GetMetricDerivativeMagnitude( unsigned int pos ) const;
223 
225  std::size_t GetMetricComputationTime( unsigned int pos ) const;
226 
232  virtual void SetTransform( TransformType * _arg );
233 
244  virtual void SetTransform( TransformType * _arg, unsigned int pos );
245 
249  virtual const TransformType * GetTransform( unsigned int pos ) const;
250 
252  virtual const TransformType * GetTransform( void ) const
253  {
254  return this->GetTransform( 0 );
255  }
256 
257 
259  virtual void SetInterpolator( InterpolatorType * _arg );
260 
262  virtual void SetInterpolator( InterpolatorType * _arg, unsigned int pos );
263 
267  virtual const InterpolatorType * GetInterpolator( unsigned int pos ) const;
268 
270  virtual const InterpolatorType * GetInterpolator( void ) const
271  {
272  return this->GetInterpolator( 0 );
273  }
274 
275 
277  virtual void SetFixedImage( const FixedImageType * _arg );
278 
280  virtual void SetFixedImage( const FixedImageType * _arg, unsigned int pos );
281 
285  virtual const FixedImageType * GetFixedImage( unsigned int pos ) const;
286 
288  virtual const FixedImageType * GetFixedImage( void ) const
289  {
290  return this->GetFixedImage( 0 );
291  }
292 
293 
295  virtual void SetFixedImageMask( FixedImageMaskType * _arg );
296 
298  virtual void SetFixedImageMask( FixedImageMaskType * _arg, unsigned int pos );
299 
303  virtual const FixedImageMaskType * GetFixedImageMask( unsigned int pos ) const;
304 
306  virtual const FixedImageMaskType * GetFixedImageMask( void ) const
307  {
308  return this->GetFixedImageMask( 0 );
309  }
310 
311 
313  virtual void SetFixedImageRegion( const FixedImageRegionType _arg );
314 
316  virtual void SetFixedImageRegion( const FixedImageRegionType _arg, unsigned int pos );
317 
321  virtual const FixedImageRegionType & GetFixedImageRegion( unsigned int pos ) const;
322 
324  virtual const FixedImageRegionType & GetFixedImageRegion( void ) const
325  {
326  return this->GetFixedImageRegion( 0 );
327  }
328 
329 
331  virtual void SetMovingImage( const MovingImageType * _arg );
332 
334  virtual void SetMovingImage( const MovingImageType * _arg, unsigned int pos );
335 
339  virtual const MovingImageType * GetMovingImage( unsigned int pos ) const;
340 
342  virtual const MovingImageType * GetMovingImage( void ) const
343  {
344  return this->GetMovingImage( 0 );
345  }
346 
347 
349  virtual void SetMovingImageMask( MovingImageMaskType * _arg );
350 
352  virtual void SetMovingImageMask( MovingImageMaskType * _arg, unsigned int pos );
353 
357  virtual const MovingImageMaskType * GetMovingImageMask( unsigned int pos ) const;
358 
360  virtual const MovingImageMaskType * GetMovingImageMask( void ) const
361  {
362  return this->GetMovingImageMask( 0 );
363  }
364 
365 
369  virtual const SizeValueType & GetNumberOfPixelsCounted( void ) const;
370 
372  virtual void Initialize( void ) throw ( ExceptionObject );
373 
379  virtual MeasureType GetValue( const ParametersType & parameters ) const;
380 
382  virtual void GetDerivative(
383  const ParametersType & parameters,
384  DerivativeType & derivative ) const;
385 
387  virtual void GetValueAndDerivative(
388  const ParametersType & parameters,
389  MeasureType & value,
390  DerivativeType & derivative ) const;
391 
393  virtual void GetSelfHessian(
394  const TransformParametersType & parameters,
395  HessianType & H ) const;
396 
400  virtual unsigned long GetMTime() const;
401 
403  static ITK_THREAD_RETURN_TYPE GetValueAndDerivativeComboThreaderCallback( void * arg );
404 
406  static ITK_THREAD_RETURN_TYPE CombineDerivativesThreaderCallback( void * arg );
407 
409  static ITK_THREAD_RETURN_TYPE ComputeDerivativesMagnitudeThreaderCallback( void * arg );
410 
411 protected:
412 
414  virtual ~CombinationImageToImageMetric() {}
415  void PrintSelf( std::ostream & os, Indent indent ) const;
416 
418  unsigned int m_NumberOfMetrics;
419  std::vector< SingleValuedCostFunctionPointer > m_Metrics;
420  std::vector< double > m_MetricWeights;
421  std::vector< double > m_MetricRelativeWeights;
423  std::vector< bool > m_UseMetric;
424  mutable std::vector< MeasureType > m_MetricValues;
425  mutable std::vector< DerivativeType > m_MetricDerivatives;
426  mutable std::vector< double > m_MetricDerivativesMagnitude;
427  mutable std::vector< std::size_t > m_MetricComputationTime;
428 
432 
433 private:
434 
435  CombinationImageToImageMetric( const Self & ); // purposely not implemented
436  void operator=( const Self & ); // purposely not implemented
437 
442  virtual void InitializeThreadingParameters( void ) const;
443 
447  double GetFinalMetricWeight( unsigned int pos ) const;
448 
451  {
452  std::vector< SingleValuedCostFunctionPointer > st_MetricsIterator;
453  typename std::vector< MeasureType >::iterator st_MetricValuesIterator;
454  typename std::vector< DerivativeType >::iterator st_MetricDerivativesIterator;
455  std::vector< std::size_t > st_MetricComputationTime;
457  };
458 
460  {
462  std::vector< double > st_DerivativesSumOfSquares;
464  };
465 
467 
468 };
469 
470 } // end namespace itk
471 
472 #ifndef ITK_MANUAL_INSTANTIATION
473 #include "itkCombinationImageToImageMetric.hxx"
474 #endif
475 
476 #endif // end #ifndef __itkCombinationImageToImageMetric_h
ImageToImageMetric< TFixedImage, TMovingImage > Superclass
Superclass::TransformParametersType TransformParametersType
SingleValuedCostFunctionType::Pointer SingleValuedCostFunctionPointer
AdvancedTransform< ScalarType, FixedImageDimension, MovingImageDimension > AdvancedTransformType
Superclass::AdvancedTransformType TransformType
virtual void SetInterpolator(InterpolatorType *_arg)
const DerivativeType & GetMetricDerivative(unsigned int pos) const
static ITK_THREAD_RETURN_TYPE CombineDerivativesThreaderCallback(void *arg)
Superclass::CoordinateRepresentationType CoordinateRepresentationType
Superclass::TransformParametersType TransformParametersType
Superclass::MovingImagePixelType MovingImagePixelType
Superclass::MovingImageType MovingImageType
bool GetUseMetric(const unsigned int pos) const
Superclass::FixedImageMaskPointer FixedImageMaskPointer
An extension of the ITK ImageToImageMetric. It is the intended base class for all elastix metrics...
Superclass::GradientImageFilterType GradientImageFilterType
static ITK_THREAD_RETURN_TYPE GetValueAndDerivativeComboThreaderCallback(void *arg)
virtual void GetSelfHessian(const TransformParametersType &parameters, HessianType &H) const
virtual void SetFixedImage(const FixedImageType *_arg)
Superclass::GradientImagePointer GradientImagePointer
Superclass::GradientPixelType GradientPixelType
Superclass::FixedImageMaskPointer FixedImageMaskPointer
virtual void SetTransform(TransformType *_arg)
Superclass::FixedImageRegionType FixedImageRegionType
void SetMetricRelativeWeight(double weight, unsigned int pos)
SingleValuedCostFunctionType * GetMetric(unsigned int count) const
virtual unsigned long GetMTime() const
virtual void SetMovingImage(const MovingImageType *_arg)
virtual const FixedImageRegionType & GetFixedImageRegion(void) const
virtual const MovingImageType * GetMovingImage(void) const
virtual void SetFixedImageMask(FixedImageMaskType *_arg)
double GetMetricDerivativeMagnitude(unsigned int pos) const
void SetMetric(SingleValuedCostFunctionType *metric, unsigned int pos)
virtual void GetValueAndDerivative(const ParametersType &parameters, MeasureType &value, DerivativeType &derivative) const
Superclass::InterpolatorPointer InterpolatorPointer
double GetFinalMetricWeight(unsigned int pos) const
Superclass::MovingImageMaskType MovingImageMaskType
void SetUseMetric(const bool use, const unsigned int pos)
std::vcl_size_t GetMetricComputationTime(unsigned int pos) const
Superclass::GradientImageFilterPointer GradientImageFilterPointer
PointSet< CoordinateRepresentationType, TFixedImage::ImageDimension, DefaultStaticMeshTraits< CoordinateRepresentationType, TFixedImage::ImageDimension, TFixedImage::ImageDimension, CoordinateRepresentationType, CoordinateRepresentationType, CoordinateRepresentationType > > FixedPointSetType
Superclass::MovingImageMaskType MovingImageMaskType
Superclass::DerivativeValueType DerivativeValueType
Superclass::GradientImageType GradientImageType
FixedArray< double, itkGetStaticConstMacro(MovingImageDimension) > MovingImageDerivativeScalesType
virtual void SetMovingImageMask(MovingImageMaskType *_arg)
itkStaticConstMacro(MovingImageDimension, unsigned int, TMovingImage::ImageDimension)
Superclass::GradientImageFilterType GradientImageFilterType
std::vector< SingleValuedCostFunctionPointer > m_Metrics
virtual void GetDerivative(const ParametersType &parameters, DerivativeType &derivative) const
Superclass::InterpolatorType InterpolatorType
Superclass::TransformJacobianType TransformJacobianType
std::vector< std::vcl_size_t > m_MetricComputationTime
virtual const TransformType * GetTransform(void) const
virtual MeasureType GetValue(const ParametersType &parameters) const
Superclass::MovingImagePixelType MovingImagePixelType
static ITK_THREAD_RETURN_TYPE ComputeDerivativesMagnitudeThreaderCallback(void *arg)
Superclass::MovingImageMaskPointer MovingImageMaskPointer
virtual const SizeValueType & GetNumberOfPixelsCounted(void) const
Superclass::MovingImageMaskPointer MovingImageMaskPointer
PointSet< CoordinateRepresentationType, TMovingImage::ImageDimension, DefaultStaticMeshTraits< CoordinateRepresentationType, TMovingImage::ImageDimension, TMovingImage::ImageDimension, CoordinateRepresentationType, CoordinateRepresentationType, CoordinateRepresentationType > > MovingPointSetType
AdvancedImageToImageMetric< TFixedImage, TMovingImage > Superclass
SingleValuedPointSetToPointSetMetric< FixedPointSetType, MovingPointSetType > PointSetMetricType
ThreaderType::ThreadInfoStruct ThreadInfoType
virtual const FixedImageType * GetFixedImage(void) const
Superclass::TransformJacobianType TransformJacobianType
void SetNumberOfMetrics(unsigned int count)
void SetMetricWeight(double weight, unsigned int pos)
Superclass::FixedImageRegionType FixedImageRegionType
Superclass::MovingImageConstPointer MovingImageConstPointer
Superclass::FixedImageMaskType FixedImageMaskType
double GetMetricRelativeWeight(unsigned int pos) const
Superclass::InterpolatorPointer InterpolatorPointer
virtual void InitializeThreadingParameters(void) const
Superclass::FixedImageConstPointer FixedImageConstPointer
void PrintSelf(std::ostream &os, Indent indent) const
Superclass::FixedImageConstPointer FixedImageConstPointer
virtual const FixedImageMaskType * GetFixedImageMask(void) const
Superclass::MovingImageConstPointer MovingImageConstPointer
MeasureType GetMetricValue(unsigned int pos) const
virtual void SetFixedImageRegion(const FixedImageRegionType _arg)
Superclass::CoordinateRepresentationType CoordinateRepresentationType
virtual const InterpolatorType * GetInterpolator(void) const
Superclass::GradientImageFilterPointer GradientImageFilterPointer
double GetMetricWeight(unsigned int pos) const
virtual const MovingImageMaskType * GetMovingImageMask(void) const
vnl_sparse_matrix< HessianValueType > HessianType
Superclass::GradientImagePointer GradientImagePointer


Generated on 11-03-2014 for elastix by doxygen 1.8.6 elastix logo