1 #ifndef __clitkCorrelationRatioImageToImageMetric_h
2 #define __clitkCorrelationRatioImageToImageMetric_h
5 * @file clitkCorrelationRatioImageToImageMetric.h
6 * @author Jef Vandemeulebroucke <jef@creatis.insa-lyon.fr>
7 * @date July 30 18:14:53 2007
9 * @brief Compute the correlation ratio between 2 images
14 /* This computes the correlation ratio between 2 images
16 * This class is templated over the FixedImage type and the MovingImage
19 * The fixed and moving images are set via methods SetFixedImage() and
20 * SetMovingImage(). This metric makes use of user specified Transform and
21 * Interpolator. The Transform is used to map points from the fixed image to
22 * the moving image domain. The Interpolator is used to evaluate the image
23 * intensity at user specified geometric points in the moving image.
24 * The Transform and Interpolator are set via methods SetTransform() and
27 * The method GetValue() computes of the mutual information
28 * while method GetValueAndDerivative() computes
29 * both the mutual information and its derivatives with respect to the
30 * transform parameters.
32 * The calculations are based on the method of Alexis Roche.
34 * The number of intensity bins used can be set through the SetNumberOfBins() method
36 * On Initialize(), we find the min and max intensities in the fixed image and compute the width of
37 * the intensity bins. The data structures which hold the bins and related measures are initialised.
41 #include "itkImageToImageMetric.h"
42 #include "itkCovariantVector.h"
49 template < class TFixedImage, class TMovingImage >
50 class ITK_EXPORT CorrelationRatioImageToImageMetric:
51 public ImageToImageMetric< TFixedImage, TMovingImage>
55 /** Standard class typedefs. */
56 typedef CorrelationRatioImageToImageMetric Self;
57 typedef ImageToImageMetric<TFixedImage, TMovingImage > Superclass;
59 typedef SmartPointer<Self> Pointer;
60 typedef SmartPointer<const Self> ConstPointer;
62 /** Method for creation through the object factory. */
65 /** Run-time type information (and related methods). */
66 itkTypeMacro(CorrelationRatioImageToImageMetric, ImageToImageMetric);
69 /** Types transferred from the base class */
70 typedef typename Superclass::RealType RealType;
71 typedef typename Superclass::TransformType TransformType;
72 typedef typename Superclass::TransformPointer TransformPointer;
73 typedef typename Superclass::TransformParametersType TransformParametersType;
74 typedef typename Superclass::TransformJacobianType TransformJacobianType;
75 typedef typename Superclass::GradientPixelType GradientPixelType;
77 typedef typename Superclass::MeasureType MeasureType;
78 typedef typename Superclass::DerivativeType DerivativeType;
79 typedef typename Superclass::FixedImageType FixedImageType;
80 typedef typename Superclass::MovingImageType MovingImageType;
81 typedef typename Superclass::FixedImageConstPointer FixedImageConstPointer;
82 typedef typename Superclass::MovingImageConstPointer MovingImageConstPointer;
86 * Initialize the Metric by
87 * (1) making sure that all the components are present and plugged
89 * (3) allocate memory for bin data structures. */
90 virtual void Initialize(void) throw ( ExceptionObject );
92 /** Get the derivatives of the match measure. */
93 void GetDerivative( const TransformParametersType & parameters,
94 DerivativeType & derivative ) const;
96 /** Get the value for single valued optimizers. */
97 MeasureType GetValue( const TransformParametersType & parameters ) const;
99 /** Get value and derivatives for multiple valued optimizers. */
100 void GetValueAndDerivative( const TransformParametersType & parameters,
101 MeasureType& Value, DerivativeType& Derivative ) const;
103 /** Number of bins to used in the calculation. Typical value is 50. */
104 itkSetClampMacro( NumberOfBins, unsigned long,
105 1, NumericTraits<unsigned long>::max() );
106 itkGetConstReferenceMacro( NumberOfBins, unsigned long);
109 CorrelationRatioImageToImageMetric();
110 virtual ~CorrelationRatioImageToImageMetric() {};
113 CorrelationRatioImageToImageMetric(const Self&); //purposely not implemented
114 void operator=(const Self&); //purposely not implemented
117 //the min and max in the fixed image intensity range
118 double m_FixedImageMin;
120 //The bin size in intensity
121 double m_FixedImageBinSize;
123 //The number of pixels in the fixed image bins are stored in a vector
124 mutable std::vector<unsigned long> m_NumberOfPixelsCountedPerBin;
126 //The mMSVPB and the mSMVPB are stored in vectors of realtype
127 typedef float ValueType;
128 typedef std::vector<ValueType> MeasurePerBinType;
129 mutable MeasurePerBinType m_mMSVPB;
130 mutable MeasurePerBinType m_mSMVPB;
131 unsigned long m_NumberOfBins;
136 } // end namespace itk
138 #ifndef ITK_MANUAL_INSTANTIATION
139 #include "clitkCorrelationRatioImageToImageMetric.txx"