00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
#ifndef __itkMutualInformationImageToImageMetric_h
00018
#define __itkMutualInformationImageToImageMetric_h
00019
00020
#include "itkImageToImageMetric.h"
00021
#include "itkCovariantVector.h"
00022
#include "itkPoint.h"
00023
00024
#include "itkIndex.h"
00025
#include "itkKernelFunction.h"
00026
#include "itkCentralDifferenceImageFunction.h"
00027
00028
namespace itk
00029 {
00030
00089
template <
class TFixedImage,
class TMovingImage >
00090 class ITK_EXPORT MutualInformationImageToImageMetric :
00091
public ImageToImageMetric< TFixedImage, TMovingImage >
00092 {
00093
public:
00094
00096 typedef MutualInformationImageToImageMetric
Self;
00097 typedef ImageToImageMetric< TFixedImage, TMovingImage > Superclass;
00098 typedef SmartPointer<Self> Pointer;
00099 typedef SmartPointer<const Self> ConstPointer;
00100
00102
itkNewMacro(
Self);
00103
00105
itkTypeMacro(MutualInformationImageToImageMetric,
ImageToImageMetric);
00106
00108 typedef typename Superclass::TransformType
TransformType;
00109 typedef typename Superclass::TransformPointer
TransformPointer;
00110 typedef typename Superclass::TransformJacobianType
TransformJacobianType;
00111 typedef typename Superclass::InterpolatorType
InterpolatorType;
00112 typedef typename Superclass::MeasureType
MeasureType;
00113 typedef typename Superclass::DerivativeType
DerivativeType;
00114 typedef typename Superclass::ParametersType
ParametersType;
00115 typedef typename Superclass::FixedImageType
FixedImageType;
00116 typedef typename Superclass::MovingImageType
MovingImageType;
00117 typedef typename Superclass::FixedImageConstPointer
FixedImageConstPointer;
00118 typedef typename Superclass::MovingImageConstPointer
MovingImageCosntPointer;
00119
00121 typedef typename FixedImageType::IndexType
FixedImageIndexType;
00122 typedef typename FixedImageIndexType::IndexValueType
FixedImageIndexValueType;
00123 typedef typename MovingImageType::IndexType
MovingImageIndexType;
00124 typedef typename TransformType::InputPointType
FixedImagePointType;
00125 typedef typename TransformType::OutputPointType
MovingImagePointType;
00126
00128
itkStaticConstMacro(MovingImageDimension,
unsigned int,
00129 MovingImageType::ImageDimension);
00130
00132
void GetDerivative(
00133
const ParametersType& parameters,
00134
DerivativeType & Derivative )
const;
00135
00137
MeasureType GetValue(
const ParametersType& parameters )
const;
00138
00140
void GetValueAndDerivative(
const ParametersType& parameters,
00141
MeasureType& Value,
DerivativeType& Derivative )
const;
00142
00147
void SetNumberOfSpatialSamples(
unsigned int num );
00148
00150
itkGetConstMacro( NumberOfSpatialSamples,
unsigned int );
00151
00157
itkSetClampMacro( MovingImageStandardDeviation,
double,
00158
NumericTraits<double>::NonpositiveMin(),
NumericTraits<double>::max() );
00159
itkGetConstMacro( MovingImageStandardDeviation,
double );
00160
00166
itkSetClampMacro( FixedImageStandardDeviation,
double,
00167
NumericTraits<double>::NonpositiveMin(),
NumericTraits<double>::max() );
00168
itkGetMacro( FixedImageStandardDeviation,
double );
00169
00172
itkSetObjectMacro(
KernelFunction,
KernelFunction );
00173
itkGetObjectMacro(
KernelFunction,
KernelFunction );
00174
00175
protected:
00176 MutualInformationImageToImageMetric();
00177
virtual ~MutualInformationImageToImageMetric() {};
00178
void PrintSelf(std::ostream& os,
Indent indent)
const;
00179
00180 private:
00181 MutualInformationImageToImageMetric(
const Self&);
00182
void operator=(
const Self&);
00183
00186
class SpatialSample
00187 {
00188
public:
00189 SpatialSample():FixedImageValue(0.0),MovingImageValue(0.0)
00190 { FixedImagePointValue.Fill( 0.0 ); }
00191 ~SpatialSample(){};
00192
00193 FixedImagePointType FixedImagePointValue;
00194
double FixedImageValue;
00195
double MovingImageValue;
00196 };
00197
00199
typedef std::vector<SpatialSample> SpatialSampleContainer;
00200
00203
mutable SpatialSampleContainer m_SampleA;
00204
00207
mutable SpatialSampleContainer m_SampleB;
00208
00209
unsigned int m_NumberOfSpatialSamples;
00210
double m_MovingImageStandardDeviation;
00211
double m_FixedImageStandardDeviation;
00212
typename KernelFunction::Pointer m_KernelFunction;
00213
double m_MinProbability;
00214
00216
void SampleFixedImageDomain( SpatialSampleContainer& samples )
const;
00217
00221
void CalculateDerivatives(
const FixedImagePointType& , DerivativeType& ) const;
00222
00224 static
void ReinitializeSeed();
00225 static
void ReinitializeSeed(
int);
00226
00227 typedef typename
Superclass::CoordinateRepresentationType
00228 CoordinateRepresentationType;
00229 typedef CentralDifferenceImageFunction< MovingImageType,
00230 CoordinateRepresentationType > DerivativeFunctionType;
00231
00232 typename DerivativeFunctionType::
Pointer m_DerivativeCalculator;
00233
00234 };
00235
00236 }
00237
00238 #ifndef ITK_MANUAL_INSTANTIATION
00239 #include "itkMutualInformationImageToImageMetric.txx"
00240 #endif
00241
00242 #endif
00243