The calculation of image similarity

Source: Internet
Author: User

Http://blog.sina.com.cn/s/blog_4a540be60100vjae.html

The calculation of image similarity (2011-12-13 22:16:23) reproduced
Tags: image similarity svd nmf Babbitt distance histogram distance image Hash Image correction Image content retrieval Category: Computer vision

Image similarity calculation is mainly used to rate the similarity of content between two images, and to judge the approximate degree of image content according to the level of the score.

It can be used to obtain the target location in the detection and tracking in computer vision, and find an area closest to the image according to the existing template. and then keep following. Some existing algorithms such as blobtracking,meanshift,camshift, particle filtering and so on are also needed to support this theory.

Another aspect is the image retrieval based on the image content, which is usually said to be a graph. Like giving you someone. In a huge image database, Luo lists some of the most matching images, of course, this technology may also be done, the image is abstracted into several eigenvalues, such as trace transformation, image hash or sift eigenvector, etc. To improve efficiency by returning the corresponding images based on the characteristics of the data stored in the database.

Here are some of the algorithms you have seen for some algorithmic principles and effects on the introduction.

(1) Histogram matching.

For example, image A and image B, respectively, calculate the histogram of two images, Hista,histb, and then calculate the normalized correlation coefficients of two histograms (Babbitt distance, histogram intersection distance) and so on.

The idea is to measure the similarity of images based on the differences between the simple mathematical vectors, which is a much more current method, first, the histogram can be well normalized, such as the usual 256 bin bars. Then two images with different resolution can be calculated directly by calculating the histogram to calculate the similarity is very convenient. And the computational amount is relatively small.

Disadvantages of this approach:

1, the histogram reflects the image pixel gray value of the probability distribution, such as the gray value of 200 pixels have how many, but for these pixels the original position in the histogram does not reflect, so the image of the skeleton, that is, the image of the inside exactly what kind of object, shape is what, The grayscale distribution of each block what these are omitted in the histogram information. One of the problems is that, for example, a black white image and a baixia black image have the same histogram distribution, with a similarity of 100%.

The distance measurement between 2 and two images is based on the Babbitt distance or normalized correlation coefficient, which is a very bad way to analyze the image by analyzing the mathematical vector.

3, in terms of the amount of information, the use of a numerical value to determine the similarity of two images is itself a process of information compression, then two 256 elements of the vector (assuming that the histogram has 256 bin bar) distance with a numerical value so sure there will be inaccuracy.

The following is a MATLAB demo and experimental results of image similarity calculation based on histogram distance.

% Calculate image histogram distance
% pap coefficient calculation method

M=imread (' 1.jpg ');
N=imread (' 2.jpg ');
I=rgb2gray (M);
J=rgb2gray (N);

[Count1,x]=imhist (I);
[Count2,x]=imhist (J);
Sum1=sum (COUNT1); Sum2=sum (Count2);
SumUp = sqrt (count1.*count2);
Sumdown = sqrt (sum1*sum2);
SumUp = SUM (SUMUP);
Figure (1);
Subplot (2,2,1); Imshow (I);
Subplot (2,2,2); Imshow (J);
Subplot (2,2,3); imhist (I);
Subplot (2,2,4); imhist (J);
HISTDIST=1-SQRT (1-sumup/sumdown)



It is true that there is a great disadvantage in the method of calculating image similarity. However, many people also have modified this method, such as the fragtrack algorithm, in particular, see this paper, "." Where the image is divided into a horizontal small block, and then for each block search with the most matching histogram. To calculate the similarity of two images, the information of the corresponding position of the histogram is incorporated. But the computational efficiency is very slow.

Another is to calculate an image outsourcing polygon, generally get the tracking image of the foreground map after the calculation of its outsourced polygons, according to the outsourced polygon to do delauny triangle decomposition, and then calculate the internal histogram of each triangle, for these two histogram group similar distance calculation. This incorporates the position information of the histogram.

(2) Mathematical decomposition of matrices

The image itself is a matrix, can rely on the mathematical matrix decomposition of some knowledge to obtain some of the matrix element value and distribution of some of the robustness characteristics of the image to calculate the similarity.

The most commonly used are SVD decomposition and NMF decomposition.

Below is a brief description of some of the properties of SVD decomposition, if you need to explore a bit more in-depth online some relevant literature, readers can go to explore the clearer:

<1> stability of singular values

<2> proportional invariance of singular values

<3> rotational invariance of singular values

<4> compressibility of singular values

In summary, we can see that singular value decomposition is based on the overall representation. Image singular value eigenvector has not only algebraic and geometric invariance, such as orthogonal transformation, rotation, displacement and mirror mapping, but also has good stability and anti-noise, and is widely used in pattern recognition and image analysis. The purpose of singular value decomposition is to obtain a unique and stable characteristic description, to reduce the dimension of the feature space and to improve the ability to resist disturbance and noise. However, because of the existence of negative numbers in singular vectors, the singular value decomposition can not explain its physical meaning well.

Non-negative matrix decomposition (NMF):

The main idea of NMF is to decompose nonnegative matrices into matrix and coefficient matrices which can embody the main information of the image, and can give a good explanation to the base matrix, such as the segmentation of human face, the base vector is the main concept feature of human "eyes" and "nose", and the source image is represented as a weighted combination of these features. Therefore, the NMF algorithm also plays a great role in the face recognition and other occasions.

The following experiment illustrates the application of these decomposition in SVD+NMF mathematics to the determination of image similarity, which is no longer disclosed in detail to my current subject.





Of course, based on the mathematical matrix eigenvalue calculation There are many methods such as trace transformation, invariant moment calculation and so on, of course, if there is a need for this information students can find me, I can carry out relevant help.

(3) Image similarity calculation based on feature points

Each image has its own feature points, which characterize some of the more important locations in the image, comparing the inflection point of similar functions, usually with Harris corner points and sift feature points. Then the resulting corner of the image is compared, if the number of similar corner points are more, then you can think that the two images of a higher degree of similarity. Here the main introduction is based on the SIFT operator.

For SIFT's principles and code, see the David Lower website.

David G Lowe Sift website

Then we can find the number of matching points to determine whether two images are consistent, the advantage of this algorithm is for an object, two different angles to get the photos can still find a lot of matching points, I also always think is a comprehensive results relatively accurate method, However, because each feature point needs to calculate a long-length characteristic value, it also causes the time consuming ratio of the algorithm to be large. So it is not commonly used in real-time video processing. Another benefit of this algorithm is that image corrections can be made by matching feature points found. For image correction using SIFT, see my other blog post.



At that time, I found 50 feature points for the image on the left, and if there were more than 60% matches on the right, I thought the two images were similar images.

Using the matching points found by the SIFT, and then through the affine transformation of the 6-D parameter calculation, and then the inverse transformation of the corrected image, the effect is pretty good, visible sift for anti-rotation and noise effect is really good.

For SIFT also can't all believe, generally use RANSAC for error matching point removal can achieve better results, of course, there are many sift to improve the algorithm. I hope there will be a lot of exchanges in this area.

The calculation of image similarity

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.