00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkHistogramImageToImageMetric_h
00018 #define __itkHistogramImageToImageMetric_h
00019
00020 #include "itkHistogram.h"
00021 #include "itkImageToImageMetric.h"
00022
00023 namespace itk
00024 {
00035 template <class TFixedImage, class TMovingImage>
00036 class ITK_EXPORT HistogramImageToImageMetric :
00037 public ImageToImageMetric<TFixedImage, TMovingImage>
00038 {
00039 public:
00041 typedef HistogramImageToImageMetric Self;
00042 typedef ImageToImageMetric<TFixedImage, TMovingImage> Superclass;
00043 typedef SmartPointer<Self> Pointer;
00044 typedef SmartPointer<const Self> ConstPointer;
00045
00047 itkTypeMacro(HistogramImageToImageMetric, ImageToImageMetric);
00048
00050 typedef typename Superclass::RealType RealType;
00051 typedef typename Superclass::TransformType TransformType;
00052 typedef typename Superclass::TransformPointer TransformPointer;
00053 typedef typename Superclass::TransformParametersType
00054 TransformParametersType;
00055 typedef typename Superclass::TransformJacobianType
00056 TransformJacobianType;
00057 typedef typename Superclass::GradientPixelType GradientPixelType;
00058 typedef typename Superclass::InputPointType InputPointType;
00059 typedef typename Superclass::OutputPointType OutputPointType;
00060 typedef typename Superclass::MeasureType MeasureType;
00061 typedef typename Superclass::DerivativeType DerivativeType;
00062 typedef typename Superclass::FixedImageType FixedImageType;
00063 typedef typename Superclass::FixedImageType::PixelType FixedImagePixelType;
00064 typedef typename Superclass::MovingImageType MovingImageType;
00065 typedef typename Superclass::MovingImageType::PixelType MovingImagePixelType;
00066 typedef typename Superclass::FixedImageConstPointer
00067 FixedImageConstPointerType;
00068 typedef typename Superclass::MovingImageConstPointer
00069 MovingImageConstPointerType;
00070
00074 typedef Statistics::Histogram<double, 2> HistogramType;
00075 typedef typename HistogramType::MeasurementVectorType MeasurementVectorType;
00076 typedef typename HistogramType::SizeType HistogramSizeType;
00077 typedef typename HistogramType::Pointer HistogramPointer;
00078
00080 void Initialize() throw (ExceptionObject);
00081
00084 itkSetMacro( HistogramSize, HistogramSizeType );
00085
00087 itkGetConstReferenceMacro( HistogramSize, HistogramSizeType );
00088
00091 itkSetMacro( UpperBoundIncreaseFactor, double );
00092 itkGetMacro( UpperBoundIncreaseFactor, double );
00094
00096 itkSetMacro( PaddingValue, FixedImagePixelType );
00097
00099 itkGetConstReferenceMacro( PaddingValue, FixedImagePixelType );
00100
00104 itkGetConstReferenceMacro( Histogram, HistogramPointer );
00105
00109 itkSetMacro( UsePaddingValue, bool );
00110 itkGetMacro( UsePaddingValue, bool );
00112
00114 itkSetMacro( DerivativeStepLength, double );
00115
00117 itkGetMacro( DerivativeStepLength, double );
00118
00120 typedef Array<double> ScalesType;
00121
00123 itkSetMacro( DerivativeStepLengthScales, ScalesType );
00124
00126 itkGetConstReferenceMacro(DerivativeStepLengthScales, ScalesType);
00127
00129 MeasureType GetValue(const TransformParametersType& parameters) const;
00130
00132 void GetDerivative(const TransformParametersType & parameters,
00133 DerivativeType & derivative) const;
00134
00136 void GetValueAndDerivative(const TransformParametersType & parameters,
00137 MeasureType& Value,
00138 DerivativeType& Derivative) const;
00139
00143 void SetLowerBound( const MeasurementVectorType & bound );
00144
00148 void SetUpperBound( const MeasurementVectorType & bound );
00149
00150
00151 protected:
00154 HistogramImageToImageMetric();
00155 virtual ~HistogramImageToImageMetric() {};
00157
00159 HistogramSizeType m_HistogramSize;
00160
00162 mutable MeasurementVectorType m_LowerBound;
00163
00165 mutable MeasurementVectorType m_UpperBound;
00166
00168 double m_UpperBoundIncreaseFactor;
00169
00172 bool m_LowerBoundSetByUser;
00173
00176 bool m_UpperBoundSetByUser;
00177
00180 void ComputeHistogram(const TransformParametersType & parameters,
00181 HistogramType& histogram) const;
00182
00185 void ComputeHistogram(const TransformParametersType & parameters,
00186 unsigned int parameter,
00187 double step,
00188 HistogramType& histogram) const;
00189
00193 void CopyHistogram(HistogramType& target, HistogramType& source) const;
00194
00197 virtual MeasureType EvaluateMeasure(HistogramType& histogram) const = 0;
00198
00200 void PrintSelf(std::ostream& os, Indent indent) const;
00201
00202 private:
00203 HistogramImageToImageMetric(const Self&);
00204 void operator=(const Self&);
00205
00207 FixedImagePixelType m_PaddingValue;
00208
00212 bool m_UsePaddingValue;
00213
00215 double m_DerivativeStepLength;
00216
00218 ScalesType m_DerivativeStepLengthScales;
00219
00222 HistogramPointer m_Histogram;
00223
00224 };
00225
00226 }
00227
00228 #ifndef ITK_MANUAL_INSTANTIATION
00229 #include "itkHistogramImageToImageMetric.txx"
00230 #endif
00231
00232 #endif // __itkHistogramImageToImageMetric_h
00233