I Description

With the development of image processing technology and machine learning, image retrieval is a technology that combines them perfectly and plays an indispensable role in today’s network world. The main contents are as followings: First of all, acquisition of database images. I have obtained a large number of training sets for feature extraction through reptiles, and all database images are processed by foreground extraction. By foreground extraction, we can directly extract the main features without considering the background features, and improve the retrieval. Secondly, as for the feature of extraction part, I extracted and saved the color features, texture features and local descriptor features of the image in the txt file through statistical color histogram, texture histogram, directional gradient histogram and SIFT feature descriptor, which facilitated the next processing. Then I compared a large number of similarity distance calculation algorithms, and finally decided to use LSH for similarity measurement, because the advantage of local sensitive hash is that it can deal with the similarity problem of high-dimensional data, and although it cannot return the most accurate results, its approximation can fully meet the retrieval requirements, and can speed up the calculation. Finally, we build the image retrieval system, build the main program, start the local host, quickly extract the image features uploaded by users and calculate the similarity with the features previously stored in the TXT file, and return the latest five results based on the similarity of different features to facilitate user screening.

Key words: Feature extraction, Histogram, Similarity distance measure, LSH, VGG-19

II Realization

  1. Color-based image feature extraction

The representation method of RGB color space can be represented by the most classic cube, as shown in Figure 2-1. The numbered axis of the cube represents the value of three colors. Each of the three visible surfaces represents a channel of one color. After superposition, tens of thousands of different colors are formed. When all three colors are 0, it means that pure black is at the bottom of the cube; when all three colors are 255, it means that pure white is at the top of the cube.
color.jpg
If you directly use the code to automatically extract the color histogram, the drawback is obvious, that is, the color distribution is very sparse, because the main object of the database picture of my system training set is furniture, and the color distribution of each picture is relatively uniform, so directly draw different color spaces The histogram will show that there is no statistical column on the horizontal axis of the histogram, which is not conducive to the comparison of similarity, and the image features cannot be grasped well, so I used a clustering algorithm kmeans when studying the image retrieval system. Given the function definition part code of kmeans, first generate a random number as the cluster center, and put the value of the cluster center into the center list; set the number of iterations to 100, and iterate the kmeans-classify function to find the nearest cluster center Putting it in the center has the advantage of greatly compressing the image scale.

3031612141296_.pic_hd.jpg

Then by calculating the number of color pixels in each unit, the color histogram is obtained. After many experiments, I found that assuming that the color statistical histograms of the two images are almost the same, the difference between the two is just a small interlaced bin. I found two methods by looking up the data: one is to use two Second distance; the other is to filter the color histogram smoothly in advance, so that the color value of one pixel can contribute to other pixels, which can make up for this defect. The color histogram creation code is as follows:

3021612141154_.pic_hd.jpg

  1. Texture-based image feature extraction

(1) Introduction to texture features and overview of Gabor filters

Texture refers to the homogeneity in the image, that is, a certain element or area of the image is sorted according to a certain rule. The best perceptron for texture features is the Gabor filter. The essence of the Gabor filter is to add Gabor functions of different directions and different frequencies in the Fourier transform as the window function to achieve multi-scale and multi-directional feature extraction of the image.
The mathematical expression of the two-dimensional Gabor function is:

3041612141596_.pic.jpg

6 frequencies, that is, the value of the parameter v is 1, 2, 3, 4, 5, 6
8 directions, that is, the value of parameter K is 8, that is, the value of parameter u is 0, 22.5, 45, 67.5, 90, 112.5, 135, 157.5. A total of 48 Gabor kernel functions, the superposition effect of Gabor functions at different frequencies and directions is as follows:

3051612141786_.pic_hd.jpg

(2) Implementation steps of Gabor filter to extract texture features

  1. First convert the input image from RGB image to grayscale image
  2. Extract the Gabor filter bank features of the gray image, and extract the features of 48 Gabor filter banks composed of Gabor features of 6 scales and 8 directions, which means that each pixel corresponds to a 48-dimensional Gabor feature vector;
  3. After getting a larger feature vector, I used the Kmeans++ clustering method to cluster all texture features, and select the texture feature after K(10) clustering to obtain the texture feature histogram according to the texture direction, which is convenient for image similarity Degree detection.
    The extraction effect is shown in the figure. The same color represents the extraction effect of the same texture. It can be seen that the Gabor filter has a very clear texture extraction effect.
    3061612141897_.pic_hd.jpg

yVcGjO.png3091612142540_.pic_hd.jpg

To be continued…