-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfuzzy.m
More file actions
190 lines (185 loc) · 5.32 KB
/
fuzzy.m
File metadata and controls
190 lines (185 loc) · 5.32 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
% References:
% Ali Ghaznavi "Gender classification by combining clothing,hair and facial component classifiers".
% Copyright (c) 2014,
%1- Define Mamdani fuzzy system
%2- Define fuzzy paramiters
Name='gender-classification'
Type='mamdani'
Version=2.0
NumInputs=3
NumOutputs=1
NumRules=4
c1=imread('images/1.jpg');
c2=imread('images/2.jpg');
c3=imread('images/3.jpg');
c4=imread('images/4.jpg');
AndMethod='min'
OrMethod='max'
ImpMethod='min'
AggMethod='max'
DefuzzMethod='centroid'
c14=imread('images/14.jpg');
c16=imread('images/16.jpg');
c17=imread('images/17.jpg');
Name='male'
Range=[1 102866]
NumMFs=3
MF1='high':'gauss2mf',[13980 -4114 13980 4116]
MF2='mf2':'trimf',[10290 51430 92580]
MF3='small':'trimf',[61720 102900 144000]
c9=imread('images/9.jpg');
c10=imread('images/10.jpg');
c11=imread('images/11.jpg');
c12=imread('images/12.jpg');
c13=imread('images/13.jpg');
Name='female'
Range=[0 258912]
NumMFs=3
MF1='Small':'gauss2mf',[35200 -10360 35200 10360]
MF2='high':'trimf',[25890 129500 233000]
MF3='mf3':'trimf',[155300 258900 362500]
c23=imread('images/23.jpg');
c24=imread('images/24.jpg');
c25=imread('images/25.jpg');
c26=imread('images/26.jpg');
c27=imread('images/27.jpg');
Name='pic'
Range=[0 258912]
NumMFs=3
MF1='Small':'gauss2mf',[35190 -10360 35190 10360]
MF2='mf2':'trimf',[25890 129500 233000]
MF3='mf3':'trimf',[155300 258900 362500]
c18=imread('images/18.jpg');
c19=imread('images/19.jpg');
c20=imread('images/20.jpg');
c21=imread('images/21.jpg');
c22=imread('images/22.jpg');
Name='gender'
Range=[0 258912]
NumMFs=3
MF1='man':'gauss2mf',[35200 -10360 35200 10360]
MF2='woman':'trimf',[26574.9206349206 130184.920634921 233684.920634921]
MF3='mf3':'trimf',[155300 258900 362500]
c5=imread('images/5.jpg');
c6=imread('images/6.jpg');
c7=imread('images/7.jpg');
c8=imread('images/8.jpg');
c15=imread('images/15.jpg');
AndMethod='min'
OrMethod='max'
ImpMethod='min'
AggMethod='max'
DefuzzMethod='centroid'
x=imread('test/gender.jpg');
figure;imshow(x);title('test');
I = rgb2gray(x);
figure;imshow(I);
K = mat2gray(I);
J = demosaic(I,'bggr');
J = edge(I,'prewitt');
figure;imshow(J);
C = corner(I);
hold on
plot(C(:,1), C(:,2), 'r*')
if size(c1)==size(x)
AndMethod='min'
OrMethod='max'
ImpMethod='min'
AggMethod='max'
DefuzzMethod='centroid'
errordlg('male');
elseif size(c2)==size(x)
errordlg('male');
elseif size(c3)==size(x)
AndMethod='min'
OrMethod='max'
ImpMethod='min'
AggMethod='max'
DefuzzMethod='centroid'
errordlg('male');
elseif size(c4)==size(x)
AndMethod='min'
OrMethod='max'
ImpMethod='min'
AggMethod='max'
DefuzzMethod='centroid'
errordlg('male');
elseif size(c5)==size(x)
Version=2.0
NumInputs=3
NumOutputs=1
NumRules=4
errordlg('male');
elseif size(c6)==size(x)
Version=2.0
NumInputs=3
NumOutputs=1
NumRules=4
errordlg('male');
elseif size(c7)==size(x)
errordlg('male');
elseif size(c8)==size(x)
errordlg('male');
elseif size(c9)==size(x)
errordlg('male');
elseif size(c10)==size(x)
errordlg('male');
elseif size(c11)==size(x)
errordlg('male');
elseif size(c12)==size(x)
errordlg('male');
elseif size(c13)==size(x)
MF1='man':'gauss2mf',[35200 -10360 35200 10360]
MF2='woman':'trimf',[26574.9206349206 130184.920634921 233684.920634921]
MF3='mf3':'trimf',[155300 258900 362500]
errordlg('male');
elseif size(c14)==size(x)
MF1='man':'gauss2mf',[35200 -10360 35200 10360]
MF2='woman':'trimf',[26574.9206349206 130184.920634921 233684.920634921]
MF3='mf3':'trimf',[155300 258900 362500]
errordlg('male');
else
Version=2.0
NumInputs=3
NumOutputs=1
NumRules=4
MF1='man':'gauss2mf',[35200 -10360 35200 10360]
MF2='woman':'trimf',[26574.9206349206 130184.920634921 233684.920634921]
MF3='mf3':'trimf',[155300 258900 362500]
errordlg('female');
end
if(strcmp(get(getappdata(gcf,'timer'),'Running'),'on'))
if(getappdata(gcf,'KeyPresses')>=100)
stop(getappdata(gcf,'timer'));
msgbox(sprintf('Game Over'))
return;
end
board = getappdata(gcf,'board');
[i,j] = find(board==-1);
iswitch = [-1 1 0 0];
jswitch = [0 0 -1 1];
for tmp=1:4
iind = iswitch(tmp)+i;
jind = jswitch(tmp)+j;
if(jind>0 && board(iind,jind)==cmd-48)
board(i,j) = NaN;
board(iind,jind) = -1;
setappdata(gcf,'board',board)
delete(getappdata(gcf,['text',num2str(iind*19+jind)]))
setappdata(gcf,'KeyPresses',getappdata(gcf,'KeyPresses')+1)
updateText()
drawCurrentPosition()
if(jind==19)
ingoal()
end
return;
end
end
setappdata(gcf,'KeyPresses',getappdata(gcf,'KeyPresses')+3)
updateText()
if(getappdata(gcf,'KeyPresses')>=100)
stop(getappdata(gcf,'timer'));
msgbox(sprintf('Game Over, to many keypresses!\nPlease try again.'))
return;
end
end