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

itkCompositeValleyFunction.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkCompositeValleyFunction.h,v $
00005   Language:  C++
00006   Date:      $Date: 2002/02/26 14:26:28 $
00007   Version:   $Revision: 1.6 $
00008 
00009   Copyright (c) 2002 Insight 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 __itkCompositeValleyFunction_h
00018 #define __itkCompositeValleyFunction_h
00019 
00020 #include "itkArray.h"
00021 #include "itkCacheableScalarFunction.h"
00022 #include <vector>
00023 
00024 namespace itk {
00025 
00071 class TargetClass
00072 {
00073 public:
00075   TargetClass(double mean, double sigma) 
00076     { 
00077     m_Mean = mean ;
00078     m_Sigma = sigma ;
00079     }
00080   
00082   void SetMean(double mean) { m_Mean = mean ; }  
00083   double GetMean() { return m_Mean ; } 
00084   
00086   void SetSigma(double sigma) { m_Sigma = sigma ; }
00087   double GetSigma() { return m_Sigma ; }
00088     
00089 private:
00090   double m_Mean ;
00091   double m_Sigma ;
00092 } ; // end of class 
00093 
00094 class CompositeValleyFunction : public CacheableScalarFunction
00095 {
00096 public:
00097 
00099   typedef CacheableScalarFunction Superclass;
00100   
00102   typedef  Superclass::MeasureType          MeasureType;
00103   typedef  Superclass::MeasureArrayType     MeasureArrayType;
00104 
00106   CompositeValleyFunction( const MeasureArrayType & classMeans, 
00107                            const MeasureArrayType & classSigmas );
00108 
00110   virtual ~CompositeValleyFunction() {}
00111 
00113   double GetHigherBound() { return m_HigherBound ; }
00114 
00116   double GetLowerBound() { return m_LowerBound ; }
00117 
00120   MeasureType operator() (MeasureType x)
00121   {
00122     if (x > m_HigherBound || x < m_LowerBound) { return 1; }
00123 
00124     if (!this->IsCacheAvailable()) 
00125       { return this->Evaluate(x); } 
00126     else 
00127       { return GetCachedValue(x); }
00128   }
00129 
00131   inline MeasureType valley(MeasureType d) 
00132     { return 1 - 1 / (1+d*d/3); }
00133 
00134 protected:
00135   void AddNewClass(double mean, double sigma)
00136   {
00137     TargetClass aClass(mean, sigma) ;
00138     m_Targets.push_back(aClass) ;
00139   }
00140 
00142   void Initialize() ;
00143 
00145   inline MeasureType Evaluate(MeasureType x) 
00146   {
00147     MeasureType res = 1;
00148     
00149     for (unsigned int k = 0 ; k < m_Targets.size() ; k++)
00150       {
00151       res *= valley( ( x - m_Targets[k].GetMean() ) /
00152                      m_Targets[k].GetSigma() );
00153       }
00154     
00155     return res;
00156   }  
00157 
00158 private:
00160   std::vector<TargetClass> m_Targets;  
00161 
00164   double m_HigherBound ;
00165 
00168   double m_LowerBound ;
00169 
00170 } ; // end of class
00171 
00172 } // end of namespace itk
00173 #endif

Generated at Fri May 21 01:14:33 2004 for ITK by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2000