2 /*=========================================================================
5 Module: $RCSfile: clitkCorrelationRatioImageToImageMetric.h
7 Date: $Date: 2010/01/06 13:31:56 $
8 Version: $Revision: 1.1 $
10 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
11 l'Image). All rights reserved. See Doc/License.txt or
12 http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
14 This software is distributed WITHOUT ANY WARRANTY; without even
15 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16 PURPOSE. See the above copyright notices for more information.
18 =========================================================================*/
21 #ifndef __clitkCorrelationRatioImageToImageMetric_h
22 #define __clitkCorrelationRatioImageToImageMetric_h
25 * @file clitkCorrelationRatioImageToImageMetric.h
26 * @author Jef Vandemeulebroucke <jef@creatis.insa-lyon.fr>
27 * @date July 30 18:14:53 2007
29 * @brief Compute the correlation ratio between 2 images
34 /* This computes the correlation ratio between 2 images
36 * This class is templated over the FixedImage type and the MovingImage
39 * The fixed and moving images are set via methods SetFixedImage() and
40 * SetMovingImage(). This metric makes use of user specified Transform and
41 * Interpolator. The Transform is used to map points from the fixed image to
42 * the moving image domain. The Interpolator is used to evaluate the image
43 * intensity at user specified geometric points in the moving image.
44 * The Transform and Interpolator are set via methods SetTransform() and
47 * The method GetValue() computes of the mutual information
48 * while method GetValueAndDerivative() computes
49 * both the mutual information and its derivatives with respect to the
50 * transform parameters.
52 * The calculations are based on the method of Alexis Roche.
54 * The number of intensity bins used can be set through the SetNumberOfBins() method
56 * On Initialize(), we find the min and max intensities in the fixed image and compute the width of
57 * the intensity bins. The data structures which hold the bins and related measures are initialised.
61 #include "itkImageToImageMetric.h"
62 #include "itkCovariantVector.h"
69 template < class TFixedImage, class TMovingImage >
70 class ITK_EXPORT CorrelationRatioImageToImageMetric:
71 public ImageToImageMetric< TFixedImage, TMovingImage>
75 /** Standard class typedefs. */
76 typedef CorrelationRatioImageToImageMetric Self;
77 typedef ImageToImageMetric<TFixedImage, TMovingImage > Superclass;
79 typedef SmartPointer<Self> Pointer;
80 typedef SmartPointer<const Self> ConstPointer;
82 /** Method for creation through the object factory. */
85 /** Run-time type information (and related methods). */
86 itkTypeMacro(CorrelationRatioImageToImageMetric, ImageToImageMetric);
89 /** Types transferred from the base class */
90 typedef typename Superclass::RealType RealType;
91 typedef typename Superclass::TransformType TransformType;
92 typedef typename Superclass::TransformPointer TransformPointer;
93 typedef typename Superclass::TransformParametersType TransformParametersType;
94 typedef typename Superclass::TransformJacobianType TransformJacobianType;
95 typedef typename Superclass::GradientPixelType GradientPixelType;
97 typedef typename Superclass::MeasureType MeasureType;
98 typedef typename Superclass::DerivativeType DerivativeType;
99 typedef typename Superclass::FixedImageType FixedImageType;
100 typedef typename Superclass::MovingImageType MovingImageType;
101 typedef typename Superclass::FixedImageConstPointer FixedImageConstPointer;
102 typedef typename Superclass::MovingImageConstPointer MovingImageConstPointer;
106 * Initialize the Metric by
107 * (1) making sure that all the components are present and plugged
108 * together correctly,
109 * (3) allocate memory for bin data structures. */
110 virtual void Initialize(void) throw ( ExceptionObject );
112 /** Get the derivatives of the match measure. */
113 void GetDerivative( const TransformParametersType & parameters,
114 DerivativeType & derivative ) const;
116 /** Get the value for single valued optimizers. */
117 MeasureType GetValue( const TransformParametersType & parameters ) const;
119 /** Get value and derivatives for multiple valued optimizers. */
120 void GetValueAndDerivative( const TransformParametersType & parameters,
121 MeasureType& Value, DerivativeType& Derivative ) const;
123 /** Number of bins to used in the calculation. Typical value is 50. */
124 itkSetClampMacro( NumberOfBins, unsigned long,
125 1, NumericTraits<unsigned long>::max() );
126 itkGetConstReferenceMacro( NumberOfBins, unsigned long);
129 CorrelationRatioImageToImageMetric();
130 virtual ~CorrelationRatioImageToImageMetric() {};
133 CorrelationRatioImageToImageMetric(const Self&); //purposely not implemented
134 void operator=(const Self&); //purposely not implemented
137 //the min and max in the fixed image intensity range
138 double m_FixedImageMin;
140 //The bin size in intensity
141 double m_FixedImageBinSize;
143 //The number of pixels in the fixed image bins are stored in a vector
144 mutable std::vector<unsigned long> m_NumberOfPixelsCountedPerBin;
146 //The mMSVPB and the mSMVPB are stored in vectors of realtype
147 typedef float ValueType;
148 typedef std::vector<ValueType> MeasurePerBinType;
149 mutable MeasurePerBinType m_mMSVPB;
150 mutable MeasurePerBinType m_mSMVPB;
151 unsigned long m_NumberOfBins;
156 } // end namespace itk
158 #ifndef ITK_MANUAL_INSTANTIATION
159 #include "clitkCorrelationRatioImageToImageMetric.txx"