cv.compareHist - MATLAB File Help |
Compares two histograms
d = cv.compareHist(H1, H2)
d = cv.compareHist(H1, H2, 'OptionName',optionValue, ...)
H1
.d(H1,H2)
.The function cv.compareHist compares two dense or two sparse histograms using the specified method.
While the function works well with 1-, 2-, 3-dimensional dense histograms, it may not be suitable for high-dimensional sparse histograms. In such histograms, because of aliasing and sampling problems, the coordinates of non-zero histogram bins can slightly shift. To compare such histograms or more general sparse configurations of weighted points, consider using the cv.EMD function.
Histogram comparison methods:
Correlation
d(H1,H2) = (sum_{I}((H1(I) - H1_hat(I))*(H2(I) - H2_hat(I)))) /
(sum_{I}(H1(I) - H1_hat(I))^2 * sum_{I}(H2(I) - H2_hat(I))^2)
where Hk_hat = 1/N * sum_{J} Hk(J)
and N
is a total number of
histogram bins.
ChiSquare
d(H1,H2) = sum_{I} ((H1(I) - H2(I))^2 / H1(I))
Intersection
d(H1,H2) = sum_{I} min(H1(I), H2(I))
Bhattacharyya
d(H1,H2) = sqrt(1 - (1/sqrt(H1_hat(I)*H2_hat(I)*N^2)) * sum_{I}(sqrt(H1(I)*H2(I))))
AltChiSquare
d(H1,H2) = 2 * sum_{I} ((H1(I) - H2(I))^2 / (H1(I) + H2(I)))
This alternative formula is regularly used for texture comparison. See [Puzicha1997].
KullbackLeibler
d(H1,H2) = sum_{I} (H1(I) * log(H1(I)/H2(I)))
[Puzicha1997]:
Jan Puzicha, Thomas Hofmann, and Joachim M Buhmann. "Non-parametric similarity measures for unsupervised texture segmentation and image retrieval". In Computer Vision and Pattern Recognition, 1997. Proceedings., 1997 IEEE Computer Society Conference on, pages 267-272.