opencv - compare 2 histograms with Chi-Square -
i want compare 2 histograms, have 2 dimensions. want use chi-square-metric. comparator looks function:
double histogram::comparehistogram(histogram *hist){ double result=0; double a=0; double b=0; (int y=0 ; y < bins_1 ; y++) { (int x=0 ; x < bins_2 ; x++) { a=gethistogramvalue(x,y)-hist->gethistogramvalue(x,y); b=gethistogramvalue(x,y)+hist->gethistogramvalue(x,y); if(fabs(b)>0.0){ result+=a*a/b; } } } return result; } i've compared result result of opencv's cv::comparehist() function , different. don't know why.
before compared histograms, norm histograms minmax-norm. compared normed histogram normed histogram of opencv , equal. think, problem in comparehist function. where?
best regards,
the relevant section of source code opencv follows:
if( method == cv_comp_chisqr ) { for( j = 0; j < len; j++ ) { double = h1[j] - h2[j]; double b = h1[j]; if( fabs(b) > dbl_epsilon ) result += a*a/b; } } so can see difference in code line
b=gethistogramvalue(x,y)+hist->gethistogramvalue(x,y); which should be
b=gethistogramvalue(x,y);
Comments
Post a Comment