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: 2003/09/10 14:29:37 $
00007   Version:   $Revision: 1.9 $
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 __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 ; } 
00085 
00087   void SetSigma(double sigma) { m_Sigma = sigma ; }
00088   double GetSigma() { return m_Sigma ; }
00090 
00091 private:
00092   double m_Mean ;
00093   double m_Sigma ;
00094 } ; // end of class 
00095 
00096 class CompositeValleyFunction : public CacheableScalarFunction
00097 {
00098 public:
00099 
00101   typedef CacheableScalarFunction Superclass;
00102 
00104   typedef  Superclass::MeasureType          MeasureType;
00105   typedef  Superclass::MeasureArrayType     MeasureArrayType;
00106 
00108   CompositeValleyFunction( const MeasureArrayType & classMeans, 
00109                            const MeasureArrayType & classSigmas );
00110 
00112   virtual ~CompositeValleyFunction() {}
00113 
00115   double GetUpperBound() { return m_UpperBound ; }
00116 
00118   double GetLowerBound() { return m_LowerBound ; }
00119 
00122   MeasureType operator() (MeasureType x)
00123   {
00124     if (x > m_UpperBound || x < m_LowerBound) { return 1; }
00125 
00126     if (!this->IsCacheAvailable()) 
00127       { return this->Evaluate(x); } 
00128     else 
00129       { return GetCachedValue(x); }
00130   }
00131 
00133   inline MeasureType Evaluate(MeasureType x) 
00134   {
00135     MeasureType res = 1;
00136 
00137     for (unsigned int k = 0 ; k < m_Targets.size() ; k++)
00138       {
00139       res *= valley( ( x - m_Targets[k].GetMean() ) /
00140                      m_Targets[k].GetSigma() );
00141       }
00142     
00143     return res;
00144   }  
00145 
00147   inline MeasureType valley(MeasureType d) 
00148   { return 1 - 1 / (1+d*d/3); }
00149 
00150 protected:
00151   void AddNewClass(double mean, double sigma)
00152   {
00153     TargetClass aClass(mean, sigma) ;
00154     m_Targets.push_back(aClass) ;
00155   }
00156 
00158   void Initialize() ;
00159 
00160 private:
00162   std::vector<TargetClass> m_Targets;  
00163 
00166   double m_UpperBound ;
00167 
00170   double m_LowerBound ;
00171 
00172 } ; // end of class
00173 
00174 } // end of namespace itk
00175 #endif
00176 

Generated at Sun Mar 11 23:52:43 2007 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000