Implementasi Jaringan Syaraf Metode Bidirectional Associative Memory Untuk Pengenalan Pola Wajah

143

LAMPIRAN HASIL PENGUJIAN TERHADAP NOISE
Noise
Pola
10
%
Pancos1
Pancos2
Pancos3
Pancos4
Pancos5
Pancos6
Pancos7
Pancos8
Pancos9
Pancos10
Pancos11
Pancos12
Pancos13
Pancos14

Pancos15
Pancos16
Pancos17




















Pancos18

X

Pancos19



Pancos20

X

20
%

X
X
X

X


X
X
X
X
X
X
X
X
X
X
X
X
X
X
X

30

%

X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X

X
X

40
%

X
X
X
X
X
X
X
X
X
X
X
X
X
X

X
X
X
X
X
X

50
%

X
X
X
X
X
X
X
X
X
X

X
X
X
X
X
X
X
X
X
X

60
%

X
X
X
X
X
X

X
X
X
X
X
X
X
X
X
X
X
X
X
X

70
%

80
%


X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X

X

X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X

X
X

90
%

X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X

100
%

X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X
X

Keterangan:



= Dikenali

X

= Dikenali sebagai pola lain

Universitas Sumatera Utara

144

Noise
Pola
10
%
Hayati1
Hayati2
Hayati3
Hayati4
Hayati5
Hayati6
Hayati7
Hayati8
Hayati9
Hayati10
Hayati11
Hayati12
Hayati13
Hayati14
Hayati15
Hayati16
Hayati17
Hayati18
Hayati19
Hayati20






















20
%






















30
%

40
%

50%

60
%





X

X

X










X
X
X

X
X
X














X

X
X
X
X
X
X

X
X
X
X
X
X










X
X
X

X
X
X
X





X
X
X
X

X
X
X
X

X
X
X
X
X
X
X
X
X

X
X


X



70
%

80
%

X
X

90
%

100
%

X
X
X
X
X
X

X
X
X
X
X
X
X
X
X

X
X
X
X
X
X
X
X
X

X
X
X
X
X
X
X
X
X









X
X
X
X
X
X
X
X
X
X

X
X
X
X
X
X
X
X
X
X

X
X
X
X
X
X
X
X
X
X

X
X
X
X
X
X
X
X
X
X



Universitas Sumatera Utara

145

Noise
Pola
10
%
Winda1
Winda2
Winda3
Winda4
Winda5
Winda6
Winda7
Winda8
Winda9
Winda10
Winda11
Winda12
Winda13
Winda14
Winda15
Winda16
Winda17
Winda18
Winda19
Winda20






















20
%






















30
%






















40
%






















50
%






















60
%






















70
%

80
%











































90
%






















100
%






















Universitas Sumatera Utara

146

Noise
Pola
10
%
Dame1
Dame2
Dame3
Dame4
Dame5
Dame6
Dame7
Dame8
Dame9
Dame10
Dame11
Dame12
Dame13
Dame14
Dame15
Dame16
Dame17
Dame18
Dame19
Dame20






















20
%






















30
%






















40
%






















50%






















60
%






















70
%

80
%











































90
%






















100
%






















Universitas Sumatera Utara

147

LAMPIRAN LISTING PROGRAM

formutama.m (Antarmuka Utama)
function varargout = formutama(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name',
mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @formutama_OpeningFcn, ...
'gui_OutputFcn', @formutama_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback',
[]);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end

function formutama_OpeningFcn(hObject, eventdata, handles,
varargin)
handles.output = hObject;
guidata(hObject, handles);
function varargout = formutama_OutputFcn(hObject, eventdata,
handles)
varargout{1} = handles.output;

% --- Executes on button press in pelatihan.
function pelatihan_Callback(hObject, eventdata, handles)
formpelatihan;
close formutama
% --- Executes on button press in keluar.
function keluar_Callback(hObject, eventdata, handles)
selection=tutup('Title','Keluar');
switch lower(selection)
case 'yes'
close
case 'no'

