Академический Документы
Профессиональный Документы
Культура Документы
b. Daftar Komponen
No Komponen Properti
1 Axes1 Tag axes1
XTick Kosong
YTick Kosong
2 Axes2 Tag axes2
XTick Kosong
YTick Kosong
3 Axes3 Tag axes3
XTick Kosong
YTick Kosong
4 Axes4 Tag axes4
XTick Kosong
YTick Kosong
5 Pushbutton1 String open image 1
Tag image1_pushbutton
6 Pushbutton2 String open image 2
Tag Image2_pushbutton
7 Pushbutton3 String Start Training
Tag start_training_pushbutton
8 Pushbutton4 String open testing image
Tag image_testing_pushbutton
9 Pushbutton5 String Start Testing
Tag start_testing_pushbutton
10 Listbox Tag show_listbox
11 Text1 String Hasil Testing
Tag text1
12 Text2 String Bobot (w) dan Bias (b) hasil
Tag text2
training
c. Kode Program
open image 1
open image 2
Start Training
for i=1:1:jml_baris
for j=1:1:jml_kolom
if s2(i,j)>=200 %putih
s2_temp(i,j)=-1;
else %hitam
s2_temp(i,j)=1;
end
end
end
%jml_pola= 2; % 2 citra
k=0;
for i=1:1:jml_baris
for j=1:1:jml_kolom
k=k+1;
s(1,k)=s1_temp(i,j);
end
end
t1=1; %target untuk citra 1 simpan sbg kolom
%akhir dalam array s
s(1,k+1)=t1;
k=0;
for i=1:1:jml_baris
for j=1:1:jml_kolom
k=k+1;
s(2,k)=s2_temp(i,j);
end
end
t2=-1; %target untuk citra 2
s(2,k+1) = t2;
for i=1:1:jml_input
w(i)=0;
end
b=0;
for n=1:1:jml_pola
for i=1:1:jml_input
x(i) = s(n,i); %%x(i) = s(i)
end
t(n)=s(n,jml_input+1); %target
y(n)=t(n); %s(n,jml_input+1); %% y = target
%perbaiki bobot dan bias
for i=1:1:jml_input
w(i) = w(i) + x(i)*y(n); % w_baru =w_lama+x(i)* y
handles.w_final(i)=w(i);
end
b=b+y(n); %b_baru= b_lama + y
handles.b_final=b;
end
%%tampilkan bobot dan bias hasil pelatihan
for i=1:1:jml_input
disp(strcat('w',num2str(i),' = ',num2str(w(i))));
end
disp(strcat('b = ',num2str(b)));
guidata(hObject,handles);
%yang lain
imshow(handles.im_testing);
guidata(hObject,handles);
Start Testing
s=rgb2gray(handles.im_testing);
jml_baris=size(s,1);
jml_kolom=size(s,2);
for i=1:1:jml_baris
for j=1:1:jml_kolom
if s(i,j)>=200 %putih
s_temp(i,j)=-1;
else %hitam
s_temp(i,j)=1;
end
end
end
k=0;
for i=1:1:jml_baris
for j=1:1:jml_kolom
k=k+1;
s_vektor(k)=s_temp(i,j);
end
end
jml_input = k;
net=0;
for i=1:1:jml_input
x(i)=s_vektor(i);
net=net+x(i)*handles.w_final(i);
end
net=net+handles.b_final
axes(handles.axes4);
if net>=0
f=1
imshow(handles.im_original1);
else
f=-1
imshow(handles.im_original2);
end
Show listbox
function show_listbox_Callback(hObject, eventdata, handles)
% hObject handle to show_listbox (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
JURUSAN FISIKA
FAKULTAS MATEMATIKA DAN ILMU PENGETAHUAN ALAM
UNIVERSITAS UDAYANA
2014