00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __MaximumRatioDecisionRule_h
00018 #define __MaximumRatioDecisionRule_h
00019
00020 #include "itkWin32Header.h"
00021
00022 #include <vector>
00023 #include "vnl/vnl_matrix.h"
00024
00025 #include "itkNumericTraits.h"
00026 #include "itkDecisionRuleBase.h"
00027
00028 namespace itk {
00029
00044 class ITKCommon_EXPORT MaximumRatioDecisionRule :
00045 public DecisionRuleBase
00046 {
00047 public:
00049 typedef MaximumRatioDecisionRule Self ;
00050 typedef DecisionRuleBase Superclass;
00051 typedef SmartPointer<Self> Pointer;
00052
00054 itkTypeMacro(MaximumRatioDecisionRule, DecisionRuleBase);
00055
00057 itkNewMacro(Self) ;
00058
00059 typedef float APrioriValueType ;
00060 typedef std::vector< APrioriValueType > APrioriVectorType ;
00061
00062 unsigned int Evaluate(std::vector< double > &discriminantScores) ;
00063
00065 void SetAPriori(APrioriVectorType& values) ;
00066
00067 protected:
00068 MaximumRatioDecisionRule() ;
00069 virtual ~MaximumRatioDecisionRule() {}
00070
00071 private:
00073 unsigned int m_NumberOfClasses ;
00074
00076 vnl_matrix< double > m_APrioriRatioMatrix ;
00077 } ;
00078
00079 inline unsigned int
00080 MaximumRatioDecisionRule::Evaluate(std::vector< double >
00081 &discriminantScores)
00082 {
00083 unsigned int i, j ;
00084 double temp ;
00085
00086 for (i = 0 ; i < m_NumberOfClasses ; i++)
00087 {
00088 j = 0 ;
00089 while ( j < m_NumberOfClasses )
00090 {
00091 if ( j != i )
00092 {
00093 if ( discriminantScores[j] != 0.0 )
00094 {
00095 temp = discriminantScores[i] / discriminantScores[j] ;
00096 }
00097 else
00098 {
00099 temp = NumericTraits< double >::max() ;
00100 }
00101
00102 if ( temp < m_APrioriRatioMatrix.get(i,j) )
00103 {
00104 break ;
00105 }
00106 }
00107
00108 ++j ;
00109
00110 if ( j == m_NumberOfClasses )
00111 {
00112 return i ;
00113 }
00114 }
00115 }
00116
00117 return i ;
00118 }
00119
00120 }
00121 #endif
00122
00123
00124
00125
00126
00127
00128