1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
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 copyright notices for more information.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ======================================================================-====*/
19 #ifndef __clitkCorrelationRatioImageToImageMetric_h
20 #define __clitkCorrelationRatioImageToImageMetric_h
23 * @file clitkCorrelationRatioImageToImageMetric.h
24 * @author Jef Vandemeulebroucke <jef@creatis.insa-lyon.fr>
25 * @date July 30 18:14:53 2007
27 * @brief Compute the correlation ratio between 2 images
32 /* This computes the correlation ratio between 2 images
34 * This class is templated over the FixedImage type and the MovingImage
37 * The fixed and moving images are set via methods SetFixedImage() and
38 * SetMovingImage(). This metric makes use of user specified Transform and
39 * Interpolator. The Transform is used to map points from the fixed image to
40 * the moving image domain. The Interpolator is used to evaluate the image
41 * intensity at user specified geometric points in the moving image.
42 * The Transform and Interpolator are set via methods SetTransform() and
45 * The method GetValue() computes of the mutual information
46 * while method GetValueAndDerivative() computes
47 * both the mutual information and its derivatives with respect to the
48 * transform parameters.
50 * The calculations are based on the method of Alexis Roche.
52 * The number of intensity bins used can be set through the SetNumberOfBins() method
54 * On Initialize(), we find the min and max intensities in the fixed image and compute the width of
55 * the intensity bins. The data structures which hold the bins and related measures are initialised.
59 #include "itkImageToImageMetric.h"
60 #include "itkCovariantVector.h"
67 template < class TFixedImage, class TMovingImage >
68 class ITK_EXPORT CorrelationRatioImageToImageMetric:
69 public ImageToImageMetric< TFixedImage, TMovingImage>
73 /** Standard class typedefs. */
74 typedef CorrelationRatioImageToImageMetric Self;
75 typedef ImageToImageMetric<TFixedImage, TMovingImage > Superclass;
77 typedef SmartPointer<Self> Pointer;
78 typedef SmartPointer<const Self> ConstPointer;
80 /** Method for creation through the object factory. */
83 /** Run-time type information (and related methods). */
84 itkTypeMacro(CorrelationRatioImageToImageMetric, ImageToImageMetric);
87 /** Types transferred from the base class */
88 typedef typename Superclass::RealType RealType;
89 typedef typename Superclass::TransformType TransformType;
90 typedef typename Superclass::TransformPointer TransformPointer;
91 typedef typename Superclass::TransformParametersType TransformParametersType;
92 typedef typename Superclass::TransformJacobianType TransformJacobianType;
93 typedef typename Superclass::GradientPixelType GradientPixelType;
95 typedef typename Superclass::MeasureType MeasureType;
96 typedef typename Superclass::DerivativeType DerivativeType;
97 typedef typename Superclass::FixedImageType FixedImageType;
98 typedef typename Superclass::MovingImageType MovingImageType;
99 typedef typename Superclass::FixedImageConstPointer FixedImageConstPointer;
100 typedef typename Superclass::MovingImageConstPointer MovingImageConstPointer;
104 * Initialize the Metric by
105 * (1) making sure that all the components are present and plugged
106 * together correctly,
107 * (3) allocate memory for bin data structures. */
108 virtual void Initialize(void) throw ( ExceptionObject );
110 /** Get the derivatives of the match measure. */
111 void GetDerivative( const TransformParametersType & parameters,
112 DerivativeType & derivative ) const;
114 /** Get the value for single valued optimizers. */
115 MeasureType GetValue( const TransformParametersType & parameters ) const;
117 /** Get value and derivatives for multiple valued optimizers. */
118 void GetValueAndDerivative( const TransformParametersType & parameters,
119 MeasureType& Value, DerivativeType& Derivative ) const;
121 /** Number of bins to used in the calculation. Typical value is 50. */
122 itkSetClampMacro( NumberOfBins, unsigned long,
123 1, NumericTraits<unsigned long>::max() );
124 itkGetConstReferenceMacro( NumberOfBins, unsigned long);
127 CorrelationRatioImageToImageMetric();
128 virtual ~CorrelationRatioImageToImageMetric() {};
131 CorrelationRatioImageToImageMetric(const Self&); //purposely not implemented
132 void operator=(const Self&); //purposely not implemented
135 //the min and max in the fixed image intensity range
136 double m_FixedImageMin;
138 //The bin size in intensity
139 double m_FixedImageBinSize;
141 //The number of pixels in the fixed image bins are stored in a vector
142 mutable std::vector<unsigned long> m_NumberOfPixelsCountedPerBin;
144 //The mMSVPB and the mSMVPB are stored in vectors of realtype
145 typedef float ValueType;
146 typedef std::vector<ValueType> MeasurePerBinType;
147 mutable MeasurePerBinType m_mMSVPB;
148 mutable MeasurePerBinType m_mSMVPB;
149 unsigned long m_NumberOfBins;
154 } // end namespace itk
156 #ifndef ITK_MANUAL_INSTANTIATION
157 #include "clitkCorrelationRatioImageToImageMetric.txx"