NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
itkRIUImageToImageMetric.h
Go to the documentation of this file.
1 /*=============================================================================
2 
3  NifTK: A software platform for medical image computing.
4 
5  Copyright (c) University College London (UCL). All rights reserved.
6 
7  This software is distributed WITHOUT ANY WARRANTY; without even
8  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
9  PURPOSE.
10 
11  See LICENSE.txt in the top level directory for details.
12 
13 =============================================================================*/
14 
15 #ifndef itkRIUImageToImageMetric_h
16 #define itkRIUImageToImageMetric_h
17 
19 
20 namespace itk
21 {
30 template < class TFixedImage, class TMovingImage >
31 class ITK_EXPORT RIUImageToImageMetric :
32  public FiniteDifferenceGradientSimilarityMeasure< TFixedImage, TMovingImage>
33 {
34 public:
35 
39  typedef SmartPointer<Self> Pointer;
40  typedef SmartPointer<const Self> ConstPointer;
44 
46  itkNewMacro(Self);
47 
50 
51 protected:
52 
54  virtual ~RIUImageToImageMetric() {};
55 
60  {
61  m_numberCounted = 0;
62  m_ratio = 0;
63  m_mean = 0;
64  m_sum = 0;
65  m_sumSquared = 0;
66  m_stdDev = 0;
67  }
68 
73  FixedImagePixelType fixedValue,
74  MovingImagePixelType movingValue)
75  {
76  if (fixedValue != 0)
77  {
78  m_numberCounted++;
79  m_ratio = (movingValue/fixedValue);
80  m_sum += m_ratio;
81  m_sumSquared += (m_ratio*m_ratio);
82  }
83  };
84 
88  MeasureType FinalizeCostFunction()
89  {
90  double measure = 0;
91  if (m_numberCounted > 0)
92  {
93  m_mean = m_sum / (double)m_numberCounted;
94  m_stdDev = vcl_sqrt( (m_sumSquared - ((m_sum*m_sum)/(double)m_numberCounted))/((double)m_numberCounted - 1));
95  measure = m_stdDev / m_mean;
96  }
97  return measure;
98  }
99 
100 private:
101  RIUImageToImageMetric(const Self&); // purposefully not implemented
102  void operator=(const Self&); // purposefully not implemented
103 
104  long int m_numberCounted;
105  double m_ratio;
106  double m_mean;
107  double m_sum;
108  double m_sumSquared;
109  double m_stdDev;
110 };
111 
112 } // end namespace itk
113 
114 #endif
115 
116 
117 
RIUImageToImageMetric Self
Definition: itkRIUImageToImageMetric.h:37
Abstract base class, implementing TemplateMethod [2] for similarity measures.
Definition: itkSimilarityMeasure.h:56
MeasureType FinalizeCostFunction()
Definition: itkRIUImageToImageMetric.h:88
Definition: niftkITKAffineResampleImage.cxx:74
void AggregateCostFunctionPair(FixedImagePixelType fixedValue, MovingImagePixelType movingValue)
Definition: itkRIUImageToImageMetric.h:72
SimilarityMeasure< TFixedImage, TMovingImage > Superclass
Definition: itkRIUImageToImageMetric.h:38
virtual ~RIUImageToImageMetric()
Definition: itkRIUImageToImageMetric.h:54
Superclass::FixedImageType::PixelType FixedImagePixelType
Definition: itkRIUImageToImageMetric.h:41
SmartPointer< const Self > ConstPointer
Definition: itkRIUImageToImageMetric.h:40
void ResetCostFunction()
Definition: itkRIUImageToImageMetric.h:59
float PixelType
Definition: niftkBreastDCEandADC.cxx:88
SmartPointer< Self > Pointer
Definition: itkRIUImageToImageMetric.h:39
AbstractBase class, just to implement the finite difference gradient method.
Definition: itkFiniteDifferenceGradientSimilarityMeasure.h:32
Superclass::MeasureType MeasureType
Definition: itkRIUImageToImageMetric.h:43
Superclass::MovingImageType::PixelType MovingImagePixelType
Definition: itkRIUImageToImageMetric.h:42
Superclass::MeasureType MeasureType
Definition: itkSimilarityMeasure.h:80
Implements Roger Woods Ratio Image Uniformity, but beware, its non-symetrical, as the base class does...
Definition: itkRIUImageToImageMetric.h:31
RIUImageToImageMetric()
Definition: itkRIUImageToImageMetric.h:53