freDifferenceHistogramImageToImageMetric.h

Go to the documentation of this file.
00001 /*=========================================================================
00002  
00003   Program:   F.R.E.E. - flexible registration evaluation engine
00004   Version:   v.1.0.0
00005   Date:      $Date: 2006/09/01 12:00:00 $
00006   Module:    $RCSfile: freDifferenceHistogramImageToImageMetric.h,v $
00007   Language:  C++
00008  
00009  
00010  
00011   Copyright (c) 2007 Ralf o Floca (Department of Medical Informatics,
00012   Institute for Medical Biometry and Informatics, University of Heidelberg,
00013   Germany). All rights reserved.
00014   See FREECopyright.txt or http://www.mi.med.uni-hd.de/free/copyright.htm
00015   for details.
00016  
00017      This software is distributed WITHOUT ANY WARRANTY; without even 
00018      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00019      PURPOSE.  See the above copyright notices for more information.
00020  
00021 =========================================================================*/
00022 #ifndef __freDifferenceHistogramImageToImageMetric_h
00023 #define __freDifferenceHistogramImageToImageMetric_h
00024 
00025 #include "itkHistogram.h"
00026 #include "itkImageToImageMetric.h"
00027 
00028 namespace itk
00029 {
00041 template <class TFixedImage, class TMovingImage, class TDifImage>
00042 class ITK_EXPORT DifferenceHistogramImageToImageMetric :
00043             public ImageToImageMetric<TFixedImage, TMovingImage>
00044 {
00045 public:
00047     typedef DifferenceHistogramImageToImageMetric Self;
00048     typedef ImageToImageMetric<TFixedImage, TMovingImage> Superclass;
00049     typedef SmartPointer<Self>                            Pointer;
00050     typedef SmartPointer<const Self>                      ConstPointer;
00051 
00053     itkTypeMacro(DifferenceHistogramImageToImageMetric, ImageToImageMetric);
00054 
00056     typedef typename Superclass::RealType                   RealType;
00057     typedef typename Superclass::TransformType              TransformType;
00058     typedef typename Superclass::TransformPointer           TransformPointer;
00059     typedef typename Superclass::TransformParametersType
00060     TransformParametersType;
00061     typedef typename Superclass::TransformJacobianType
00062     TransformJacobianType;
00063     typedef typename Superclass::GradientPixelType          GradientPixelType;
00064     typedef typename Superclass::InputPointType             InputPointType;
00065     typedef typename Superclass::OutputPointType            OutputPointType;
00066     typedef typename Superclass::MeasureType                MeasureType;
00067     typedef typename Superclass::DerivativeType             DerivativeType;
00068     typedef typename Superclass::FixedImageType             FixedImageType;
00069     typedef typename Superclass::FixedImageType::PixelType  FixedImagePixelType;
00070     typedef typename Superclass::MovingImageType            MovingImageType;
00071     typedef typename Superclass::MovingImageType::PixelType MovingImagePixelType;
00072     typedef TDifImage                                       DifferenceImageType;
00073     typedef typename DifferenceImageType::PixelType         DifferenceImagePixelType;
00074     typedef typename Superclass::FixedImageConstPointer
00075     FixedImageConstPointer;
00076     typedef typename Superclass::MovingImageConstPointer
00077     MovingImageConstPointer;
00078 
00082     typedef Statistics::Histogram<double, 1> HistogramType;
00083     typedef typename HistogramType::MeasurementVectorType  MeasurementVectorType;
00084     typedef typename HistogramType::SizeType               HistogramSizeType;
00085     typedef typename HistogramType::Pointer                HistogramPointer;
00086 
00088     void Initialize() throw (ExceptionObject);
00089 
00092     itkSetMacro( HistogramSize, HistogramSizeType );
00093 
00095     itkGetConstReferenceMacro( HistogramSize, HistogramSizeType );
00096 
00099     itkSetMacro( UpperBoundIncreaseFactor, double );
00100     itkGetMacro( UpperBoundIncreaseFactor, double );
00101 
00105     itkGetConstReferenceMacro( Histogram, HistogramPointer );
00106 
00110     itkSetMacro( UseMask, bool );
00111     itkGetMacro( UseMask, bool );
00112 
00113     itkGetConstMacro( MaskedMaximum, FixedImagePixelType );
00114     itkSetMacro( MaskedMaximum, FixedImagePixelType );
00115     itkGetConstMacro( MaskedMinimum, FixedImagePixelType );
00116     itkSetMacro( MaskedMinimum, FixedImagePixelType );
00117 
00119     itkSetMacro( DerivativeStepLength, double );
00120 
00122     itkGetMacro( DerivativeStepLength, double );
00123 
00125     MeasureType GetValue(const TransformParametersType& parameters) const;
00126 
00128     void GetDerivative(const TransformParametersType & parameters,
00129                        DerivativeType & derivative) const;
00130 
00132     void GetValueAndDerivative(const TransformParametersType & parameters,
00133                                MeasureType& Value,
00134                                DerivativeType& Derivative) const;
00135 
00136 protected:
00139     DifferenceHistogramImageToImageMetric();
00140     virtual ~DifferenceHistogramImageToImageMetric()
00141     {}
00142     ;
00143 
00145     HistogramSizeType m_HistogramSize;
00147     double m_UpperBoundIncreaseFactor;
00148 
00150     mutable MeasurementVectorType m_LowerBound;
00152     mutable MeasurementVectorType m_UpperBound;
00153 
00156     void ComputeHistogram(const TransformParametersType & parameters,
00157                           HistogramType& histogram) const;
00160     void ComputeHistogram(const TransformParametersType & parameters,
00161                           unsigned int parameter,
00162                           double step,
00163                           HistogramType& histogram) const;
00167     void CopyHistogram(HistogramType& target, HistogramType& source) const;
00168 
00171     virtual MeasureType EvaluateMeasure(HistogramType& histogram) const = 0;
00172 
00173     inline bool IsMaskedValue(const RealType& value) const
00174     {
00175         return (value<=m_MaskedMaximum) && (value>=m_MaskedMinimum);
00176     };
00177 
00179     void PrintSelf(std::ostream& os, Indent indent) const;
00180 
00181 private:
00182     DifferenceHistogramImageToImageMetric(const Self&); //purposely not implemented
00183     void operator=(const Self&); //purposely not implemented
00184 
00186     FixedImagePixelType m_MaskedMaximum;
00187     FixedImagePixelType m_MaskedMinimum;
00188 
00192     bool m_UseMask;
00193 
00195     double m_DerivativeStepLength;
00196 
00199     HistogramPointer  m_Histogram;
00200 };
00201 
00202 } // end namespace itk
00203 
00204 #ifndef ITK_MANUAL_INSTANTIATION
00205 #include "freDifferenceHistogramImageToImageMetric.txx"
00206 #endif
00207 
00208 #endif // __freDifferenceHistogramImageToImageMetric_h

Generated at Sat Oct 13 15:47:30 2007 for f.r.e.e. - Flexible Registration and Evaluation Engine by doxygen 1.5.3 written by Dimitri van Heesch, © 1997-2000