Universitas Sumatera Utara

148

%no action
end
% --- Executes on button press in deskripsi.
function deskripsi_Callback(hObject, eventdata, handles)
deskripsi;
close formutama
% --- Executes on button press in pengujian.
function pengujian_Callback(hObject, eventdata, handles)
formpengujian;
close formutama

formpelatihan.m (Bantuan)
function varargout = formpelatihan(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name',
mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @formpelatihan_OpeningFcn,
...
'gui_OutputFcn', @formpelatihan_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback',
[]);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
function formpelatihan_OpeningFcn(hObject, eventdata, handles,
varargin)
handles.output = hObject;
guidata(hObject, handles);
function varargout = formpelatihan_OutputFcn(hObject, eventdata,
handles)
varargout{1} = handles.output;
% --- Executes on selection change in popmenu1.
function popmenu1_Callback(hObject, eventdata, handles)
val = get (hObject,'Value');

Universitas Sumatera Utara

149

if(val==1)
nmfile='pancos';
elseif(val==2)
nmfile='dame';
elseif(val==3)
nmfile='hayati';
elseif(val==4)
nmfile='winda';
else
nmfile='kosong';
end
gbr1 = imread([nmfile '1' '.jpg']);
axes(handles.axes1);
imshow(gbr1)
handles.gray=rgb2gray(gbr1);
handles.thresh=graythresh(handles.gray);
gbr1=im2bw(handles.gray,handles.thresh);
axes(handles.axes21);
imshow(gbr1)
[l k] = size(gbr1);
for i=1:1:l
for j=1:1:k
if (gbr1(i,j)==0)
bar(i,j)=-1;
else
bar(i,j)=1;
end
end
end
fid=fopen([nmfile '1' '.txt'],'w');
fprintf(fid,' %d',bar);
fclose(fid);
gbr2 = imread([nmfile '2' '.jpg']);
axes(handles.axes2);
imshow(gbr2)
handles.gray=rgb2gray(gbr2);
handles.thresh=graythresh(handles.gray);
gbr2=im2bw(handles.gray,handles.thresh);
axes(handles.axes22);
imshow(gbr2)
for i=1:1:l
for j=1:1:k
if (gbr2(i,j)==0)
bar(i,j)=-1;
else
bar(i,j)=1;
end
end
end
fid=fopen([nmfile '2' '.txt'],'w');
fprintf(fid,' %d',bar);
fclose(fid);

Universitas Sumatera Utara

150

gbr3 = imread([nmfile '3' '.jpg']);
axes(handles.axes3);
imshow(gbr3)
handles.gray=rgb2gray(gbr3);
handles.thresh=graythresh(handles.gray);
gbr3=im2bw(handles.gray,handles.thresh);
axes(handles.axes23);
imshow(gbr3)
for i=1:1:l
for j=1:1:k
if (gbr3(i,j)==0)
bar(i,j)=-1;
else
bar(i,j)=1;
end
end
end
fid=fopen([nmfile '3' '.txt'],'w');
fprintf(fid,' %d',bar);
fclose(fid);
gbr4 = imread([nmfile '4' '.jpg']);
axes(handles.axes4);
imshow(gbr4)
handles.gray=rgb2gray(gbr4);
handles.thresh=graythresh(handles.gray);
gbr4=im2bw(handles.gray,handles.thresh);
axes(handles.axes24);
imshow(gbr4)
for i=1:1:l
for j=1:1:k
if (gbr4(i,j)==0)
bar(i,j)=-1;
else
bar(i,j)=1;
end
end
end
fid=fopen([nmfile '4.txt'],'w');
fprintf(fid,' %d',bar);
fclose(fid);
gbr5 = imread([nmfile '5' '.jpg']);
axes(handles.axes5);
imshow(gbr5)
handles.gray=rgb2gray(gbr5);
handles.thresh=graythresh(handles.gray);
gbr5=im2bw(handles.gray,handles.thresh);
axes(handles.axes25);
imshow(gbr5)

