Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to measure the cosine similarity between 2 images

I have a population matrix of 5 images with 49 extracted salience features. I want to calculate the cosine similarity in Matlab between a test image with the same extracted features 49.

like image 924
hend Avatar asked Dec 02 '22 20:12

hend


1 Answers

You could use the matlab's built in function to get the cosine distance:

pdist([u;v],'cosine')

which returns the "One minus the cosine of the included angle between points". You could then subtract the answer from one to get the 'cosine of the included angle' (similarity), like this:

1 - pdist([u;v],'cosine')

Source: Pairwise distance between pairs of objects.

like image 56
Hassan Avatar answered Dec 21 '22 20:12

Hassan