# An Improved Method for Image Retrieval Based on Color and Texture Features

Jun Yue, Chen Li, Zhenbo Li

<figure><img src="image_1.png" /></figure>

► To cite this version:

Jun Yue, Chen Li, Zhenbo Li. An Improved Method for Image Retrieval Based on Color and Texture Features. 8th International Conference on Computer and Computing Technologies in Agriculture (CCTA), Sep 2014, Beijing, China. pp.739-752, 10.1007/978-3-319-19620-6_80. hal-01420292

HAL Id: hal-01420292

https://inria.hal.science/hal-01420292

Submitted on 20 Dec 2016

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_2.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
# An Improved Method for Image Retrieval Based on Color and
Texture Features

Jun Yue¹ Chen Li² Zhenbo Li¹,³,∗

¹ College of Information and Electrical Engineering, LUDONG University, YanTai, 264025,China; ² College of Information and Electrical Engineering, China Agricultural University, Beijing, 100083,China

³yuejun509@gmail.com, yuejuncn@sina.com

**Abstract:** With the development of technology and Internet, people need more and more information. The carrier of information is also changed from the original text into the current image, video, etc. Image retrieval plays an increasingly important role in the field of study. This paper is a study of image retrieval based on color and texture features, the main algorithms include color histogram, color moment, gray level co-occurrence matrix (GLCM) and Tamura texture features, etc. Then it made further improvements that combined color histogram and Tamura texture features method (we made Tamura texture retrieval again based on color histogram firstly) based on search results. Experimental results demonstrate that the rates of retrieval by comprehensive approach is higher than using a single method.

**Keywords:** color histogram; color moment; gray level co-occurrence matrix; gray-scale diffence statistics; Tamura texture features

## 1 Introduction

With the development of multimedia network technology, we can get information from many kinds of methods. Besides text, currently digital imaging is widely used in various areas including medical science, industrial manufacturing, aerospace engineering, remote sensing, etc. In order to effectively manage and retrieve image, the traditional methods are to mark the image with text and create relation between them. But sometimes it is difficult to describe the complete meaning of the images using only a few key words, and it is subjective(people have different descriptions of the same image). Using the traditional methods lead to differences between input keywords and the keywords in database, so users won't find the target image. To overcome this disadvantage, people proposed a content-based image retrieval[1] which includes extracting the features of the image, matching the target image, and the images in the database, and then we can search the target image. Image features, including text features and visual features, visual features can be described by color, texture and shape.

Color is the most straightforward descriptor of the images, Swain[2] first proposed a method using the color histogram feature to search images. Stricker, took the first three-moment matrix of colors to characterize the content of the image. Texture is an important feature of the image, and extracting the texture feature is also an important way to retrieve image. In 1970s, Haralick proposed a method gray level co-occurrence matrix; Tamura[3] proposed a form of expression texture including coarseness, contrast, directionality, linelikeness, regularity, and roughness.

In this paper, we retrieve images from both color and texture. The main algorithms include color
histogram, color moment, GLCM, gray-scale diffidence statistics and Tamura texture features. The recall ratio and precision were used as the performance of different algorithms. Based on the experiments, we also proposed a method combining the color histogram and Tamura texture features. The results demonstrated that the rates of retrieval by comprehensive approach is higher than only using a single method.

This retrieval process is divided into five modules, and the procedure is as follow:

1. Create an image database

2. Extract the feature of the image, form a feature library

3. Input search image and extract the feature

4. Feature matching

5. Output query results and compare the accuracy

<figure><img src="image_3.png" /><figcaption>Fig.1.1 Image retrieval flowchart</figcaption></figure>

# 2 Feature Extraction

## 2.1 Color Feature

Color is the most widely used visual feature of image retrieval, because color is highly related to objects and scenes of image. The common methods that we used to describe the color feature contain color moment, color correlogram, color histogram[4], etc.

### (1) Color Moment

Color moment is based on numerical methods and it can describe the distribution of color by calculating the moment. Since the color distribution information mainly concentrated on the lower order moments, so first moment (mean), second moment (variance) and third moment (skewness) are commonly used methods to represent the color distribution of image. The mathematical formula is as follows:

First moment:

$$ \mu_i = \frac{1}{N} \sum_{j=1}^{N} p_{ij} $$