Universitas Sumatera Utara

151

for i=1:1:l
for j=1:1:k
if (gbr5(i,j)==0)
bar(i,j)=-1;
else
bar(i,j)=1;
end
end
end
fid=fopen([nmfile '5' '.txt'],'w');
fprintf(fid,' %d',bar);
fclose(fid);

gbr6 = imread([nmfile '6' '.jpg']);
axes(handles.axes6);
imshow(gbr6)
handles.gray=rgb2gray(gbr6);
handles.thresh=graythresh(handles.gray);
gbr6=im2bw(handles.gray,handles.thresh);
axes(handles.axes26);
imshow(gbr6)
for i=1:1:l
for j=1:1:k
if (gbr6(i,j)==0)
bar(i,j)=-1;
else
bar(i,j)=1;
end
end
end
fid=fopen([nmfile '6' '.txt'],'w');
fprintf(fid,' %d',bar);
fclose(fid);

gbr7 = imread([nmfile '7' '.jpg']);
axes(handles.axes7);
imshow(gbr7)
handles.gray=rgb2gray(gbr7);
handles.thresh=graythresh(handles.gray);
gbr7=im2bw(handles.gray,handles.thresh);
axes(handles.axes27);
imshow(gbr7)
for i=1:1:l
for j=1:1:k
if (gbr7(i,j)==0)
bar(i,j)=-1;
else
bar(i,j)=1;
end

Universitas Sumatera Utara

152

end
end
fid=fopen([nmfile '7' '.txt'],'w');
fprintf(fid,' %d',bar);
fclose(fid);
gbr8 = imread([nmfile '8' '.jpg']);
axes(handles.axes8);
imshow(gbr8)
handles.gray=rgb2gray(gbr8);
handles.thresh=graythresh(handles.gray);
gbr8=im2bw(handles.gray,handles.thresh);
axes(handles.axes28);
imshow(gbr8)
for i=1:1:l
for j=1:1:k
if (gbr8(i,j)==0)
bar(i,j)=-1;
else
bar(i,j)=1;
end
end
end
fid=fopen([nmfile '8' '.txt'],'w');
fprintf(fid,' %d',bar);
fclose(fid);

gbr9 = imread([nmfile '9' '.jpg']);
axes(handles.axes9);
imshow(gbr9)
handles.gray=rgb2gray(gbr9);
handles.thresh=graythresh(handles.gray);
gbr9=im2bw(handles.gray,handles.thresh);
axes(handles.axes29);
imshow(gbr9)
for i=1:1:l
for j=1:1:k
if (gbr9(i,j)==0)
bar(i,j)=-1;
else
bar(i,j)=1;
end
end
end
fid=fopen([nmfile '9' '.txt'],'w');
fprintf(fid,' %d',bar);
fclose(fid);
gbr10 = imread([nmfile '10' '.jpg']);

Universitas Sumatera Utara

153

axes(handles.axes10);
imshow(gbr10)
handles.gray=rgb2gray(gbr10);
handles.thresh=graythresh(handles.gray);
gbr10=im2bw(handles.gray,handles.thresh);
axes(handles.axes30);
imshow(gbr10)
for i=1:1:l
for j=1:1:k
if (gbr10(i,j)==0)
bar(i,j)=-1;
else
bar(i,j)=1;
end
end
end
fid=fopen([nmfile '10' '.txt'],'w');
fprintf(fid,' %d',bar);
fclose(fid);
gbr11 = imread([nmfile '11' '.jpg']);
axes(handles.axes11);
imshow(gbr11)
handles.gray=rgb2gray(gbr11);
handles.thresh=graythresh(handles.gray);
gbr11=im2bw(handles.gray,handles.thresh);
axes(handles.axes31);
imshow(gbr11)
for i=1:1:l
for j=1:1:k
if (gbr11(i,j)==0)
bar(i,j)=-1;
else
bar(i,j)=1;
end
end
end
fid=fopen([nmfile '11' '.txt'],'w');
fprintf(fid,' %d',bar);
fclose(fid);
gbr12 = imread([nmfile '12' '.jpg']);
axes(handles.axes12);
imshow(gbr12)
handles.gray=rgb2gray(gbr12);
handles.thresh=graythresh(handles.gray);
gbr12=im2bw(handles.gray,handles.thresh);
axes(handles.axes32);
imshow(gbr12)
for i=1:1:l

