% for i = 1:15
%    figure
%    imshow(data_celkem{i}.obj{1})
% end




 for j = 1:15
    geo_d(j,:) = [data_celkem{j}.Obsah{1} data_celkem{j}.Obvod{1}...
        data_celkem{j}.Kulatost{1} data_celkem{j}.Hranatost{1} ...
        data_celkem{j}.Kompaktnost{1}];
    
    vzd_d(j,:) = data_celkem{j}.Vzdalenosti{1};
    fd_d(j,:) = data_celkem{j}.FD{1};
    zm_d(j,:) = cell2mat(data_celkem{j}.ZM{1}(:));

 end

[Ikm,ckm]=kmeans(geo_d,5);
[cfm,U,obj_fcnf]=fcm(geo_d,5);

[Ikm_FD,ckm_FD]=kmeans(fd_d,5);
[cfm_FD,U_FD,obj_fcnf_FD]=fcm(fd_d,5);

[Ikm_ZM,ckm_ZM]=kmeans(zm_d,5);
[cfm_ZM,U_ZM,obj_fcnf_ZM]=fcm(zm_d,5);


figure(1)
plot(U_FD(1,:),'blue');hold on
plot(U_FD(2,:),'red');hold on;
plot(U_FD(3,:),'black');hold on;
plot(U_FD(4,:),'yellow');hold on;
plot(U_FD(5,:),'green');hold on;
legend('shluk 1','shluk 2', 'shluk 3', 'shluk 4', 'shluk 5')
xlabel('Objekt','FontSize',14)
ylabel('Stupen prislusnosti,-','FontSize',14)
title('Stupne prislusnosti objektu k jednotlivym shlukum pro FD','FontSize',14)

figure(2)
plot(U(1,:),'blue');hold on
plot(U(2,:),'red');hold on;
plot(U(3,:),'black');hold on;
plot(U(4,:),'yellow');hold on;
plot(U(5,:),'green');hold on;
legend('shluk 1','shluk 2', 'shluk 3', 'shluk 4', 'shluk 5')
xlabel('Objekt','FontSize',14)
ylabel('Stupen prislusnosti,-','FontSize',14)
title('Stupne prislusnosti objektu k jednotlivym shlukum pro GM','FontSize',14)

figure(3)
plot(U_ZM(1,:),'blue');hold on
plot(U_ZM(2,:),'red');hold on;
plot(U_ZM(3,:),'black');hold on;
plot(U_ZM(4,:),'yellow');hold on;
plot(U_ZM(5,:),'green');hold on;
legend('shluk 1','shluk 2', 'shluk 3', 'shluk 4', 'shluk 5')
xlabel('Objekt','FontSize',14)
ylabel('Stupen prislusnosti,-','FontSize',14)
title('Stupne prislusnosti objektu k jednotlivym shlukum pro ZM','FontSize',14)



% figure
% plot(geo_d(Ikm==1,1),geo_d(Ikm==1,2),'oblack','LineWidth',2);hold on
% plot(geo_d(Ikm==2,1),geo_d(Ikm==2,2),'ored','LineWidth',2); hold on;
% plot(geo_d(Ikm==3,1),geo_d(Ikm==3,2),'oblue','LineWidth',2); hold on;
% plot(geo_d(Ikm==4,1),geo_d(Ikm==4,2),'oyellow','LineWidth',2); hold on;
% plot(geo_d(Ikm==5,1),geo_d(Ikm==5,2),'ogreen','LineWidth',2); hold on;
% plot(ckm(:,1),ckm(:,2),'*b','LineWidth',2);hold off
% legend('shluk 1','shluk 2', 'shluk 3', 'shluk 4', 'shluk 5','centroidy')
% title('kMeans')