Está en la página 1de 7

Histogram Comparision

Pi19404
September 15, 2013

Contents

Contents
Histogram Comparison
0.1 Introduction . . . . . . . . . . . . . . 0.2 Histogram Comparison . . . . . 0.2.1 Minkowski norm . . . . . . 0.2.2 Histogram Intersection 0.2.3 Correlation . . . . . . . . . 0.2.4 Chi-Square . . . . . . . . . . 0.2.5 Bhattacharya Distance . 0.3 multi-channel images . . . . . . . . 0.4 Implementation . . . . . . . . . . . . 0.5 Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3
3 3 3 4 4 5 5 5 5 7

2|7

Histogram Comparison

Histogram Comparison
0.1 Introduction
In this section we will look at techniques for histogram comparison .

0.2 Histogram Comparison


In many application histogram is used as object model .Thus to compare an unknown object with a known object we can compute the similarity between their histograms.

The histogram of image shows the frequency distribution of different pixel intensities. The value of histogram for pixel level/intensity g shows the total count of pixels in the image with pixel intensity g.Let this be denoted by h (g )
a

ha (g ) =

X (g A(i; j))


i;j

2x

0.2.1 Minkowski norm


The histogram can be viewed as vectors and similariy is calculated using Minkowski norm (L ).
p

The manhattan distance p = 1 and euclidean distance p = 2 are special cases of minkowski norm.

3|7

Histogram Comparison

dL1 (ha ; hb ) = dL2 (ha ; hb ) =

X jh (g) h (g)j
g

X jh (g) h (g)j
2G
a b a b

2G

A high value indicates a mismatch while low value indicates a better match.0 indicates a perfect mismatch while total mismatch is 1 for normalized histogram.

0.2.2 Histogram Intersection


For 2 histograms h and h the histogram intersection is defined as
a b

dI (ha ; hb ) =

X min(h (g); h (g))


g

2G

A high score indicates a good match while low score indicates bad match.if both histograms are normalized then 1 is a perfect match while 0 indicates total mismatch indicating no regions of histogram overlap.

0.2.3 Correlation
For 2 histograms h and h the histogram correlation is defined as ,where histograms are simple considered as discrete 1-D signals.
a b

P 2 (h (g) h )(h (g) h ) d (h ; h ) = qP  P (h (g ) h ) 2 (h (g ) h ) 2 X H (j)  = 1 whereh


g G a a b b C a b g G a a

N is the total number of bins If the histogram is normalized ,then


k

X H (j) = 1; h = 1
k j

The value of 1 represents a perfect match ,-1 indicates a ideal mismatch while 0 indidates no correlation. For correlation a high score represents a better match than a low score.

4|7

Histogram Comparison

0.2.4 Chi-Square
For 2 histograms h and h the histogram similarity using Ch-Squared method is defined as
a b

d(ha ; hb ) =

X (H (g) H (g))
a b g

2G

H a (g )

A low score represents a better match than a high score.0 is a perfect match while mismatch is unbounded. The chi-square test is testing the null hypothesis, which states that there is no significant difference between the expected and observed result

0.2.5 Bhattacharya Distance


In statistics, the Bhattacharyya distance measures the similarity of two discrete or continuous probability distributions. It is closely related to the Bhattacharyya coefficient which is a measure of the amount of overlap between two statistical samples or populations
d(ha ; hb ) =

ph 1h N X ph (g) h (g)


a b

2G

For Bhattacharyya matching , low scores indicate good matches and high scores indicate bad matches. A value of 0 is perfect match while 1 indicates a perfect mismatch.

0.3 multi-channel images


For histogram with independ channels,values of similarity scores for each channel can be added seperately.

0.4 Implementation
The opencv libraries are used to perform histogram related operations.All the histogram related functions are encapsulate in the class named histogram. The code is present in files histogram.cpp and histogram.hpp which are

5|7

Histogram Comparison wrapper classes for calling opencv histogram functions and performing comparison operations etc. Let us consider the Hue histogram for following images and below are the similarity score using the bhattachrya distance method,chisquare,intersection and correlation methods. Consider the sets of image 1-2 0.591298 1-3 0.984197 1-4 0.766227 12.2216 3209.85 288.806 0.27982 0.00276222 0.197568 0.234247 -0.0775062 0.0814768

We can see that images 1 and 2 will have similar histograms ,for correlation and intersection for image pair 1-2 will be greater than 1-3 .Indicating the similarity of histograms 1-2 incomparison to 2-3. Chi square mismatch is unbounded as can be seen by high value.A large value can be observed in 2-3 compared to 1-2 The bhattachrya distance is close to 0 for better match,and nearly 1 for mismatch, for 1-3 value is almost 1 indicating a ideal mismatch. In case of image pair 1-2 and 1-4 are similar,but coefficients indicate that histogram of 1-2 is more similar than 1-4.

Figure 1: Histogram Comparison

The similarity measures are crude at best,however it might be useful in case of discriminative task ,however for identification task it seems like a poor measure.

6|7

Histogram Comparison

0.5 Code
For code refer to site http://code.google.com/p/m19404/source/browse/ OpenVisionLibrary/ImgProc/ Histogram.cpp,Histogram.hpp,test_histogram.cpp files.

7|7

También podría gustarte