Universitas Sumatera Utara

154

for j=1:1:k
if (gbr12(i,j)==0)
bar(i,j)=-1;
else
bar(i,j)=1;
end
end
end
fid=fopen([nmfile '12' '.txt'],'w');
fprintf(fid,' %d',bar);
fclose(fid);

gbr13 = imread([nmfile '13' '.jpg']);
axes(handles.axes13);
imshow(gbr13)
handles.gray=rgb2gray(gbr13);
handles.thresh=graythresh(handles.gray);
gbr13=im2bw(handles.gray,handles.thresh);
axes(handles.axes33);
imshow(gbr13)
for i=1:1:l
for j=1:1:k
if (gbr13(i,j)==0)
bar(i,j)=-1;
else
bar(i,j)=1;
end
end
end
fid=fopen([nmfile '13' '.txt'],'w');
fprintf(fid,' %d',bar);
fclose(fid);

gbr14 = imread([nmfile '14' '.jpg']);
axes(handles.axes14);
imshow(gbr14)
handles.gray=rgb2gray(gbr14);
handles.thresh=graythresh(handles.gray);
gbr14=im2bw(handles.gray,handles.thresh);
axes(handles.axes34);
imshow(gbr14)
for i=1:1:l
for j=1:1:k
if (gbr14(i,j)==0)
bar(i,j)=-1;
else
bar(i,j)=1;
end
end

Universitas Sumatera Utara

155

end
fid=fopen([nmfile '14' '.txt'],'w');
fprintf(fid,' %d',bar);
fclose(fid);

gbr15 = imread([nmfile '15' '.jpg']);
axes(handles.axes15);
imshow(gbr15)
handles.gray=rgb2gray(gbr15);
handles.thresh=graythresh(handles.gray);
gbr15=im2bw(handles.gray,handles.thresh);
axes(handles.axes35);
imshow(gbr15)
for i=1:1:l
for j=1:1:k
if (gbr15(i,j)==0)
bar(i,j)=-1;
else
bar(i,j)=1;
end
end
end
fid=fopen([nmfile '15' '.txt'],'w');
fprintf(fid,' %d',bar);
fclose(fid);

gbr16 = imread([nmfile '16' '.jpg']);
axes(handles.axes16);
imshow(gbr16)
handles.gray=rgb2gray(gbr16);
handles.thresh=graythresh(handles.gray);
gbr16=im2bw(handles.gray,handles.thresh);
axes(handles.axes36);
imshow(gbr16)
for i=1:1:l
for j=1:1:k
if (gbr16(i,j)==0)
bar(i,j)=-1;
else
bar(i,j)=1;
end
end
end
fid=fopen([nmfile '16' '.txt'],'w');
fprintf(fid,' %d',bar);
fclose(fid);

Universitas Sumatera Utara

156

gbr17 = imread([nmfile '17' '.jpg']);
axes(handles.axes17);
imshow(gbr17)
handles.gray=rgb2gray(gbr17);
handles.thresh=graythresh(handles.gray);
gbr17=im2bw(handles.gray,handles.thresh);
axes(handles.axes37);
imshow(gbr17)
for i=1:1:l
for j=1:1:k
if (gbr17(i,j)==0)
bar(i,j)=-1;
else
bar(i,j)=1;
end
end
end
fid=fopen([nmfile '17' '.txt'],'w');
fprintf(fid,' %d',bar);
fclose(fid);
gbr18 = imread([nmfile '18' '.jpg']);
axes(handles.axes18);
imshow(gbr18)
handles.gray=rgb2gray(gbr18);
handles.thresh=graythresh(handles.gray);
gbr18=im2bw(handles.gray,handles.thresh);
axes(handles.axes38);
imshow(gbr18)
for i=1:1:l
for j=1:1:k
if (gbr18(i,j)==0)
bar(i,j)=-1;
else
bar(i,j)=1;
end
end
end
fid=fopen([nmfile '18' '.txt'],'w');
fprintf(fid,' %d',bar);
fclose(fid);
gbr19 = imread([nmfile '19' '.jpg']);
axes(handles.axes19);
imshow(gbr19)
handles.gray=rgb2gray(gbr19);
handles.thresh=graythresh(handles.gray);
gbr19=im2bw(handles.gray,handles.thresh);
axes(handles.axes39);
imshow(gbr19)

