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  * Copyright UMC Utrecht and contributors
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkCombinationImageToImageMetric_h
19 #define __itkCombinationImageToImageMetric_h
20 
23 
24 namespace itk
25 {
26 
58 template< class TFixedImage, class TMovingImage >
60  public AdvancedImageToImageMetric< TFixedImage, TMovingImage >
61 {
62 public:
63 
67  TFixedImage, TMovingImage > Superclass;
69  typedef SmartPointer< const Self > ConstPointer;
70 
73 
75  itkNewMacro( Self );
76 
78  itkStaticConstMacro( MovingImageDimension, unsigned int,
79  TMovingImage::ImageDimension );
80  itkStaticConstMacro( FixedImageDimension, unsigned int,
81  TFixedImage::ImageDimension );
82 
87  //typedef typename Superclass::MovingImagePointer MovingImagePointer;
90  //typedef typename Superclass::FixedImagePointer FixedImagePointer;
94  typedef typename TransformType::Pointer TransformPointer;
101  typedef typename Superclass::RealType RealType;
115 
119 
134  typedef Superclass ImageMetricType;
135  typedef typename ImageMetricType::Pointer ImageMetricPointer;
136  typedef SingleValuedCostFunction SingleValuedCostFunctionType;
137  typedef typename SingleValuedCostFunctionType::Pointer SingleValuedCostFunctionPointer;
138 
139  typedef typename FixedImageType::PixelType FixedImagePixelType;
140  typedef typename MovingImageType::RegionType MovingImageRegionType;
141  typedef FixedArray< double,
142  itkGetStaticConstMacro( MovingImageDimension ) > MovingImageDerivativeScalesType;
143 
145  typedef PointSet< CoordinateRepresentationType,
146  TFixedImage::ImageDimension,
147  DefaultStaticMeshTraits<
149  TFixedImage::ImageDimension,
150  TFixedImage::ImageDimension,
152  CoordinateRepresentationType > > FixedPointSetType;
153  typedef PointSet< CoordinateRepresentationType,
154  TMovingImage::ImageDimension,
155  DefaultStaticMeshTraits<
157  TMovingImage::ImageDimension,
158  TMovingImage::ImageDimension,
160  CoordinateRepresentationType > > MovingPointSetType;
162  FixedPointSetType, MovingPointSetType > PointSetMetricType;
163 
167 
173  void SetNumberOfMetrics( unsigned int count );
174 
176  itkGetConstMacro( NumberOfMetrics, unsigned int );
177 
182  void SetMetric( SingleValuedCostFunctionType * metric, unsigned int pos );
183 
185  SingleValuedCostFunctionType * GetMetric( unsigned int count ) const;
186 
188  void SetMetricWeight( double weight, unsigned int pos );
189 
191  double GetMetricWeight( unsigned int pos ) const;
192 
194  void SetMetricRelativeWeight( double weight, unsigned int pos );
195 
197  double GetMetricRelativeWeight( unsigned int pos ) const;
198 
200  itkSetMacro( UseRelativeWeights, bool );
201  itkGetMacro( UseRelativeWeights, bool );
202 
204  itkSetMacro( UseMultiThread, bool );
205 
211  void SetUseMetric( const bool use, const unsigned int pos );
212 
214  void SetUseAllMetrics( void );
215 
217  bool GetUseMetric( const unsigned int pos ) const;
218 
220  MeasureType GetMetricValue( unsigned int pos ) const;
221 
223  const DerivativeType & GetMetricDerivative( unsigned int pos ) const;
224 
226  double GetMetricDerivativeMagnitude( unsigned int pos ) const;
227 
229  double GetMetricComputationTime( unsigned int pos ) const;
230 
236  virtual void SetTransform( TransformType * _arg );
237 
248  virtual void SetTransform( TransformType * _arg, unsigned int pos );
249 
253  virtual const TransformType * GetTransform( unsigned int pos ) const;
254 
256  virtual const TransformType * GetTransform( void ) const
257  {
258  return this->GetTransform( 0 );
259  }
260 
261 
263  virtual void SetInterpolator( InterpolatorType * _arg );
264 
266  virtual void SetInterpolator( InterpolatorType * _arg, unsigned int pos );
267 
271  virtual const InterpolatorType * GetInterpolator( unsigned int pos ) const;
272 
274  virtual const InterpolatorType * GetInterpolator( void ) const
275  {
276  return this->GetInterpolator( 0 );
277  }
278 
279 
281  virtual void SetFixedImage( const FixedImageType * _arg );
282 
284  virtual void SetFixedImage( const FixedImageType * _arg, unsigned int pos );
285 
289  virtual const FixedImageType * GetFixedImage( unsigned int pos ) const;
290 
292  virtual const FixedImageType * GetFixedImage( void ) const
293  {
294  return this->GetFixedImage( 0 );
295  }
296 
297 
299  virtual void SetFixedImageMask( FixedImageMaskType * _arg );
300 
302  virtual void SetFixedImageMask( FixedImageMaskType * _arg, unsigned int pos );
303 
307  virtual const FixedImageMaskType * GetFixedImageMask( unsigned int pos ) const;
308 
310  virtual const FixedImageMaskType * GetFixedImageMask( void ) const
311  {
312  return this->GetFixedImageMask( 0 );
313  }
314 
315 
317  virtual void SetFixedImageRegion( const FixedImageRegionType _arg );
318 
320  virtual void SetFixedImageRegion( const FixedImageRegionType _arg, unsigned int pos );
321 
325  virtual const FixedImageRegionType & GetFixedImageRegion( unsigned int pos ) const;
326 
328  virtual const FixedImageRegionType & GetFixedImageRegion( void ) const
329  {
330  return this->GetFixedImageRegion( 0 );
331  }
332 
333 
335  virtual void SetMovingImage( const MovingImageType * _arg );
336 
338  virtual void SetMovingImage( const MovingImageType * _arg, unsigned int pos );
339 
343  virtual const MovingImageType * GetMovingImage( unsigned int pos ) const;
344 
346  virtual const MovingImageType * GetMovingImage( void ) const
347  {
348  return this->GetMovingImage( 0 );
349  }
350 
351 
353  virtual void SetMovingImageMask( MovingImageMaskType * _arg );
354 
356  virtual void SetMovingImageMask( MovingImageMaskType * _arg, unsigned int pos );
357 
361  virtual const MovingImageMaskType * GetMovingImageMask( unsigned int pos ) const;
362 
364  virtual const MovingImageMaskType * GetMovingImageMask( void ) const
365  {
366  return this->GetMovingImageMask( 0 );
367  }
368 
369 
373  virtual const SizeValueType & GetNumberOfPixelsCounted( void ) const;
374 
376  virtual void Initialize( void ) throw ( ExceptionObject );
377 
383  virtual MeasureType GetValue( const ParametersType & parameters ) const;
384 
386  virtual void GetDerivative(
387  const ParametersType & parameters,
388  DerivativeType & derivative ) const;
389 
391  virtual void GetValueAndDerivative(
392  const ParametersType & parameters,
393  MeasureType & value,
394  DerivativeType & derivative ) const;
395 
397  virtual void GetSelfHessian(
398  const TransformParametersType & parameters,
399  HessianType & H ) const;
400 
404  virtual unsigned long GetMTime() const;
405 
407  static ITK_THREAD_RETURN_TYPE GetValueAndDerivativeComboThreaderCallback( void * arg );
408 
410  static ITK_THREAD_RETURN_TYPE CombineDerivativesThreaderCallback( void * arg );
411 
413  static ITK_THREAD_RETURN_TYPE ComputeDerivativesMagnitudeThreaderCallback( void * arg );
414 
415 protected:
416 
418  virtual ~CombinationImageToImageMetric() {}
419  void PrintSelf( std::ostream & os, Indent indent ) const;
420 
422  unsigned int m_NumberOfMetrics;
423  std::vector< SingleValuedCostFunctionPointer > m_Metrics;
424  std::vector< double > m_MetricWeights;
425  std::vector< double > m_MetricRelativeWeights;
427  std::vector< bool > m_UseMetric;
428  mutable std::vector< MeasureType > m_MetricValues;
429  mutable std::vector< DerivativeType > m_MetricDerivatives;
430  mutable std::vector< double > m_MetricDerivativesMagnitude;
431  mutable std::vector< double > m_MetricComputationTime;
432 
434  FixedImageRegionType m_NullFixedImageRegion;
435  DerivativeType m_NullDerivative;
436 
437 private:
438 
439  CombinationImageToImageMetric( const Self & ); // purposely not implemented
440  void operator=( const Self & ); // purposely not implemented
441 
446  virtual void InitializeThreadingParameters( void ) const;
447 
451  double GetFinalMetricWeight( unsigned int pos ) const;
452 
455  {
456  std::vector< SingleValuedCostFunctionPointer > st_MetricsIterator;
457  typename std::vector< MeasureType >::iterator st_MetricValuesIterator;
458  typename std::vector< DerivativeType >::iterator st_MetricDerivativesIterator;
459  std::vector< double > st_MetricComputationTime;
460  ParametersType * st_Parameters;
461  };
462 
464  {
466  std::vector< double > st_DerivativesSumOfSquares;
467  DerivativeValueType * st_Derivative;
468  };
469 
471 
472 };
473 
474 } // end namespace itk
475 
476 #ifndef ITK_MANUAL_INSTANTIATION
477 #include "itkCombinationImageToImageMetric.hxx"
478 #endif
479 
480 #endif // end #ifndef __itkCombinationImageToImageMetric_h
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)
double GetMetricComputationTime(unsigned int pos) const
Superclass::CoordinateRepresentationType CoordinateRepresentationType
Superclass::TransformParametersType TransformParametersType
Superclass::MovingImagePixelType MovingImagePixelType
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)
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
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 04-09-2015 for elastix by doxygen 1.8.9.1 elastix logo