Second moment:
$$ \sigma_i = \left[ \frac{1}{N} \sum_{j=1}^{N} (p_{ij} - \mu_i)^2 \right]^{1/2} $$

Third moment:

$$ S_i = \left[ \frac{1}{N} \sum_{j=1}^{N} (p_{ij} - \mu_i)^3 \right]^{1/3} $$

Where $p_{ij}$ represents the probability of the color image of the i-th color component of the channel appears as the gray pixel j, N represents the number of pixels of the image.

## (2) Color Correlation

The color correlogram is another expression of the distribution of image color. It reflects the spatial correlation between each two neighboring pixels, as well as the correlation between local pixel distribution and overall pixel distribution. It is easy to calculate and has good effect.

## 2.2 Texture

Texture is an attribute of an image area, it needs to contact the context because the texture of one pixel is meaningless. Texture reflects the relationship between the gray value of image pixels. Some common texture descriptors are introduced as follow.

### (1) GLCM$^{[5]}$

Before calculating GLCM, we should preprocess images. The grayscale of images is generally large, so it can be time-saving and reducing the amount of computation greatly if we compress grayscale first.

GLCM describes texture by doing a study of the spatial correlation properties of gray, and it is based on second-order gray level co-occurrence matrix statistical features. It describes as follow:
Entropy:

$$ H = - \sum_{i} \sum_{j} p(i, j) \log(p(i, j)) $$

Entropy is a measurement of the amount of information of images. It shows the texture complexity and non-uniformity of images. When the values of GLCM are uniformly distributed, the entropy is large.
Energy:

$$ E = \sum_{i} \sum_{j} p(i, j)^2 $$

Energy is the sum of squares of the element values of GLCM. It reflects the degree of gray uniformity and texture coarseness. If the values of GLCM concentrated in a piece, the energy value is great; if the values distribute evenly, the energy value is small.
Moment of inertia:

$$ I = \sum_{i} \sum_{j} (i - j)^2 p(i, j) $$

The moment of inertia is contrast that reflects the image clarity and the degree of the groove depth.
The more pixels in large contrast, the greater moment of inertia.

Correlation:

$$U = \frac{\sum_{i} \sum_{j} ijp(i, j) - \mu_{x} \mu_{y}}{\sigma_{x} \sigma_{y}}$$

Correlation measures the degree of similarity on GLCM elements in a row or column direction. So it reflects the relationship between the local gray of the image. When the matrix element values are average, the correlation is large, whereas the matrix element values vary greatly, the correlation value is smaller.

### (2) Gray-scale diffence statistics

Assumed that the gray value of any point (x, y) of the image is g(x, y). A point deviating from (x, y) is (x+Δx, y+Δy), the gray value of it is g(x+Δx, y+Δy). The difference between gray values is:

$$g_{\Delta}(x, y) = g(x, y) - g(x + \Delta x, y + \Delta y)$$

We can get the histograms of $g_{\Delta}(x, y)$ and texture features by the formula. In this paper, texture features are the mean, contrast and entropy. Gray value reflects the smooth degree of texture, the smaller the mean, the more smooth the texture. Contrast reflects the clarity of image, the greater the contrast, the more easily distinguish the image. Entropy reflects image texture roughness, the higher the value, the more coarse the texture.

## 2.3 Comprehensive color histogram and Tamura texture feature

Color histogram is the simplest and most common image features, which describes the proportion of different colors in the whole image and has the invariance of rotation, translation and scale. But it is not concerned with the spatial position of each color. Therefore, different objects with same color histogram might be determined as one target when using color histogram based methods. Ultimately, the error of retrieval results increases significantly. It is suitable to use color histogram based methods when images are difficult to segmented or the spatial distribution of color is not important.

Based on the texture of visual perception, Tamura et al. proposed an expression of texture features. Calculating the six components of texture which is corresponding to the texture features of the six attributes in psychological[6]: coarseness, contrast, directionality, regularity, linelessness, and roughness. Typically, coarseness, contrast and directionality is sufficient to express the texture features of images. Therefore, we get the roughness, contrast and directionality of the image in the database as eigenvectors, calculating the Euclidean distance, matching the image and searching the target image. The following describes the mathematical expression of these three attributes[7]:

### (1) Coarseness

