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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With