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.

有帮助吗?

解决方案

1) Transform your images of size M lines X N columns in a vector M*N lines. Keep one image in a vector u and the other image in a vector v.

2) Evaluate: cosTheta = dot(u,v)/(norm(u)*norm(v)); [As far as I know there is no function in matlab that does that]

Usually people evaluate similarities among images using the projections of them on the eigenfaces. So, before doing that, people usually evaluate the eigenfaces.

其他提示

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top