Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV Histogram Comparison Methods

Looking at the Histogram Documentation, there are 4(5) different comparison methods:

  1. CV_COMP_CORREL Correlation
  2. CV_COMP_CHISQR Chi-Square
  3. CV_COMP_INTERSECT Intersection
  4. CV_COMP_BHATTACHARYYA Bhattacharyya distance
  5. CV_COMP_HELLINGER Synonym for CV_COMP_BHATTACHARYYA

They all give different outputs that are read differently as shown in the Compare Histogram Documentation. But I can't find anything that states how effectively each method performs compared against each other. Surely there are Pros and Cons for each method, otherwise why have multiple methods?

Even the OpenCV 2 Computer Vision Application Programming Cookbook has very little to say on the differnces:

The call to cv::compareHist is straightforward. You just input the two histograms and the function returns the measured distance. The specific measurement method you want to use is specified using a flag. In the ImageComparator class, the intersection method is used (with flag CV_COMP_INTERSECT). This method simply compares, for each bin, the two values in each histogram, and keeps the minimum one. The similarity measure is then simply the sum of these minimum values. Consequently, two images having histograms with no colors in common would get an intersection value of 0, while two identical histograms would get a value equal to the total number of pixels.

The other methods available are the Chi-Square (flag CV_COMP_CHISQR) which sums the normalized square difference between the bins, the correlation method (flag CV_COMP_CORREL) which is based on the normalized cross-correlation operator used in signal processing to measure the similarity between two signals, and the Bhattacharyya measure (flag CV_COMP_BHATTACHARYYA) used in statistics to estimate the similarity between two probabilistic distributions.

There must be differences between the methods, so my question is what are they? and under what circumstances do they work best?

like image 882
MLMLTL Avatar asked May 15 '15 11:05

MLMLTL


1 Answers

CV_COMP_INTERSECT is fast to compute since you just need the minimum value for each bin. But it will not tell you much about the distribution of the differences. Other methods try to achieve better and more continuous score as a match, under different assumptions about the pixel distribution.

You can find the formulae used in different methods, at

http://docs.opencv.org/doc/tutorials/imgproc/histograms/histogram_comparison/histogram_comparison.html

Some references to more details on the matching algorithms can be found at:

http://siri.lmao.sk/fiit/DSO/Prednasky/7%20a%20Histogram%20based%20methods/7%20a%20Histogram%20based%20methods.pdf

like image 97
Totoro Avatar answered Oct 13 '22 03:10

Totoro