Ask Your Question
2

Question About Histogram Comparison

asked 2012-12-22 10:47:06 -0500

enienws gravatar image

Hello, I need to compare two histograms for my project. I am working on normalized histograms by using the following function call:

//Assuming that histogram is a cv::Mat and is valid    
cv::normalize(histogram, histogram, 1.0);

I am using cv::compareHist() to compare the histograms. I have tried the all four methods for comparison with OpenCV macros: CV_COMP_CORREL, CV_COMP_CHISQR, CV_COMP_INTERSECT, CV_COMP_BHATTACHARYYA.

The problem is that: When analyzing the comparison results, CV_COMP_INTERSECT comparison method produce values bigger than 1 although two histograms are normalized. It is stated on Learning OpenCV: Computer Vision with the OpenCV library (page 202):

If both histograms are normalized to 1, then a perfect match is 1 and a total mismatch is 0.

What you think about this?

Best wishes.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2012-12-23 07:26:56 -0500

Michael Burdinov gravatar image

When you use CV_COMP_INTERSECT comparison method on two histograms that are perfectly match, your result will be equal to sum of values of a histogram. i.e. your result will be equal to L1 norm of histogram.

When you used normalize() function, you set only 3 first parameters. And so other parameters were used with their default values. By default it uses L2 norm. i.e. after using normalize(), sum of squares of values of histogram was set to 1.

To fix your problem you should use:

cv::normalize(histogram, histogram, 1.0, 0.0, NORM_L1);
edit flag offensive delete link more

Comments

Thank you so much. I have understood where the mistake was.

enienws gravatar imageenienws ( 2012-12-23 08:34:48 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2012-12-22 10:47:06 -0500

Seen: 1,099 times

Last updated: Dec 23 '12