Universitas Sumatera Utara

157

for i=1:1:l
for j=1:1:k
if (gbr19(i,j)==0)
bar(i,j)=-1;
else
bar(i,j)=1;
end
end
end
fid=fopen([nmfile '19' '.txt'],'w');
fprintf(fid,' %d',bar);
fclose(fid);
gbr20 = imread([nmfile '20' '.jpg']);
axes(handles.axes20);
imshow(gbr20)
handles.gray=rgb2gray(gbr20);
handles.thresh=graythresh(handles.gray);
gbr20=im2bw(handles.gray,handles.thresh);
axes(handles.axes40);
imshow(gbr20)
for i=1:1:l
for j=1:1:k
if (gbr20(i,j)==0)
bar(i,j)=-1;
else
bar(i,j)=1;
end
end
end
fid=fopen([nmfile '20' '.txt'],'w');
fprintf(fid,' %d',bar);
fclose(fid);
% --- Executes during object creation, after setting all
properties.
function popmenu1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in latih.
function latih_Callback(hObject, eventdata, handles)
clear all;
clc;
mulai='mulai'
x1_1=textread('pancos1.txt');
x1_2=textread('pancos2.txt');
x1_3=textread('pancos3.txt');

Universitas Sumatera Utara

158

x1_4=textread('pancos4.txt');
x1_5=textread('pancos5.txt');
x1_6=textread('pancos6.txt');
x1_7=textread('pancos7.txt');
x1_8=textread('pancos8.txt');
x1_9=textread('pancos9.txt');
x1_10=textread('pancos10.txt');
x1_11=textread('pancos11.txt');
x1_12=textread('pancos12.txt');
x1_13=textread('pancos13.txt');
x1_14=textread('pancos14.txt');
x1_15=textread('pancos15.txt');
x1_16=textread('pancos16.txt');
x1_17=textread('pancos17.txt');
x1_18=textread('pancos18.txt');
x1_19=textread('pancos19.txt');
x1_20=textread('pancos20.txt');
x2_1=textread('dame1.txt');
x2_2=textread('dame2.txt');
x2_3=textread('dame3.txt');
x2_4=textread('dame4.txt');
x2_5=textread('dame5.txt');
x2_6=textread('dame6.txt');
x2_7=textread('dame7.txt');
x2_8=textread('dame8.txt');
x2_9=textread('dame9.txt');
x2_10=textread('dame10.txt');
x2_11=textread('dame11.txt');
x2_12=textread('dame12.txt');
x2_13=textread('dame13.txt');
x2_14=textread('dame14.txt');
x2_15=textread('dame15.txt');
x2_16=textread('dame16.txt');
x2_17=textread('dame17.txt');
x2_18=textread('dame18.txt');
x2_19=textread('dame19.txt');
x2_20=textread('dame20.txt');
x3_1=textread('hayati1.txt');
x3_2=textread('hayati2.txt');
x3_3=textread('hayati3.txt');
x3_4=textread('hayati4.txt');
x3_5=textread('hayati5.txt');
x3_6=textread('hayati6.txt');
x3_7=textread('hayati7.txt');
x3_8=textread('hayati8.txt');
x3_9=textread('hayati9.txt');
x3_10=textread('hayati10.txt');
x3_11=textread('hayati11.txt');
x3_12=textread('hayati12.txt');
x3_13=textread('hayati13.txt');
x3_14=textread('hayati14.txt');
x3_15=textread('hayati15.txt');
x3_16=textread('hayati16.txt');
x3_17=textread('hayati17.txt');

