#
source:
foam/trunk/vision/src/LDAClassifier.h
@
85

Revision 85, 2.6 KB checked in by dave, 11 years ago (diff) |
---|

Line | |
---|---|

1 | // Copyright (C) 2009 foam |

2 | // |

3 | // This program is free software; you can redistribute it and/or modify |

4 | // it under the terms of the GNU General Public License as published by |

5 | // the Free Software Foundation; either version 2 of the License, or |

6 | // (at your option) any later version. |

7 | // |

8 | // This program is distributed in the hope that it will be useful, |

9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |

10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |

11 | // GNU General Public License for more details. |

12 | // |

13 | // You should have received a copy of the GNU General Public License |

14 | // along with this program; if not, write to the Free Software |

15 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |

16 | |

17 | #include <vector> |

18 | #include <map> |

19 | #include <set> |

20 | #include "Vector.h" |

21 | #include "Matrix.h" |

22 | |

23 | #ifndef FOAM_LDA_CLASSIFIER |

24 | #define FOAM_LDA_CLASSIFIER |

25 | |

26 | // A linear discriminant analysis classifier for arbitrary data sets |

27 | |

28 | template<class T> |

29 | class LDAClassifier |

30 | { |

31 | public: |

32 | LDAClassifier(unsigned int FeatureSize); |

33 | ~LDAClassifier(); |

34 | |

35 | class Feature |

36 | { |

37 | public: |

38 | Vector<T> m_Data; |

39 | int m_Class; |

40 | }; |

41 | |

42 | void AddFeature(const Feature &f); |

43 | int Classify(const Feature &f); |

44 | |

45 | private: |

46 | |

47 | void CalcClasses(); |

48 | void CalcGlobalMean(); |

49 | void CalcClassMeans(); |

50 | void CalcMeanCorrected(); |

51 | void CalcCovariance(); |

52 | void CalcPooledCovariance(); |

53 | void CalcPriorProbablity(); |

54 | |

55 | unsigned int m_FeatureSize; |

56 | std::vector<Feature > m_Features; |

57 | |

58 | std::set<int> m_Classes; |

59 | Vector<T> m_GlobalMean; |

60 | std::map<int,Vector<T> > m_ClassMeans; |

61 | std::map<int,Matrix<T> > m_MeanCorrected; |

62 | std::map<int,Matrix<T> > m_Covariance; |

63 | Matrix<T> m_PooledCovariance; |

64 | Vector<T> m_PriorProbability; |

65 | |

66 | }; |

67 | |

68 | template<class T> |

69 | LDAClassifier<T>::LDAClassifier(unsigned int FeatureSize) |

70 | { |

71 | } |

72 | |

73 | template<class T> |

74 | LDAClassifier<T>::~LDAClassifier() |

75 | { |

76 | } |

77 | |

78 | template<class T> |

79 | void LDAClassifier<T>::AddFeature(const Feature &f) |

80 | { |

81 | m_Features.push_back(f); |

82 | } |

83 | |

84 | template<class T> |

85 | int LDAClassifier<T>::Classify(const Feature &f) |

86 | { |

87 | return 0; |

88 | } |

89 | |

90 | template<class T> |

91 | void LDAClassifier<T>::CalcClasses() |

92 | { |

93 | m_Classes.clear(); |

94 | for (typename std::vector<Feature >::iterator i=m_Features.begin(); |

95 | i!=m_Features.end(); ++i) |

96 | { |

97 | m_Classes.insert(i->m_Class); |

98 | } |

99 | } |

100 | |

101 | template<class T> |

102 | void LDAClassifier<T>::CalcGlobalMean() |

103 | { |

104 | |

105 | } |

106 | |

107 | template<class T> |

108 | void LDAClassifier<T>::CalcClassMeans() |

109 | { |

110 | } |

111 | |

112 | template<class T> |

113 | void LDAClassifier<T>::CalcMeanCorrected() |

114 | { |

115 | } |

116 | |

117 | template<class T> |

118 | void LDAClassifier<T>::CalcCovariance() |

119 | { |

120 | } |

121 | |

122 | template<class T> |

123 | void LDAClassifier<T>::CalcPooledCovariance() |

124 | { |

125 | } |

126 | |

127 | template<class T> |

128 | void LDAClassifier<T>::CalcPriorProbablity() |

129 | { |

130 | } |

131 | |

132 | #endif |

**Note:**See TracBrowser for help on using the repository browser.