# OpenCV similarity between two images using Euclidean distance

Can we use the Euclidean distance to determine the similarity between two images

- Detect Keypoint image1, image2 using SUFT
- Compute Descriptor image1, image2 using SUFT
- double dif = norm(des1,des2,L2_norm)----> if dif is small -> can we tell that two images similar?

If yes, so what is the threshold to lead to these two images are similar.

And another question is when I compute descriptor for those images. I see that the size of them is not equal. Ex: des1 is 64x96, des2 is 64x85 So the norm function throw an exception.

So is there any way for us to normalize the descriptor to fixed size in order to using Euclidean distance or not?

And I use OpenCV Java API to do these above stuffs currently.

i'm afraid, your idea is not feasible at all.

well you could compare single descriptors(rows), but that does not make any sense, since the single descriptors are in arbitrary order.

you will have to use a BF or Flann Matcher to get matches, those will contain the id's of the keypoints, and the euclid.distance between the respective descriptors at those points. from those, you can derive some heuristic measure, like the average distance beween descriptors, or such.

Thanks for your answer berak! Could you please tell more details about "derive some heuristic measure, like the average distance beween descriptors, or such". I really need to know how to do it because what I end up to have is an meaningful number to represent distance between two descriptors.

sum up the distances, and divide by count, i guess, would be the most primitive measure

Thanks you again! I will try it.