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

Review/Statistics/itkDistanceMetric.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkDistanceMetric.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-05-02 05:43:55 $
00007   Version:   $Revision: 1.1 $
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 __itkDistanceMetric_h
00018 #define __itkDistanceMetric_h
00019 
00020 #include "itkArray.h"
00021 #include "itkFunctionBase.h"
00022 #include "itkMeasurementVectorTraits.h"
00023 
00024 namespace itk  { 
00025 namespace Statistics  {
00026 
00044 template< class TVector >
00045 class ITK_EXPORT DistanceMetric : public FunctionBase< TVector, double  >
00046 {
00047 public:
00049   typedef DistanceMetric                    Self;
00050   typedef FunctionBase< TVector, double >   Superclass;
00051   typedef SmartPointer< Self >              Pointer;
00052   typedef SmartPointer<const Self>          ConstPointer;
00053 
00055   typedef TVector                           MeasurementVectorType;
00056 
00060   typedef unsigned int                      MeasurementVectorSizeType;
00061 
00063   itkTypeMacro(DistanceMetric, FunctionBase);
00064 
00065   typedef Array< double > OriginType;
00066 
00073   void SetOrigin(const OriginType& x);
00074   itkGetConstReferenceMacro(Origin, OriginType);
00076 
00079   virtual double Evaluate(const MeasurementVectorType &x) const = 0;
00080 
00086   virtual double Evaluate(const MeasurementVectorType &x1, 
00087                           const MeasurementVectorType &x2) const = 0;
00088 
00090   virtual void SetMeasurementVectorSize( MeasurementVectorSizeType s )
00091     {
00092     // Test whether the vector type is resizable or not
00093     MeasurementVectorType m;
00094     if( MeasurementVectorTraits::IsResizable( m ) )
00095       {
00096       // then this is a resizable vector type
00097       //
00098       // if the new size is the same as the previou size, just return
00099       if( s == this->m_MeasurementVectorSize )
00100         {
00101         return;
00102         }
00103       else
00104         {
00105         this->m_MeasurementVectorSize = s;
00106         this->Modified();
00107         }
00108       }
00109     else
00110       {
00111       // If this is a non-resizable vector type
00112       MeasurementVectorType m3;
00113       MeasurementVectorSizeType defaultLength = MeasurementVectorTraits::GetLength( m3 );
00114       // and the new length is different from the default one, then throw an exception
00115       if( defaultLength != s )
00116         {
00117         itkExceptionMacro("Attempting to change the measurement \
00118                            vector size of a non-resizable vector type");
00119         }
00120       }
00121     }
00123 
00125   itkGetConstMacro( MeasurementVectorSize, MeasurementVectorSizeType ); 
00126 
00127 protected:
00128   DistanceMetric();
00129   virtual ~DistanceMetric() {}
00130   void PrintSelf(std::ostream& os, Indent indent) const;
00131 
00132 private:
00133 
00134   OriginType m_Origin;
00135 
00137   MeasurementVectorSizeType       m_MeasurementVectorSize;
00138 }; // end of class
00139 
00140 } // end of namespace Statistics 
00141 } // end of namespace itk
00142 
00143 #ifndef ITK_MANUAL_INSTANTIATION
00144 #include "itkDistanceMetric.txx"
00145 #endif
00146 
00147 #endif
00148 

Generated at Tue Sep 15 02:49:26 2009 for ITK by doxygen 1.5.8 written by Dimitri van Heesch, © 1997-2000