First, taking a sliding window (the size is $2^k \times 2^k$ per pixel) scan image, calculating the mean of gray value of all the pixels falls in the window at each slide. Calculating the average intensity difference of pixel in horizontal direction and vertical direction which falls on overlap window, the formula is:

$$E_{k,h}(x, y) = |A_k(x + 2^{k-1}, y) - A_k(x - 2^{k-1}, y)|$$
$$E_{k,v}(x, y) = |A_k(x, y + 2^{k-1}) - A_k(x, y - 2^{k-1})|$$
We can set the optimum size of the window by K value which is the maximal of E.The size is $S(x, y) = 2^k$. Then the coarseness is the average of all $S(x, y)$ that we calculate, the formula is:

$$F_{crs} = \frac{1}{m \times n} \sum_{i=1}^{m} \sum_{j=1}^{n} S(i, j)$$

(2) contrast

$$F_{con} = \frac{\sigma}{\partial_{4}^{1/4}}$$

Contrast is the distribution of gray values of all the pixels by statistics. Defined by the formula $\partial_{4} = \mu_{4} / \sigma^{4}$, and $\mu_{4}$ means fourth moment.

(3) directionality

Directionality is determined by calculating the gradient of the neighboring pixels. The formula of mode and direction of the gradient is:

$$|\Delta G| = (|\Delta_{H}| + |\Delta_{V}|) / 2$$

$$\theta = \tan^{-1}(\Delta_{H} / \Delta_{V}) + \pi / 2$$

$\Delta_{H}$ represents the change in horizontal direction and $\Delta_{V}$ is vertical.

As we all know, color[8] describes the surface properties of scene in the image or block as a global features. Because of color is not sensitive to the change of direction and size of the image, it can not capture the local features greatly. Texture reflects the relationship between the gray value of image pixel. The global regularities and local irregularities of the image may be certain or random. From this experiment we can get that single image retrieval method has advantages, but there are also various shortcomings, resulting in retrieval efficiency is not very high. Therefore, in order to remedy these shortcomings, this paper presents a comprehensive method of color histogram and Tamura texture feature.

The method that integrates color histogram and Tamura texture feature can search the image fully. The main principle is: based on the color histogram, we make secondary use of retrieval by using Tamura texture feature. We compare the similarity of texture after color, judging by the two indexes so that the experimental result is more accurate and has higher retrieval efficiency. Experiment shows that the retrieval rates of comprehensive color histogram and Tamura texture feature is higher than single retrieval method.

## 3 Image similarity measure

The measurement of image similarity plays an important role in image retrieval, and it affects the accuracy of image matching. When matching the image features, the common method calculating the distance between two points. The methods of calculating the distance include Absolute distance, Secondary Type distance and Euclidean distance[9]. The Euclidean distance is a commonly used method
which has the advantage of low complexity, so this paper measure the similarity of the image by
calculating the Euclidean distance. The formula is as follows:

$$
d = \left[ \sum_{i=1}^{n} (a_i - b_i)^2 \right]^{1/2}
$$

4 The experimental results

First, create an image database.We choose ten kinds of flowers and each of them are ten. It's pink
Chinese Rose,orange Chinese Rose, Narcissus, Lotus, Magnolia,Blue Enchantress, Sunflower,green
Rose,Peach Blossom and Winter Jasmine. Sequentially numbered from 1 to 100, the size is 128 *
128pix and the resolution ratio is 72 * 72.The same kinds of flowers have similarities but is not higer,so
the search process may has large deviations and needs to be improved.

Each image has been searched in five ways in the experiment, the results as the following
examples:

Selecting the retrieved picture:

<figure><img src="image_4.png" /><figcaption>Fig.4.1 the retrieved image</figcaption></figure>

(1) Color Histogram

<figure><img src="image_5.png" /><figcaption>Fig.4.2 the results of color histogram</figcaption></figure>

(2) Color Moment
<figure><img src="image_6.png" /><figcaption>Fig.4.3 the results of color moment</figcaption></figure>

(3) Gray-scale diffience statistics

<figure><img src="image_7.png" /><figcaption>Fig.4.4 the results of gray-scale diffience statistics</figcaption></figure>

(4) GLCM
<figure><img src="image_8.png" /><figcaption>Fig.4.5 the results of GLCM</figcaption></figure>

<figure><img src="image_9.png" /><figcaption>Fig.4.6 the results of Tamura texture feature</figcaption></figure>

