A Study of Distance Metrics in Histogram Based Image Retrieval

There has been a profound expansion of digital data both in terms of quality and heterogeneity. Trivial searching techniques of images by using metadata, keywords or tags are not sufficient. Efficient Content-based Image Retrieval (CBIR) is certainly the only solution to this problem. Difference between colors of two images can be an important metric to measure their similarity or dissimilarity. Content-based Image Retrieval is all about generating signatures of images in database and comparing the signature of the query image with these stored signatures. Color histogram can be used as signature of an image and used to compare two images based on certain distance metric. In this study, COREL Database is used for an exhaustive study of various distance metrics on different color spaces. Euclidean distance, Manhattan distance, Histogram Intersection and Vector Cosine Angle distances are used to compare histograms in both RGB and HSV color spaces. So, a total of 8 distance metrics for comparison of images for the sake of CBIR are discussed in this work.


INTRODUCTION
With the growing need of digital data and declining cost of storage, we have moved past the trivial text-based search of images and advanced towards Content-based Image Retrieval. The focus is now upon the efficient methods and features to be used to get semantically best results. Computers are better at measuring properties and storing it in their memory; however, humans are much better than computers at attaching semantic description to an image [1].This is still an open question as to which method is the best as each has its own pros and cons but some major works has been done in this direction in [1][2] [3]. The common ground of all the CBIR techniques is to extract the signature of the query image on the basis of its pixel values and compare it with already stored signatures of all the images in the database based on some rule. This comparison rule can be some distance metric, as discussed in this paper, or some other rules based on local characteristics. According to [3], besides providing significant compression of image representation, signatures also provide an improved correlation between image representation and semantics. The meaning of the image is inferred based upon the signature derived from pixel values. Most of the CBIR techniques use one of the 3 approaches to extract signatures: histogram, color layout and region-based search [3]. Color histogram is an important feature of an image which gives a global representation of an image; it gives a holistic view of an image. However, there are references available in the literature which focuses upon a certain portion of the image and semantically distinguish it on the basis of that [4].
Two histograms are compared on the basis of certain distance metric. Several distance metrics are available in the literature: Euclidean distance, Manhattan distance, Vector Cosine Angle distance, Histogram Intersection distance, CIEdeltaE, CIEdeltaE2000, Earth Mover's distance [5] and many more. The results vary greatly on the distance metrics, the color space and also on the image database used. In this paper, an exhaustive study of effects of various distance metrics in different color spaces has been done. Euclidean distance, Manhattan distance, Histogram Intersection distance and Vector Cosine Angle distance are used to measure similarity between two images in each of the two color spaces, viz RGB and HSV. In all, there are 8 approaches used whose performance is measured by precision and recall [6]. COREL database is used for the study. In COREL database there are 1000 images distributed in 10 categories, each of them having 100 images.
In the next section, we discuss a little theory about the color spaces and its conversions. In section 3, the distance metrics used in this work has been discussed. In section 4, the experiments and results of the work have been detailed. The last section draws conclusion from the work so done and discusses some future work.

COLOR SPACE
Color space is a digital palette with colors being much precisely organized and quantified. It relates colors to a tuples of numbers, typically to three or four values or color components. Different color spaces are available in literature. In this paper, RGB and HSV color spaces have been used for study.

RGB Color Space
RGB color model is an additive color model in which Red(R), Green(G) and Blue(B) are added together in order to produce an array of colors. RGB is a device dependent color space. Different devices detect or produce a given RGB values differently because the color elements (phosphors or dyes) differ from manufacturer to manufacturer. Moreover, it may vary in the same device over time. This color space is used in TV, digital cameras, CRT/LCD/plasma monitors, phone displays etc.

HSV Color Space
HSV stands for Hue, Saturation and Value. This is used mostly by artists. A color in HSV color space is specified by stating hue angle, chroma level and the lightness level. "Hue" depicts the colors like red or blue, "value" depicts the lightness level, whereas "saturation" depicts how different a color appears from gray of same lightness. HSV color space is a normalized color space in which complimentary colors appear at a separation of 180°.

DISTANCE METRICS
We store the color histograms of all the images in the database. Once given the query image, its signature, i.e color histogram, is calculated and thereafter its distance from all those present in the database. Accordingly, the results are sorted and nearest neighbors are displayed. In this work, 4 distance metrics have been used as a similarity rule.

Euclidean Distance
In Cartesian coordinates, if X = (x1, x2... xn) and Y = (y1, y2... yn) are two points in Euclidean n-space, then the Euclidean distance between X and Y is given by:

