36 #ifndef SOFT_DECISION_SIMILAR_COMPONENT_H 37 #define SOFT_DECISION_SIMILAR_COMPONENT_H 61 if( (!_isInit) || _An.size() == 0 )
62 throw std::runtime_error(
"Should doIt before getting result !" ) ;
64 std::vector<short> segRes( _nbInd ) ;
66 for(
int ind = 0 ; ind < _nbInd ; ++ind ){
69 for(
int k = 1 ; k < _nbClasses ; ++k ){
70 if( _Rnk(ind, k) > _Rnk(ind, bestClass) )
74 segRes[ind] = bestClass ;
89 std::vector<short> _labels ;
90 std::vector<bool> _valids ;
96 bool stopCriterion(
double threshold ) ;
98 inline double similarity(
const AimsData<float>& indivMatrix,
int ind,
int k ) ;
99 inline double projection(
const AimsData<float>& indivMatrix,
int ind,
int k,
101 std::vector<double> _pk ;
102 std::vector< AimsData<double> > _ek ;
103 std::vector<double> _An ;
104 std::vector<double> _newpk ;
105 std::vector< AimsData<double> > _newek ;
106 std::vector<double> _newAn ;
112 SoftDecisionSimilarComponent::similarity(
const AimsData<float>& indivMatrix,
int ind,
int k )
114 double norm = 0., sim = 0. ;
115 for(
int t = 0 ; t < _nbVar ; ++t ){
116 norm += indivMatrix( ind, t ) * indivMatrix( ind, t ) ;
117 sim += indivMatrix( ind, t ) * _ek[k](t) ;
121 return sim / sqrt(norm) ;
125 SoftDecisionSimilarComponent::projection(
const AimsData<float>& indivMatrix,
130 for(
int t = 0 ; t < _nbVar ; ++t ){
131 proj += indivMatrix( ind, t ) * newek(t) ;
SoftDecisionSimilarComponent(int nbClasses, int nbVar)
~SoftDecisionSimilarComponent()
std::vector< short > getSegmentationResult() const
double doIt(const AimsData< float > &indivMatrix)
const AimsData< double > & getRnk() const
AIMSDATA_API float norm(const Tensor &thing)