As can be seen from the above results, the number of images that retrieved by five ways is:7,3,3,4,8. So for figure 4.1,the best way of retrieval is Tamura texture, followed by color histogram, the worst way are color moments and gray-scale difference statistics.But this is only one picture in database and is not representative,then we search the remaining 99 images and add up data.

# 5 Performance Evaluation

## 5.1 the first method of evaluation

We need to have some indexes to measure if retrieval is accurate and how much the degree of accuracy is. The common indexes are recall ratio and precision ratio[10].The definition is as follows:

Recall ratio: n/N
Precision ratio: n/T

n refers to the number of images in the query results are associated with the key figure [11]. N refers to the number of images in the test set are associated with the key figure. And T refers to the number of images returned by the query. According to the choice and the number of image database, we know N is 10, T is 20.

Experiments were conducted on each image(total 100) with five kinds of retrieval methods (Color Histogram, Color Moment, GLCM, Gray-scale difference statistics, Tamura texture features). We get a total of five sets of data and calculate the average recall and precision ratio, the following is a table:

<table><caption>**Table 5.1** The experimental results</caption><thead><tr><td>Retrieval method</td><td>Average recall ratio</td><td>Average precision ratio</td></tr></thead><tbody><tr><td>Color histogram</td><td>66%</td><td>33%</td></tr><tr><td>Color moment</td><td>37.6%</td><td>18.8%</td></tr><tr><td>Gray-scale difference statistics</td><td>31.3%</td><td>15.7%</td></tr><tr><td>GLCM</td><td>36.2%</td><td>18.1%</td></tr><tr><td>Tamura texture feature</td><td>37.8%</td><td>18.9%</td></tr></tbody></table>

The analysis of the results: from the table 5.1 we can get the best retrieval method is color histogram with average precision ratio of 33 and the worst is gray-scale difference statistics with 15.7%.

In addition, the system response time is also an index of retrieval results. From the experimental we can know the fastest retrieval method is color histogram and color moments with only one second. The gray differential statistics with a time of about 10 seconds followed by GLCM with a time of 20 seconds and the longest is Tamura texture with more than one minute. Therefore, for the purposes of retrieval efficiency, color histogram and color moments have the highest efficiency.

In summary, using color histogram for image retrieval can achieve better results in this image database of experiment.

## 5.2 the second method of evaluation

In addition to calculating recall and precision ratio, we can collate data and get a line chart so that we have seen what is the better retrieval method. In the 100 samples we selected 50 pictures with equal intervals(taking five images of each kind of flower), a line chart is as follows:
<figure><img src="image_10.png" /><figcaption>Fig.5.1 a line chart of search results</figcaption></figure>

Calculating the average of this 50 pictures with five method, we get the following table:

<table><caption>Table5.2 The average number of retrieval with different method</caption><thead><tr><td>Retrieval method</td><td>Average numbers</td></tr></thead><tbody><tr><td>Color Histogram</td><td>6.82</td></tr><tr><td>Color Moment</td><td>3.64</td></tr><tr><td>Gray-scale difference statistics</td><td>3.02</td></tr><tr><td>GLCM</td><td>3.32</td></tr><tr><td>Tamura Texture Feature</td><td>3.72</td></tr></tbody></table>

From Fig 5.1 and Table 5.2 we can see that color histogram is better than others especially for the former 20 pictures with the average number of retrieval 6.82. Tamura texture feature is the next one. The overall line trend of gray-scale difference statistics located below the other four retrieval method with a poor result, the average number of sheets to retrieve is only 3.02. It is also consistent with the experimental results in Table 5.1.

## 6 Improved methods

As can be seen from the above experiment Tamura texture feature and color histogram are better than others, but a single retrieval method is still lower. Therefore, this paper proposes a combination of these two methods to retrieve, I.e., based on the color histogram we do Tamura texture feature again. For the same Fig 4.1, the experimental results are as follows:
<figure><img src="image_11.png" /><figcaption>Fig.6.1 the result of a combination of color histogram and Tamura texture feature</figcaption></figure>

Analyzing by contrast:for the same Fig 4.1,it has 7 images of former 10 are the same kinds of flowers with targeted image only by color histogram,just show as Fig 4.2. It has 5 images of former 10 are the same kinds of flowers only by Tamura texture feature,just show as Fig 4.6.