Histogram Intersection Distance
It was proposed in [11]. Let IR, IG and IB be the normalized color histograms of an image in the database and let QR, QG and QB be the normalized color histogram of query image. The similarity between the query image and the stored image in the database, SC HI (I,Q) is given by:

Vector Cosine Angle Distance
The cosine of angle between two vectors determines whether two vectors are pointing in roughly the same direction. This distance is frequently used in data mining to measure the cohesion within clusters. If X = (x1, x2... xn) and Y = (y1, y2... yn) are two points, then cosϴ is the cosine of vector angle between X and Y in n-dimension. (ix)

EXPERIMENTS & RESULTS
In this paper, we have used COREL database for the experiment purpose. COREL database consists of 1000 images divided in 10 categories with 100 images in each category. The categories of the images are people, beach, monuments, buses, dinosaurs, elephants, flowers, horses, mountains and cuisines. First of all, signatures of all the images are stored in a database and then an image is queried with its signature as input. In this work, we have color histogram of an image as the signature. The rule for similarity measure is distance metrics. 4 different distance metrics, viz, euclidean distance, manhattan distance, histogram intersection distance and vector cosine angle distance, are used in two color spaces, RGB and HSV. Thus, in all we have 8 different rules for similarity measures for content based retrieval. The performance criteria are precision and recall. w w w . i j c t o n l i n e . c o m

Calculating Precision
As discussed in [6], precision is defined as the ratio of number of relevant images retrieved to number of images retrieved. The better the precision at same recall value, the better the distance metric is. Here, because we use COREL database, the number of relevant images is fixed, 100.

Recall
We calculate precision of the distance metric by varying the number of retrieved images. Once, the distance of query image is calculated with all the images in the database, it is sorted. The order of sort depends on the type of distance metric. So, the denominator for calculating precision (No. of images retrieved) is varied by considering 10, 20 and 30 nearest neighbors (NN). Out of these nearest neighbors (NN), how many of them belong to the same category as the query image, that's precision.
For, the purpose of experiment, we have considered 5 random images from each of the 10 category as the query image and calculated their precision based on all the 4 distance metrics in both the color spaces. Then we have taken the mean of the precision of all the 50 images for each of the 8 similarity rules (4 distance metrics each in 2 color spaces). The above process is repeated for 3 cases, when the no. of images retrieved is 10, 20 and 30. A bar graph is subsequently plotted to discuss the results.

Calculating Time
We have also measured the average execution time of each of the distance metric in RGB and HSV color space for 10, 20 and 30 nearest neighbors. The results are as follows.

Results
Given a query image, Fig. 7 displays two retrieval results for each of the 8 similarity rules. In this one, Histogram Intersection distance seems to perform very well; but the two retrieved images are from different categories, although their color information seems to be same. Some more tests were also performed. But it was hard to find some general trend based on subjective tests.
From the bar graphs of precision, Fig. 4 (a) ~ (c), we conclude that Manhattan Distance and Histogram Intersection Distance comes out as winners among all the distance metrics. Moreover, the result is much better in HSV color space than RGB color space.
The time plots, Fig. 5 (a) ~ (b), show almost the same execution time in both the color spaces. The transformation factor from RGB to HSV color space is marginal. As expected, taking into account 30 nearest neighbors took a little bit more execution time than 20 nearest neighbors which in turn took some more time than 10 nearest neighbors. Both the color spaces gave uniform results in terms of execution time.
The more the precision at a certain recall, the better is the image retrieval. The recall vs. precision graphs, Fig. 6 (a) ~ (e), show that in most of the cases HSV color space performed better that RGB color spaces. In all the cases, except Horses category, Histogram Intersection distance performed much better that any of the other distance metric.

CONCLUSIONS
In this work, four distance metrics were compared in two color spaces. According to the precision graph and time graph, we conclude that Histogram Intersection distance is the best method among these four. It gives the most satisfying precision and takes the least computation time. Vector Cosine Angle distance (VCAD) is computationally burdensome because of a number of multiplications and divisions involved. It is intelligible from the time plot where execution time of VCAD just shoots up in both the color spaces. HSV color space results in better performance than RGB color space. Execution time difference between the two color spaces is marginal.
However, histogram approach is a method of global image representation. It discards the information about texture, shape and location. There can be semantic differences between the images retrieved even if their color information may be the same. For future work, rather than using histograms to extract signatures, we can also use color layout [1] [13] or regionbased methods to extract signatures and then do performance analysis. Color-layout method retains the information regarding shape, texture and shape; however, it is sensitive to shifting, cropping, scaling and rotation. Region-based methods [16][17] attempts to overcome the drawbacks of color-layout by acting at object level. Moreover, some other distance metrics like Earth Mover's distance [5] and weighted Euclidean distance [1] [7] can also be considered for performance analysis.