Histogram Chi-Square Distance Metric (Bug #2199)
Description
The Chi-Sqaure formula looks to be incorrect. I believe it should be SUM - H2)^2 / (H1 + H2) ).
Add: "+ H2"
http://docs.opencv.org/modules/imgproc/doc/histograms.html?highlight=histogram#double cvCompareHist(const CvHistogram* hist1, const CvHistogram* hist2, int method)
History
Updated by Robert Witkowski 8 months ago
Nathaniel Quillin wrote:
The Chi-Sqaure formula looks to be incorrect. I believe it should be SUM - H2)^2 / (H1 + H2) ).
Add: "+ H2"
http://docs.opencv.org/modules/imgproc/doc/histograms.html?highlight=histogram#double cvCompareHist(const CvHistogram* hist1, const CvHistogram* hist2, int method)
in some papers as this one (shape context, hist-comparison) there is also a factor 0.5 included, see URL:
http://www.eecs.berkeley.edu/Research/Projects/CS/vision/shape/belongie-pami02.pdf
Updated by Robert Witkowski 8 months ago
Robert Witkowski wrote:
Nathaniel Quillin wrote:
The Chi-Sqaure formula looks to be incorrect. I believe it should be SUM - H2)^2 / (H1 + H2) ).
Add: "+ H2"
http://docs.opencv.org/modules/imgproc/doc/histograms.html?highlight=histogram#double cvCompareHist(const CvHistogram* hist1, const CvHistogram* hist2, int method)
in some papers as this one (shape context, hist-comparison) there is also a factor 0.5 included, see URL:
http://www.eecs.berkeley.edu/Research/Projects/CS/vision/shape/belongie-pami02.pdf
ps: i've just checked that the '+ H2' is correctly implemented, already (see cvhistogram.cpp, google). ONLY THE DOCUMENTACION IS WRONG. in cvhistogram.cpp you can see that the variable b is calculated using in your notation b = H1 + H2 (here b = ptr1[i] + ptr2[i]):
case CV_COMP_CHISQR:
for( i = 0; i < total; i++ ) {
double a = ptr1[i] - ptr2[i];
double b = ptr1[i] + ptr2[i];
if( b != 0 )
result += a*a/b;
}
break;
Updated by Vadim Pisarevsky 8 months ago
thanks for the report!
looks like there are different opinions on how the formula should look like. We now use the formula from Wikipedia.
See also #1263
- Status changed from Open to Cancelled
- Assignee set to Vadim Pisarevsky