Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkMattesMutualInformationImageToImageMetric.h

Go to the documentation of this file.
00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkMattesMutualInformationImageToImageMetric.h,v $ 00005 Language: C++ 00006 Date: $Date: 2003/10/10 17:31:30 $ 00007 Version: $Revision: 1.9 $ 00008 00009 Copyright (c) Insight Software Consortium. All rights reserved. 00010 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 #ifndef __itkMattesMutualInformationImageToImageMetric_h 00018 #define __itkMattesMutualInformationImageToImageMetric_h 00019 00020 #include "itkImageToImageMetric.h" 00021 #include "itkCovariantVector.h" 00022 #include "itkPoint.h" 00023 #include "itkIndex.h" 00024 #include "itkBSplineKernelFunction.h" 00025 #include "itkBSplineDerivativeKernelFunction.h" 00026 #include "itkCentralDifferenceImageFunction.h" 00027 #include "itkBSplineInterpolateImageFunction.h" 00028 #include "itkBSplineDeformableTransform.h" 00029 00030 00031 namespace itk 00032 { 00033 00110 template <class TFixedImage,class TMovingImage > 00111 class ITK_EXPORT MattesMutualInformationImageToImageMetric : 00112 public ImageToImageMetric< TFixedImage, TMovingImage > 00113 { 00114 public: 00115 00117 typedef MattesMutualInformationImageToImageMetric Self; 00118 typedef ImageToImageMetric< TFixedImage, TMovingImage > Superclass; 00119 typedef SmartPointer<Self> Pointer; 00120 typedef SmartPointer<const Self> ConstPointer; 00121 00123 itkNewMacro(Self); 00124 00126 itkTypeMacro(MattesMutualInformationImageToImageMetric, ImageToImageMetric); 00127 00129 typedef typename Superclass::TransformType TransformType; 00130 typedef typename Superclass::TransformPointer TransformPointer; 00131 typedef typename Superclass::TransformJacobianType TransformJacobianType; 00132 typedef typename Superclass::InterpolatorType InterpolatorType; 00133 typedef typename Superclass::MeasureType MeasureType; 00134 typedef typename Superclass::DerivativeType DerivativeType; 00135 typedef typename Superclass::ParametersType ParametersType; 00136 typedef typename Superclass::FixedImageType FixedImageType; 00137 typedef typename Superclass::MovingImageType MovingImageType; 00138 typedef typename Superclass::FixedImageConstPointer FixedImageConstPointer; 00139 typedef typename Superclass::MovingImageConstPointer MovingImageCosntPointer; 00140 typedef typename Superclass::CoordinateRepresentationType 00141 CoordinateRepresentationType; 00142 00144 typedef typename FixedImageType::IndexType FixedImageIndexType; 00145 typedef typename FixedImageIndexType::IndexValueType FixedImageIndexValueType; 00146 typedef typename MovingImageType::IndexType MovingImageIndexType; 00147 typedef typename TransformType::InputPointType FixedImagePointType; 00148 typedef typename TransformType::OutputPointType MovingImagePointType; 00149 00151 itkStaticConstMacro( MovingImageDimension, unsigned int, 00152 MovingImageType::ImageDimension ); 00153 00161 virtual void Initialize(void) throw ( ExceptionObject ); 00162 00164 void GetDerivative( 00165 const ParametersType& parameters, 00166 DerivativeType & Derivative ) const; 00167 00169 MeasureType GetValue( const ParametersType& parameters ) const; 00170 00172 void GetValueAndDerivative( const ParametersType& parameters, 00173 MeasureType& Value, DerivativeType& Derivative ) const; 00174 00176 itkSetClampMacro( NumberOfSpatialSamples, unsigned long, 00177 1, NumericTraits<unsigned long>::max() ); 00178 itkGetConstMacro( NumberOfSpatialSamples, unsigned long); 00179 00181 itkSetClampMacro( NumberOfHistogramBins, unsigned long, 00182 1, NumericTraits<unsigned long>::max() ); 00183 itkGetConstMacro( NumberOfHistogramBins, unsigned long); 00184 00185 protected: 00186 00187 MattesMutualInformationImageToImageMetric(); 00188 virtual ~MattesMutualInformationImageToImageMetric() {}; 00189 void PrintSelf(std::ostream& os, Indent indent) const; 00190 00194 class FixedImageSpatialSample 00195 { 00196 public: 00197 FixedImageSpatialSample():FixedImageValue(0.0) 00198 { FixedImagePointValue.Fill(0.0); } 00199 ~FixedImageSpatialSample() {}; 00200 00201 FixedImagePointType FixedImagePointValue; 00202 double FixedImageValue; 00203 }; 00204 00206 typedef std::vector<FixedImageSpatialSample> 00207 FixedImageSpatialSampleContainer; 00208 00210 FixedImageSpatialSampleContainer m_FixedImageSamples; 00211 00213 virtual void SampleFixedImageDomain( 00214 FixedImageSpatialSampleContainer& samples); 00215 00218 virtual void TransformPoint( const FixedImagePointType& fixedImagePoint, 00219 MovingImagePointType& mappedPoint, bool& sampleWithinSupportRegion, 00220 double& movingImageValue ) const; 00221 00222 private: 00223 00224 MattesMutualInformationImageToImageMetric(const Self&); //purposely not implemented 00225 void operator=(const Self&); //purposely not implemented 00226 00227 00229 typedef float PDFValueType; 00230 typedef std::vector<PDFValueType> MarginalPDFType; 00231 00233 mutable MarginalPDFType m_FixedImageMarginalPDF; 00234 00236 mutable MarginalPDFType m_MovingImageMarginalPDF; 00237 00239 typedef Image<PDFValueType,2> JointPDFType; 00240 typedef Image<PDFValueType,3> JointPDFDerivativesType; 00241 typedef JointPDFType::IndexType JointPDFIndexType; 00242 typedef JointPDFType::PixelType JointPDFValueType; 00243 typedef JointPDFType::RegionType JointPDFRegionType; 00244 typedef JointPDFType::SizeType JointPDFSizeType; 00245 typedef JointPDFDerivativesType::IndexType JointPDFDerivativesIndexType; 00246 typedef JointPDFDerivativesType::PixelType JointPDFDerivativesValueType; 00247 typedef JointPDFDerivativesType::RegionType JointPDFDerivativesRegionType; 00248 typedef JointPDFDerivativesType::SizeType JointPDFDerivativesSizeType; 00249 00251 typename JointPDFType::Pointer m_JointPDF; 00252 typename JointPDFDerivativesType::Pointer m_JointPDFDerivatives; 00253 00254 unsigned long m_NumberOfSpatialSamples; 00255 unsigned long m_NumberOfParameters; 00256 00258 unsigned long m_NumberOfHistogramBins; 00259 double m_MovingImageNormalizedMin; 00260 double m_FixedImageNormalizedMin; 00261 double m_MovingImageTrueMin; 00262 double m_MovingImageTrueMax; 00263 double m_FixedImageBinSize; 00264 double m_MovingImageBinSize; 00265 00267 typedef BSplineKernelFunction<3> CubicBSplineFunctionType; 00268 typedef BSplineDerivativeKernelFunction<3> 00269 CubicBSplineDerivativeFunctionType; 00270 00272 typename CubicBSplineFunctionType::Pointer m_CubicBSplineKernel; 00273 typename CubicBSplineDerivativeFunctionType::Pointer 00274 m_CubicBSplineDerivativeKernel; 00275 00282 typedef CovariantVector< double, 00283 itkGetStaticConstMacro(MovingImageDimension) > ImageDerivativesType; 00284 00286 virtual void ComputeImageDerivatives( const MovingImagePointType& mappedPoint, 00287 ImageDerivativesType& gradient ) const; 00288 00290 bool m_InterpolatorIsBSpline; 00291 00293 typedef 00294 BSplineInterpolateImageFunction<MovingImageType, 00295 CoordinateRepresentationType> BSplineInterpolatorType; 00296 00298 typename BSplineInterpolatorType::Pointer m_BSplineInterpolator; 00299 00301 typedef CentralDifferenceImageFunction<MovingImageType, 00302 CoordinateRepresentationType> DerivativeFunctionType; 00303 00305 typename DerivativeFunctionType::Pointer m_DerivativeCalculator; 00306 00307 00309 virtual void ComputePDFDerivatives( const FixedImagePointType& fixedImagePoint, 00310 int fixedImageParzenWindowIndex, int movingImageParzenWindowIndex, 00311 const ImageDerivativesType& movingImageGradientValue, 00312 double cubicBSplineDerivativeValue ) const; 00313 00323 bool m_TransformIsBSpline; 00324 00326 long m_NumParametersPerDim; 00327 00331 unsigned long m_NumBSplineWeights; 00332 00334 itkStaticConstMacro( FixedImageDimension, unsigned int, 00335 FixedImageType::ImageDimension ); 00336 00340 enum { DeformationSplineOrder = 3 }; 00341 00345 typedef BSplineDeformableTransform< 00346 CoordinateRepresentationType, 00347 ::itk::GetImageDimension<FixedImageType>::ImageDimension, 00348 DeformationSplineOrder> BSplineTransformType; 00349 typedef typename BSplineTransformType::WeightsType 00350 BSplineTransformWeightsType; 00351 typedef typename BSplineTransformType::ParameterIndexArrayType 00352 BSplineTransformIndexArrayType; 00353 00357 typename BSplineTransformType::Pointer m_BSplineTransform; 00358 mutable BSplineTransformWeightsType m_BSplineTransformWeights; 00359 mutable BSplineTransformIndexArrayType m_BSplineTransformIndices; 00360 00361 }; 00362 00363 } // end namespace itk 00364 00365 #ifndef ITK_MANUAL_INSTANTIATION 00366 #include "itkMattesMutualInformationImageToImageMetric.txx" 00367 #endif 00368 00369 #endif 00370

Generated at Sun Apr 1 02:37:19 2007 for ITK by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2000