-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFianl.asv
91 lines (80 loc) · 3.34 KB
/
Fianl.asv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
for i = 1 : 54
% qImg = quantizeRGB(['D:\MART\Images' int2str(i) '.jpg'], 6);
qImg = imread(['E:\SV\fruits\' int2str(i) '.jpg']);
qImg1=rgb2gray(qImg);
P(:,i) = imhist(qImg1);
end
P = double(P);
T = [1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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open('re1.txt','w+');
% for i =1 : 1
% k=max(Y(:,i));
% for j = 1 : 7
% if (k==Y(j,i))
% fprintf(1,'%s\n',['class' int2str(j)]);
% end
% end
% end
testX = P(:,A);
testT1 = T(:,A);
testT=vec2ind(testT1);
testY = net(testX);
testIndices = vec2ind(testY);
plotconfusion(testT1,testY)
[c11,cm11] = confusion(testT1,testY);
fprintf('Percentage Correct Classification : %f%%\n', 100*(1-c11));
fprintf('Percentage Incorrect Classification : %f%%\n', 100*c11);
% for k1 = 1:length(pic)
% fname = [directory '/' f(pic(k1)).name];
% 0000
% img1= imread(fname);
% str=getname(k1,testT);
% str1=getname(k1,testIndices);
% str2=sprintf('%s :%s',str,str1);
%
% subplot(5,6,c);
% imshow(img1);
% title(str2);
% c=c+1;
%
% end
%
% function [str]=getname(k,test)
% %testT=vec2ind(testT1);
% testT=test(k);
%
%
% if(testT==1)
% str='Angry';
% else if(testT==2)
% str='Disgust';
% else if(testT==3)
% str='Fear';
% else if(testT==4)
% str='Happy';
% else if(testT==5)
% str='Sad';
% else if(testT==6)
% str='Surprise';
% end
% end
% end
% end
% end
% end
% end
%