LAMPIRAN
LISTING
PROGRAM
beranda.m
function varargout = beranda(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @beranda_OpeningFcn, ... 'gui_OutputFcn', @beranda_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
% End initialization code - DO NOT EDIT
% --- Executes just before beranda is made visible.
function beranda_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
handles.citra=imread('logo.jpg'); guidata(hObject,handles);
axes(handles.axes1); imshow(handles.citra);
% --- Outputs from this function are returned to the command line. function varargout = beranda_OutputFcn(hObject, eventdata, handles)
% Get default command line output from handles structure varargout{1} = handles.output;
%
-function beranda_Callback(hObject, eventdata, handles)
%
-function pelatihan_Callback(hObject, eventdata, handles) pelatihan
close beranda;
%
close beranda;
%
-function bantuan_Callback(hObject, eventdata, handles) bantuan
%
-function keluar_Callback(hObject, eventdata, handles) choice= questdlg ('Apakah Anda Ingin
Keluar?','Keluar','Ya','Tidak','Tidak'); switch choice
case 'Ya' close all; end
pelatihan.m
function varargout = pelatihan(varargin)
% Begin initialization code - DO NOT EDIT gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @pelatihan_OpeningFcn, ... 'gui_OutputFcn', @pelatihan_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
% --- Executes just before pelatihan is made visible.
function pelatihan_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
% --- Outputs from this function are returned to the command line. function varargout = pelatihan_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
% --- Executes on button press in buka.
function buka_Callback(hObject, eventdata, handles)
[nama_file, nama_path]= uigetfile({'*.jpg','File jpeg(*.jpg)'},'File Citra');
handles.citra=imread(fullfile(nama_path, nama_file)); guidata(hObject, handles);
axes(handles.axes1); imshow(handles.citra); else
return; end;
% --- Executes on button press in simpan.
function simpan_Callback(hObject, eventdata, handles) nama=get(handles.nmwajah,'string');
a=double(getimage(handles.axes3)); b=double(getimage(handles.axes4));
wajah=[reshape(a,1,16060);reshape(b,1,16060)]; set(handles.nmwajah,'string','');
if (strcmp(nama,'Azhar'))
xlswrite('simpan.xlsx',wajah,'datawajah','B2'); elseif (strcmp(nama,'Fauzi'))
xlswrite('simpan.xlsx',wajah,'datawajah','B4'); elseif(strcmp(nama,'Fiktar'))
xlswrite('simpan.xlsx',wajah,'datawajah','B6'); elseif(strcmp(nama,'Fizhta'))
xlswrite('simpan.xlsx',wajah,'datawajah','B8'); elseif(strcmp(nama,'Iqshan'))
xlswrite('simpan.xlsx',wajah,'datawajah','B10'); elseif(strcmp(nama,'Putra'))
xlswrite('simpan.xlsx',wajah,'datawajah','B12'); elseif(strcmp(nama,'Rio'))
xlswrite('simpan.xlsx',wajah,'datawajah','B14'); elseif(strcmp(nama,'Sandy'))
xlswrite('simpan.xlsx',wajah,'datawajah','B16'); elseif(strcmp(nama,'Santo'))
xlswrite('simpan.xlsx',wajah,'datawajah','B18'); elseif(strcmp(nama,'Tedja'))
xlswrite('simpan.xlsx',wajah,'datawajah','B20'); end
h= msgbox('Data telah disimpan', 'Berhasil');
% --- Executes on button press in reduksi.
function reduksi_Callback(hObject, eventdata, handles) ndata = xlsread('simpan.xlsx','datawajah');
Rataan = mean(ndata); [M,N]=size(ndata);
xnew = ndata - repmat(Rataan,M,1); [M,N]=size(xnew);
for a=1:M for b=1:N
if xnew(a,b)<=0 xnew(a,b)=0; end
end end
[junk, rindices] = sort(-1*V); V = V(rindices);
PC = PC(:,rindices); signal = ndata'* PC; ext = ndata * signal; minr=min(ext);
minr=min(minr); maxr=max(ext); maxr=max(maxr); delta=maxr-minr;
datautama = 2*(ext-minr)/delta-1;
xlswrite('hasilreduksi.xlsx', signal, 'datawajah','A2:T16061'); xlswrite('hasilreduksi.xlsx', ext, 'datawajah','A16064:T16083'); xlswrite('hasilreduksi.xlsx', datautama,
'datawajah','A16086:T16105');
h = msgbox('Data telah direduksi' , 'Berhasil' );
% --- Executes on button press in reset.
function reset_Callback(hObject, eventdata, handles) set(handles.nmwajah,'String','','Enable','on'); axes(handles.axes1);
imshow(1);
axes(handles.axes2); imshow(1);
axes(handles.axes3); imshow(1);
axes(handles.axes4); imshow(1);
% --- Executes on button press in latihlvq.
function latihlvq_Callback(hObject, eventdata, handles)
entry = xlsread('hasilreduksi.xlsx', 'datawajah', 'A16086:T16105');
target = [1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10]; entry = entry';
T = ind2vec(target); kelas=size(full(T),1); neuron = 20;
net=newlvq(minmax(entry),neuron,(1/kelas)*ones(1,kelas)); net.trainParam.epochs = 5000;
net.trainParam.goal = 0.0001; net.trainParam.lr = 0.1; net = train(net,entry,T);
net.IW{1,1}
xlswrite('bobotawal.xlsx', net.IW{1,1},'bobotawal','A'); net.LW{2,1};
xlswrite('bobotakhir.xlsx', net.LW{2,1},'bobotakhir','A');
output = sim(net,entry); H = vec2ind(output)
% --- Executes during object creation, after setting all properties. function nmwajah_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white'); end
%
-function beranda_Callback(hObject, eventdata, handles) beranda
close pelatihan;
%
-function pelatihan_Callback(hObject, eventdata, handles)
%
-function pengujian_Callback(hObject, eventdata, handles) pengujian
close pelatihan;
%
-function bantuan_Callback(hObject, eventdata, handles) bantuan
%
-function keluar_Callback(hObject, eventdata, handles) choice=questdlg ('Apakah Anda Ingin Keluar
?','Keluar','Ya','Tidak','Tidak'); switch choice
case 'Ya' close all; end
% --- Executes on button press in dtksitepi.
function dtksitepi_Callback(hObject, eventdata, handles) s=getimage(handles.axes1);
t=getimage(handles.axes2); citra_gray=rgb2gray(s); citra_gray1=rgb2gray(t);
A=citra_gray; B=citra_gray1; F1=[1 0;0 -1]; F2=[0 -1;1 0];
Gx=conv2(A,F1,'same'); Gy=conv2(A,F2,'same'); Gw=conv2(B,F1,'same'); Gz=conv2(B,F2,'same'); M=sqrt(Gx.^2+Gy.^2); N=sqrt(Gw.^2+Gz.^2); M=uint8(M);
R1=max(N,Thresh); T=graythresh(R); T1=graythresh(R1); R=im2bw(R,T); P=im2bw(R1,T1);
citra_robert=R; citra_robert1=P; axes(handles.axes3); imshow(citra_robert) axes(handles.axes4); imshow(citra_robert1);
% --- Executes on button press in pushbutton9.
function pushbutton9_Callback(hObject, eventdata, handles)
[nama_file, nama_path]= uigetfile({'*.jpg','File jpeg(*.jpg)'},'Buka File Citra');
if ~isequal(nama_file, 0)
handles.citra=imread(fullfile(nama_path, nama_file)); guidata(hObject, handles);
axes(handles.axes2); imshow(handles.citra); else
return; end;
pengujian.m
function varargout = pengujian(varargin)
% Begin initialization code - DO NOT EDIT gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @pengujian_OpeningFcn, ... 'gui_OutputFcn', @pengujian_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
% --- Executes just before pengujian is made visible.
function pengujian_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
function varargout = pengujian_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
% --- Executes on button press in buka.
function buka_Callback(hObject, eventdata, handles) set(handles.hasilnama,'String','');
set(handles.hasilwaktu,'String',''); axes(handles.axes2);
imshow(1);
[nama_file, nama_path]= uigetfile({'*.jpg','File jpeg(*.jpg)'},'Buka Pulau');
if ~isequal(nama_file, 0)
info = imfinfo([nama_path, nama_file]); filename = info.Filename;
handles.citra = imread(fullfile(nama_path, nama_file)); guidata(hObject, handles);
axes(handles.axes1); imshow(handles.citra);
set(handles.nmwajah,'string',nama_file); else
return; end;
function nmwajah_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function nmwajah_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white'); end
function edit2_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties. function edit2_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white'); end
% --- Executes on button press in ujilvq.
function ujilvq_Callback(hObject, eventdata, handles) tStart=tic;
Signal = xlsread('hasilreduksi.xlsx','datawajah','A2:T16061'); ext = xlsread('hasilreduksi.xlsx','datawajah','A16064:T16083'); entry = xlsread('hasilreduksi.xlsx','datawajah','A16086:T16105');
citrauji = reshape(citratepi,1,16060); mat_uji = flatvec*Signal;
minr=min(ext); minr=min(minr); maxr=max(ext); maxr=max(maxr); delta=maxr-minr;
data_uji = 2*(mat_uji-minr)/delta-1;
target = [1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10];
T = ind2vec(target); kelas=size(full(T),1); neuron = 20;
net=newlvq(minmax(entry),neuron,(1/kelas)*ones(1,kelas)); net = init(net);
net.IW{1,1}= xlsread('bobotawal.xlsx','bobotawal'); net.LW{2,1}= xlsread('bobotakhir.xlsx','bobotakhir');
data_uji = data_uji'; output = sim(net,data_uji) H = vec2ind(output)
if (output(1,1)<0.9) a(1,1)=0;
else
a(1,1)=1; end
if (output(2,1)<0.9) a(2,1)=0;
else
a(2,1)=1; end
if (output(3,1)<0.9) a(3,1)=0;
else
a(3,1)=1; end
if (output(4,1)<0.9) a(4,1)=0;
else
a(4,1)=1; end
if (output(5,1)<0.9) a(5,1)=0;
else
a(5,1)=1; end
if (output(6,1)<0.9) a(6,1)=0;
else
end
if (output(7,1)<0.9) a(7,1)=0;
else
a(7,1)=1; end
if (output(8,1)<0.9) a(8,1)=0;
else
a(8,1)=1; end
if (output(9,1)<0.9) a(9,1)=0;
else
a(9,1)=1; end
if (output(10,1)<0.9) a(10,1)=0;
else
a(10,1)=1; end
wajah=[a(1,1);a(2,1);a(3,1);a(4,1);a(5,1);a(6,1);a(7,1);a(8,1);a(9,1) ;a(10,1)];
wajah1 = [1; 0; 0; 0; 0; 0; 0; 0; 0; 0]; wajah2 = [0; 1; 0; 0; 0; 0; 0; 0; 0; 0]; wajah3 = [0; 0; 1; 0; 0; 0; 0; 0; 0; 0]; wajah4 = [0; 0; 0; 1; 0; 0; 0; 0; 0; 0]; wajah5 = [0; 0; 0; 0; 1; 0; 0; 0; 0; 0]; wajah6 = [0; 0; 0; 0; 0; 1; 0; 0; 0; 0]; wajah7 = [0; 0; 0; 0; 0; 0; 1; 0; 0; 0]; wajah8 = [0; 0; 0; 0; 0; 0; 0; 1; 0; 0]; wajah9 = [0; 0; 0; 0; 0; 0; 0; 0; 1; 0]; wajah10 = [0; 0; 0; 0; 0; 0; 0; 0; 0; 1];
if isequal (a,wajah1) hasilnama='Azhar';
handles.citrawajah=imread('azhar1.jpg'); elseif isequal (a,wajah2)
hasilnama='Fauzi';
handles.citrawajah=imread('fauzi1.jpg'); elseif isequal (a,wajah3)
hasilnama='Fiktar';
handles.citrawajah=imread('fiktar1.jpg'); elseif isequal (a,wajah4)
hasilnama='Fizhta';
handles.citrawajah=imread('fizhta1.jpg'); elseif isequal (a,wajah5)
hasilnama='Iqshan';
handles.citrawajah=imread('iqshan1.jpg'); elseif isequal (a,wajah6)
hasilnama='Putra';
hasilnama='Rio';
handles.citrawajah=imread('rio1.jpg'); elseif isequal (a,wajah8)
hasilnama='Sandy';
handles.citrawajah=imread('sandy1.jpg'); elseif isequal (a,wajah9)
hasilnama='Santo';
handles.citrawajah=imread('santo1.jpg'); elseif isequal (a,wajah10)
hasilnama='Tedja';
handles.citrawajah=imread('tedja1.jpg'); else
hasilnama='Tidak Dikenali'; handles.citrawajah= 1; end
set(handles.hasilnama,'String',hasilnama); guidata(hObject, handles);
axes(handles.axes2);
imshow(handles.citrawajah); waktupengujian = toc(tStart);
set(handles.hasilwaktu,'string',waktupengujian); % --- Executes on button press in reset.
function reset_Callback(hObject, eventdata, handles) set(handles.nmwajah,'String','');
set(handles.hasilnama,'String',''); set(handles.hasilwaktu,'String',''); axes(handles.axes1);
imshow(1);
axes(handles.axes2); imshow(1);
% --- Executes on button press in dtksitepi.
function dtksitepi_Callback(hObject, eventdata, handles) citra_gray=rgb2gray(handles.citra);
A=citra_gray; F1=[1 0;0 -1]; F2=[0 -1;1 0];
Gx=conv2(A,F1,'same'); Gy=conv2(A,F2,'same'); M=sqrt(Gx.^2+Gy.^2); M=uint8(M);
Thresh=0.1; R=max(M,Thresh); T=graythresh(R); R=im2bw(R,T); citra_robert=R; axes(handles.axes1); imshow(citra_robert);
%
-function beranda_Callback(hObject, eventdata, handles) beranda
close pengujian;
-function Pelatihan_Callback(hObject, eventdata, handles) pelatihan
close pengujian;
%
-function pengujian_Callback(hObject, eventdata, handles)
%
-function bantuan_Callback(hObject, eventdata, handles) bantuan
%
-function keluar_Callback(hObject, eventdata, handles) choice=questdlg ('Apakah Anda Ingin Keluar
?','Keluar','Ya','Tidak','Tidak'); switch choice
case 'Ya' close all; end
bantuan.m
function varargout = bantuan(varargin)
% Begin initialization code - DO NOT EDIT gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @bantuan_OpeningFcn, ... 'gui_OutputFcn', @bantuan_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
% End initialization code - DO NOT EDIT
% --- Executes just before bantuan is made visible.
function bantuan_OpeningFcn(hObject, eventdata, handles, varargin)
% Choose default command line output for bantuan handles.output = hObject;
% --- Outputs from this function are returned to the command line. function varargout = bantuan_OutputFcn(hObject, eventdata, handles)
% Get default command line output from handles structure varargout{1} = handles.output;
% --- Executes on selection change in listbox1.
function listbox1_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties. function listbox1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white'); end
% --- Executes on selection change in listbox2.
function listbox2_Callback(hObject, eventdata, handles)
% --- Executes during object creation, after setting all properties.
function listbox2_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white'); end
%
-function Bantuan_Callback(hObject, eventdata, handles)
%