But the combination of color histogram and Tamura texture feature is better,it has secrched 8 images that are similar with targeted image showing as Fig 6.1.

In order to make it representative,we selected ten images (numbered 11, 21, ... 81, 91)from database to test and get the number of similar images of the former 10,the Table is as follows:

<table><caption>Table6.1 the comparison of single retrieval method and integrated method</caption><thead><tr><th>The image number</th><th>Clolr histogram</th><th>Tamura texture feature</th><th>Integrated method</th></tr></thead><tbody><tr><td>1</td><td>7</td><td>5</td><td>8</td></tr><tr><td>11</td><td>7</td><td>2</td><td>6</td></tr><tr><td>21</td><td>4</td><td>5</td><td>6</td></tr><tr><td>31</td><td>3</td><td>1</td><td>7</td></tr><tr><td>41</td><td>3</td><td>1</td><td>5</td></tr><tr><td>51</td><td>8</td><td>2</td><td>4</td></tr><tr><td>61</td><td>7</td><td>2</td><td>5</td></tr><tr><td>71</td><td>6</td><td>2</td><td>7</td></tr><tr><td>81</td><td>5</td><td>2</td><td>7</td></tr><tr><td>91</td><td>5</td><td>2</td><td>6</td></tr><tr><td>The average number</td><td>5.5</td><td>2.4</td><td>6.1</td></tr></tbody></table>

To make the results more clear, we draw a line chart by the above table:
<figure><img src="image_12.png" /><figcaption>Fig.6.2 a line chart of improved method</figcaption></figure>

From Table 6.1 and Fig 6.2, for the numbered images 51 and 61, we can see that the integrated method is worse than color histogram, but is better than Tamura texture feature. Overall, the efficiency of a single retrieval method is relatively poor, and integrated color histogram method and Tamura texture feature enables retrieval rate increased.

# 7 Summary and expectation

This paper is a study of image retrieval based on color and texture features, the five methods we used include color histogram, color moment, GLCM, gray-scale difference statistics, and Tamura texture features. Subsequently we do further comparison after calculating the recall ratio and precision ratio. From this experiment we can see that color histogram is better than other methods whether on time or the accuracy. Tamura texture feature provides better results than other methods, but it is not suitable for real-time applications because it is time-consuming. The preliminary results showed that all methods based on single feature cannot provide acceptable performance, and thus a retrieve model was proposed using both color-histogram and texture. The experimental results showed that the retrieval accuracy of the improved model are increased.

In future, the study will be focusing on three aspects. In order to avoid effects caused by irregular images, all will be automatically cropped and saved into the database. The retrieval efficiency on large-scale database needs to be further studied and optimized. Additionally, the selection of similarity measurement is crucial to improve the retrieval accuracy, and various similarity calculations should be tested.

# References:

[1] Wei guang, Wang.Cheng jun, Xie. The exploration of the Content-Based Image Retrieval Technology. 2014.

[2] Hui ying, Xu. Jie Yuan. Jian min, Zhao. A Color and Texture-Based Image Retrieval Methods. 2009, (5)

[3] Yu bao, Hao. Ren li, Wang. Jun Ma. An improvement of Tamura Texture Feature Retrieval Method, 2010, (7)

[4] Nirmal, A.J.1; Gaikwad, V.B.2. Color and Texture Features for Content Based Image Retrieval System. 2011

[5] Shuang Wang, Jing Pan. A Fuzzy Algorithm Based On Texture and Color Features. 2014, (2)
[6]Jing ying,Yan.Cheng ru,Wang.Xiao yun,Wang.A Texture-Based Image Retrieval. University of Electronic Science and Technology.2010,(12)

[7]Zhi min,Ji.A study of Image Retrieval integrated Color,Texture and Shape.2011,(5)

[8]Yu Cai-xiang;Qiu Shu-bo. Image Retrieval Algorithm Based On Texture and Color Features.2009

[9] Su,C;Wahab,M.H.A.;Tsai-Ming Hsieh; Image Retrieval Based On Texture and Color Features.2012

[10] Afifi,A.J.;Ashour,W.M.. Content-Based Image Retrieval Using Invariant Color and Texture Features.2012

[11] Yong an,WANG. The Research and Implementation Based on Color and Texture Image Retrieval.2011.

[12]Fang Yuan. Image Retrieval Research Based On Texture and Color Features.2012.