Universitas Sumatera Utara

159

x3_18=textread('hayati18.txt');
x3_19=textread('hayati19.txt');
x3_20=textread('hayati20.txt');
x4_1=textread('winda1.txt');
x4_2=textread('winda2.txt');
x4_3=textread('winda3.txt');
x4_4=textread('winda4.txt');
x4_5=textread('winda5.txt');
x4_6=textread('winda6.txt');
x4_7=textread('winda7.txt');
x4_8=textread('winda8.txt');
x4_9=textread('winda9.txt');
x4_10=textread('winda10.txt');
x4_11=textread('winda11.txt');
x4_12=textread('winda12.txt');
x4_13=textread('winda13.txt');
x4_14=textread('winda14.txt');
x4_15=textread('winda15.txt');
x4_16=textread('winda16.txt');
x4_17=textread('winda17.txt');
x4_18=textread('winda18.txt');
x4_19=textread('winda19.txt');
x4_20=textread('winda20.txt');
y_1=[1 1 1];
y_2=[-1 -1 1];
y_3=[1 1 -1];
y_4=[-1 -1 -1];
W=
(x1_1'*y_1)+(x1_2'*y_1)+(x1_3'*y_1)+(x1_4'*y_1)+(x1_5'*y_1)+(x1_6'
*y_1)+(x1_7'*y_1)+(x1_8'*y_1)+(x1_9'*y_1)+(x1_10'*y_1)+(x1_11'*y_1
)+(x1_12'*y_1)+(x1_13'*y_1)+(x1_14'*y_1)+(x1_15'*y_1)+(x1_16'*y_1)
+(x1_17'*y_1)+(x1_18'*y_1)+(x1_19'*y_1)+(x1_20'*y_1);
W=W+(x2_1'*y_2)+(x2_2'*y_2)+(x2_3'*y_2)+(x2_4'*y_2)+(x2_5'*y_2)+(x
2_6'*y_2)+(x2_7'*y_2)+(x2_8'*y_2)+(x2_9'*y_2)+(x2_10'*y_2)+(x2_11'
*y_2)+(x2_12'*y_2)+(x2_13'*y_2)+(x2_14'*y_2)+(x2_15'*y_2)+(x2_16'*
y_2)+(x2_17'*y_2)+(x2_18'*y_2)+(x2_19'*y_2)+(x2_20'*y_2);
W=W+(x3_1'*y_3)+(x3_2'*y_3)+(x3_3'*y_3)+(x3_4'*y_3)+(x3_5'*y_3)+(x
3_6'*y_3)+(x3_7'*y_3)+(x3_8'*y_3)+(x3_9'*y_3)+(x3_10'*y_3)+(x3_11'
*y_3)+(x3_12'*y_3)+(x3_13'*y_3)+(x3_14'*y_3)+(x3_15'*y_3)+(x3_16'*
y_3)+(x3_17'*y_3)+(x3_18'*y_3)+(x3_19'*y_3)+(x3_20'*y_3);
W=W+(x4_1'*y_4)+(x4_2'*y_4)+(x4_3'*y_4)+(x4_4'*y_4)+(x4_5'*y_4)+(x
4_6'*y_4)+(x4_7'*y_4)+(x4_8'*y_4)+(x4_9'*y_4)+(x4_10'*y_4)+(x4_11'
*y_4)+(x4_12'*y_4)+(x4_13'*y_4)+(x4_14'*y_4)+(x4_15'*y_4)+(x4_16'*
y_4)+(x4_17'*y_4)+(x4_18'*y_4)+(x4_19'*y_4)+(x4_20'*y_4);
%disp(W)
kondisi=true;
tdkdikenali=0;
takKenal=0;
pro=0;
while(kondisi && pro