# calculating similarity scores between similar and different classes?

I have images for 99 person for each person i have 5 images . i have this function

[similarity] = ssim(img1, img2, K, window, L);where K,window ,L are previously determined with their values.

now , i need to use this function to measure intra-class similarities and inter-class similarities .

i mean i need to measure the similaity within and outside the class and put the results in 2 matrices , one contains the results of similarities within the same classes , and the other contains the results of similarities among the determined class and all other classes.

i wrote this in matlab :

%%%%for intraclass

K = [0.05 0.05];
window = ones(8);
L = 100;
[s1] = ssim(img1, img2, K, window, L);
[s2] = ssim(img1, img3, K, window, L);
[s2] = ssim(img1, img4, K, window, L);
[s3] = ssim(img1, img4, K, window, L);
[s4] = ssim(img1, img5, K, window, L);
intra_class=[s1 s2 s3 s4];
histintra_class=hist(intra_class);
plot(histintra_class);title('intra_class');

%%%%for interclass

K = [0.05 0.05];
window = ones(8);
L = 100;
[s1] = ssim(img1, img2, K, window, L);
[s2] = ssim(img1, img3, K, window, L);
[s3] = ssim(img1, img4, K, window, L);
[s4] = ssim(img1, img5, K, window, L);
inter_class=[s1 s2 s3 s4];
histinter_class=hist(inter_class);
plot(histinter_class);title)'interclass');


now how can i implement this on all my images automatically , i mean how can i read all images and finding intra and inter class similarities and get automatically the 2 matrices which are inter class and intra class

regards

• What's the question? Which part are you having trouble with? Is the function provided to you or do you need to create it? Do you already know which images are in each class? Applying a function to a bunch of inputs and putting the outputs in a table seems straightforward enough. – endolith Apr 6 '12 at 13:34
• @endolith.pleas can you see my edition? thanks a lot. – ruaa Apr 6 '12 at 14:41
• If this is just a matter of "how do I read filenames with a matlab script", it's probably a better fit on stackoverflow.com – endolith Apr 6 '12 at 15:43
• how can i transfer it to stackoverflow.com , and how i can know that this question must be posted at stackoverflow.com??.thanks – ruaa Apr 6 '12 at 23:50
• Is this your final year project perhaps? – user24145 Oct 12 '16 at 15:19

As a very simple example : To compute Euclidean distance $L_2$, which is computed between the centroid of the Clusters - as $Distance = \sqrt{(x_a- x_b)^2 + (y_a- y_b)^2 }$