NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
itkHistogramSimilarityMeasure.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 itkHistogramSimilarityMeasure_h
16 #define itkHistogramSimilarityMeasure_h
17 
18 #include "itkUCLHistogram.h"
20 
21 namespace itk
22 {
32 template <class TFixedImage, class TMovingImage>
33 class ITK_EXPORT HistogramSimilarityMeasure :
34 public FiniteDifferenceGradientSimilarityMeasure<TFixedImage, TMovingImage>
35 {
36 public:
37 
41  typedef SmartPointer<Self> Pointer;
42  typedef SmartPointer<const Self> ConstPointer;
43 
46 
48  typedef typename Superclass::MeasureType MeasureType;
49  typedef typename Superclass::ParametersType ParametersType;
53 
60  typedef typename HistogramType::MeasurementVectorType HistogramMeasurementVectorType;
61  typedef typename HistogramType::AbsoluteFrequencyType HistogramFrequencyType;
62  typedef typename HistogramType::Iterator HistogramIteratorType;
63 
65  void Initialize() throw (ExceptionObject);
66 
68  void SetHistogramSize(int x, int y)
69  {
70  // The size of this vector is templated in base class.
71  niftkitkDebugMacro(<< "HistogramSimilarityMeasure():Setting size to [" << niftk::ConvertToString((int)x) \
72  << "," << niftk::ConvertToString((int)y) << "]");
73 
74  HistogramSizeType size(2);
75  size[0] = x;
76  size[1] = y;
77  this->SetHistogramSize(size);
78  };
79 
84  itkSetMacro( HistogramSize, HistogramSizeType );
85 
87  itkGetConstReferenceMacro( HistogramSize, HistogramSizeType );
88 
93  itkGetObjectMacro( Histogram, HistogramType );
94 
100  itkSetMacro(UseParzenFilling, bool);
101  itkGetMacro(UseParzenFilling, bool);
102 
104  double GetParzenValue(double x);
105 
107  double GetParzenDerivative(double x);
108 
109 protected:
110 
113 
115  HistogramSizeType m_HistogramSize;
116 
121  {
122  HistogramMeasurementVectorType lowerBounds(2);
123  lowerBounds[0] = this->GetFixedLowerBound();
124  lowerBounds[1] = this->GetMovingLowerBound();
125  HistogramMeasurementVectorType upperBounds(2);
126  upperBounds[0] = this->GetFixedUpperBound();
127  upperBounds[1] = this->GetMovingUpperBound();
128 
129 // niftkitkDebugMacro(<< "HistogramSimilarityMeasure():Resetting histogram to size:" << this->m_HistogramSize << ", lowerBounds:" << lowerBounds << ", upperBounds:" << upperBounds);
130  this->m_Histogram->Initialize( this->m_HistogramSize, lowerBounds, upperBounds );
131  this->m_Histogram->SetToZero();
132  }
133 
138  void AggregateCostFunctionPair(FixedImagePixelType fixedValue, MovingImagePixelType movingValue);
139 
141  void PrintSelf(std::ostream& os, Indent indent) const;
142 
144  MeasureType MeanFixed() const { return this->m_Histogram->MeanFixed(); }
145 
147  MeasureType MeanMoving() const { return this->m_Histogram->MeanMoving(); }
148 
150  MeasureType VarianceFixed() const { return this->m_Histogram->VarianceFixed(); }
151 
153  MeasureType VarianceMoving() const { return this->m_Histogram->VarianceMoving(); }
154 
156  MeasureType Covariance() const { return this->m_Histogram->Covariance(); }
157 
159  MeasureType EntropyFixed() const { return this->m_Histogram->EntropyFixed(); }
160 
162  MeasureType EntropyMoving() const { return this->m_Histogram->EntropyMoving(); }
163 
165  MeasureType JointEntropy() const { return this->m_Histogram->JointEntropy(); }
166 
171  HistogramPointer m_Histogram;
172 
173 private:
174  HistogramSimilarityMeasure(const Self&); // purposefully not implemented
175  void operator=(const Self&); // purposefully not implemented
176 
178  bool m_UseParzenFilling;
179 
180 };
181 
182 } // end namespace itk
183 
184 #ifndef ITK_MANUAL_INSTANTIATION
185 #include "itkHistogramSimilarityMeasure.txx"
186 #endif
187 
188 #endif // __itkHistogramSimilarityMeasure_h
MeasureType EntropyMoving() const
Definition: itkHistogramSimilarityMeasure.h:162
Superclass::SizeType SizeType
Definition: itkUCLHistogram.h:46
void ResetCostFunction()
Definition: itkHistogramSimilarityMeasure.h:120
Computes similarity between two objects to be registered using Histogram.
Definition: itkHistogramSimilarityMeasure.h:33
HistogramType::SizeType HistogramSizeType
Definition: itkHistogramSimilarityMeasure.h:59
Abstract base class, implementing TemplateMethod [2] for similarity measures.
Definition: itkSimilarityMeasure.h:56
SmartPointer< const Self > ConstPointer
Definition: itkHistogramSimilarityMeasure.h:42
SmartPointer< Self > Pointer
Definition: itkUCLHistogram.h:40
HistogramType::AbsoluteFrequencyType HistogramFrequencyType
Definition: itkHistogramSimilarityMeasure.h:61
MeasureType EntropyFixed() const
Definition: itkHistogramSimilarityMeasure.h:159
GLint GLint GLint GLint GLint GLint y
Definition: glew.h:1236
Definition: niftkITKAffineResampleImage.cxx:74
Superclass::FixedImageType::PixelType FixedImagePixelType
Definition: itkSimilarityMeasure.h:84
HistogramPointer m_Histogram
Definition: itkHistogramSimilarityMeasure.h:171
Superclass::MovingImagePixelType MovingImagePixelType
Definition: itkHistogramSimilarityMeasure.h:52
Superclass::MeasureType MeasureType
Definition: itkHistogramSimilarityMeasure.h:45
#define niftkitkDebugMacro(x)
Definition: itkUCLMacro.h:29
MeasureType MeanFixed() const
Definition: itkHistogramSimilarityMeasure.h:144
virtual ~HistogramSimilarityMeasure()
Definition: itkHistogramSimilarityMeasure.h:112
Superclass::FixedImagePixelType FixedImagePixelType
Definition: itkHistogramSimilarityMeasure.h:51
MeasureType VarianceMoving() const
Definition: itkHistogramSimilarityMeasure.h:153
Extends Histogram to provide standard Entropy functions.
Definition: itkUCLHistogram.h:32
SimilarityMeasure< TFixedImage, TMovingImage > Superclass
Definition: itkHistogramSimilarityMeasure.h:40
HistogramType::MeasurementVectorType HistogramMeasurementVectorType
Definition: itkHistogramSimilarityMeasure.h:60
HistogramType::Pointer HistogramPointer
Definition: itkHistogramSimilarityMeasure.h:58
MeasureType VarianceFixed() const
Definition: itkHistogramSimilarityMeasure.h:150
AbstractBase class, just to implement the finite difference gradient method.
Definition: itkFiniteDifferenceGradientSimilarityMeasure.h:32
MeasureType JointEntropy() const
Definition: itkHistogramSimilarityMeasure.h:165
std::string ConvertToString(int x)
Definition: niftkConversionUtils.cxx:26
GLint GLint GLint GLint GLint x
Definition: glew.h:1236
Statistics::UCLHistogram< double, 2 > HistogramType
Definition: itkHistogramSimilarityMeasure.h:57
GLsizeiptr size
Definition: glew.h:1665
MeasureType Covariance() const
Definition: itkHistogramSimilarityMeasure.h:156
Superclass::MeasureType MeasureType
Definition: itkSimilarityMeasure.h:80
Superclass::DerivativeType DerivativeType
Definition: itkSimilarityMeasure.h:81
Superclass::ParametersType ParametersType
Definition: itkHistogramSimilarityMeasure.h:49
HistogramSimilarityMeasure Self
Definition: itkHistogramSimilarityMeasure.h:39
HistogramType::Iterator HistogramIteratorType
Definition: itkHistogramSimilarityMeasure.h:62
Superclass::MovingImageType::PixelType MovingImagePixelType
Definition: itkSimilarityMeasure.h:87
Superclass::DerivativeType DerivativeType
Definition: itkHistogramSimilarityMeasure.h:50
MeasureType MeanMoving() const
Definition: itkHistogramSimilarityMeasure.h:147
SmartPointer< Self > Pointer
Definition: itkHistogramSimilarityMeasure.h:41