Histogram Chi-Square Distance Metric (Bug #2199)


Added by Nathaniel Quillin over 1 year ago. Updated over 1 year ago.


Status:Cancelled Start date:2012-07-25
Priority:Normal Due date:
Assignee:Vadim Pisarevsky % Done:

0%

Category:documentation
Target version:2.4.3
Affected version: Operating System:
Difficulty: HW Platform:
Pull request:

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)


Related issues (Add)


History

Updated by Robert Witkowski over 1 year 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 over 1 year 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 over 1 year 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

Also available in: Atom PDF