Professional Documents
Culture Documents
MENU UTAMA
function varargout = menuutama(varargin)
% MENUUTAMA MATLAB code for menuutama.fig
%
MENUUTAMA, by itself, creates a new MENUUTAMA or raises the
existing
%
singleton*.
%
%
H = MENUUTAMA returns the handle to a new MENUUTAMA or the
handle to
%
the existing singleton*.
%
%
MENUUTAMA('CALLBACK',hObject,eventData,handles,...) calls
the local
%
function named CALLBACK in MENUUTAMA.M with the given input
arguments.
%
%
MENUUTAMA('Property','Value',...) creates a new MENUUTAMA
or raises the
%
existing singleton*. Starting from the left, property
value pairs are
%
applied to the GUI before menuutama_OpeningFcn gets called.
An
%
unrecognized property name or invalid value makes property
application
%
stop. All inputs are passed to menuutama_OpeningFcn via
varargin.
%
%
*See GUI Options on GUIDE's Tools menu. Choose "GUI allows
only one
%
instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help menuutama
% Last Modified by GUIDE v2.5 03-Jul-2015 23:49:42
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',
mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @menuutama_OpeningFcn, ...
'gui_OutputFcn', @menuutama_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
% --- Outputs from this function are returned to the command line.
function varargout = menuutama_OutputFcn(hObject, eventdata,
handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject
handle to figure
% eventdata reserved - to be defined in a future version of
MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
delete(handles.figure1)
% --- Executes on button press in btnidentifikasi.
function btnidentifikasi_Callback(hObject, eventdata, handles)
% hObject
handle to btnidentifikasi (see GCBO)
% eventdata reserved - to be defined in a future version of
MATLAB
% handles
structure with handles and user data (see GUIDATA)
delete(handles.figure1)
identifikasi;
% --- Executes on button press in btninfo.
function btninfo_Callback(hObject, eventdata, handles)
% hObject
handle to btninfo (see GCBO)
% eventdata reserved - to be defined in a future version of
MATLAB
% handles
structure with handles and user data (see GUIDATA)
delete(handles.figure1)
infobatik;
% --- Executes on button press in btnproses.
function btnproses_Callback(hObject, eventdata, handles)
% hObject
handle to btnproses (see GCBO)
% eventdata reserved - to be defined in a future version of
MATLAB
% handles
structure with handles and user data (see GUIDATA)
delete(handles.figure1)
pelatihan;
INFO BATIK
function varargout = infobatik(varargin)
% INFOBATIK MATLAB code for infobatik.fig
%
INFOBATIK, by itself, creates a new INFOBATIK or raises the
existing
%
singleton*.
%
%
H = INFOBATIK returns the handle to a new INFOBATIK or the
handle to
%
the existing singleton*.
%
%
INFOBATIK('CALLBACK',hObject,eventData,handles,...) calls
the local
%
function named CALLBACK in INFOBATIK.M with the given input
arguments.
%
%
INFOBATIK('Property','Value',...) creates a new INFOBATIK
or raises the
%
existing singleton*. Starting from the left, property
value pairs are
%
applied to the GUI before infobatik_OpeningFcn gets called.
An
%
unrecognized property name or invalid value makes property
application
%
stop. All inputs are passed to infobatik_OpeningFcn via
varargin.
%
%
*See GUI Options on GUIDE's Tools menu. Choose "GUI allows
only one
%
instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help infobatik
% Last Modified by GUIDE v2.5 28-Jul-2015 21:07:29
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',
mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @infobatik_OpeningFcn, ...
'gui_OutputFcn', @infobatik_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
% --- Outputs from this function are returned to the command line.
eventdata,
(see VARARGOUT);
version of
(see GUIDATA)
% handles
PELATIHAN
function varargout = pelatihan(varargin)
% PELATIHAN MATLAB code for pelatihan.fig
%
PELATIHAN, by itself, creates a new PELATIHAN or raises the
existing
%
singleton*.
%
%
H = PELATIHAN returns the handle to a new PELATIHAN or the
handle to
%
the existing singleton*.
%
%
PELATIHAN('CALLBACK',hObject,eventData,handles,...) calls
the local
%
function named CALLBACK in PELATIHAN.M with the given input
arguments.
%
%
PELATIHAN('Property','Value',...) creates a new PELATIHAN
or raises the
%
existing singleton*. Starting from the left, property
value pairs are
%
applied to the GUI before pelatihan_OpeningFcn gets called.
An
%
unrecognized property name or invalid value makes property
application
%
stop. All inputs are passed to pelatihan_OpeningFcn via
varargin.
%
%
*See GUI Options on GUIDE's Tools menu. Choose "GUI allows
only one
%
instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help pelatihan
% Last Modified by GUIDE v2.5 03-Jul-2015 22:53:55
% 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
% End initialization code - DO NOT EDIT
% --- Outputs from this function are returned to the command line.
function varargout = pelatihan_OutputFcn(hObject, eventdata,
handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject
handle to figure
% eventdata reserved - to be defined in a future version of
MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% eventdata
MATLAB
% handles
end
set(hObject,'BackgroundColor','white');
=
=
=
=
wcodemat(a1,ncolors);
wcodemat(h1,ncolors);
wcodemat(v1,ncolors);
wcodemat(d1,ncolors);
cod_a1
cod_h1
cod_v1
cod_d1
=
=
=
=
wkeep(cod_a1,
wkeep(cod_h1,
wkeep(cod_v1,
wkeep(cod_d1,
sz/2);
sz/2);
sz/2);
sz/2);
if level == 1
else
%Ekstrak koefisien level 2
a2 = appcoef2(wc,s,wname,2);
h2 = detcoef2('h',wc,s,2);
v2 = detcoef2('v',wc,s,2);
d2 = detcoef2('d',wc,s,2);
cod_a2
cod_h2
cod_v2
cod_d2
=
=
=
=
wcodemat(a2,ncolors);
wcodemat(h2,ncolors);
wcodemat(v2,ncolors);
wcodemat(d2,ncolors);
cod_a2
cod_h2
cod_v2
cod_d2
end
%Mendapatkan nilai entropi dan energi
entropi = wentropy(wc, 'shannon');
energi = wentropy(wc,'log energy');
strent = mat2str(entropi);
strene = mat2str(energi);
%Menampilkan nilai entropi dan energi
set(proyek.txtentropi, 'String', strent);
=
=
=
=
wkeep(cod_a2,
wkeep(cod_h2,
wkeep(cod_v2,
wkeep(cod_d2,
sz/4);
sz/4);
sz/4);
sz/4);
=
=
=
=
wcodemat(ra2,ncolors);
wcodemat(rh2,ncolors);
wcodemat(rv2,ncolors);
wcodemat(rd2,ncolors);
else
ra1
rh1
rv1
rd1
=
=
=
=
wrcoef2('a',wc,s,wname,1);
wrcoef2('h',wc,s,wname,1);
wrcoef2('v',wc,s,wname,1);
wrcoef2('d',wc,s,wname,1);
cod_ra1
cod_rh1
cod_rv1
cod_rd1
=
=
=
=
wcodemat(ra1,ncolors);
wcodemat(rh1,ncolors);
wcodemat(rv1,ncolors);
wcodemat(rd1,ncolors);
end
%Rekonstruksi citra cara 2
XXhat = waverec2(wc,s,wname);
%sprintf('Kesalahan rekonstruksi (menggunakan waverec2) = %g',
max(max(abs(X-XXhat))))
%Implementasi threshold dengan nilai ambang = 20
thr = 20;
[X_comp,wc_comp,s_comp,perf0,perfL2] =
wdencmp('gbl',wc,s,wname,2,thr,'h',1);
%Thresholding spasial
thr_h = [21 17];
% horizontal threshold.
thr_d = [23 19];
% diagonal threshold.
thr_v = [21 17];
% vertical threshold.
thr = [thr_h; thr_d; thr_v];
[X_comp,wc_comp,s_comp,perf0,perfL2] =
wdencmp('lvd',X,wname,2,thr,'h');
% handles
clc
PROSES IDENTIFIKASI
function varargout = identifikasi(varargin)
% IDENTIFIKASI MATLAB code for identifikasi.fig
%
IDENTIFIKASI, by itself, creates a new IDENTIFIKASI or
raises the existing
%
singleton*.
%
%
H = IDENTIFIKASI returns the handle to a new IDENTIFIKASI
or the handle to
%
the existing singleton*.
%
%
IDENTIFIKASI('CALLBACK',hObject,eventData,handles,...)
calls the local
%
function named CALLBACK in IDENTIFIKASI.M with the given
input arguments.
%
%
IDENTIFIKASI('Property','Value',...) creates a new
IDENTIFIKASI or raises the
%
existing singleton*. Starting from the left, property
value pairs are
%
applied to the GUI before identifikasi_OpeningFcn gets
called. An
%
unrecognized property name or invalid value makes property
application
%
stop. All inputs are passed to identifikasi_OpeningFcn via
varargin.
%
%
*See GUI Options on GUIDE's Tools menu. Choose "GUI allows
only one
%
instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help identifikasi
% Last Modified by GUIDE v2.5 03-Jul-2015 23:14:46
% Begin initialization code - DO NOT
gui_Singleton = 1;
gui_State = struct('gui_Name',
'gui_Singleton',
'gui_OpeningFcn',
EDIT
mfilename, ...
gui_Singleton, ...
@identifikasi_OpeningFcn, ...
% --- Outputs from this function are returned to the command line.
function varargout = identifikasi_OutputFcn(hObject, eventdata,
handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject
handle to figure
% eventdata reserved - to be defined in a future version of
MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
if nargin < 4
classLabel = unique(protoClass);
nClass
= length(classLabel);
UNIT = nClass; % # of SOM units
end
if size(data,2) ~= size(proto,2)
error('Dimension of data vectors and prototype vectors do not
match.');
end
if size(proto,1) ~= size(protoClass,1)
error('Row # of prototypes and prototype class vector do not
match.');
end
%%%% Training
%sMap = som_randinit(proto);
% init randomly
%sMap = som_seqtrain(sMap, proto); % sequential train
sMap = som_make(proto, 'munits', UNIT); % equals to randinit and
seqtrain
% labeling proto class to SOM units (make SOM supervised)
protoSom = som_data_struct(proto,'labels',num2str(protoClass));
sMap = som_autolabel(sMap, protoSom);
% plot SOM space
%som_grid(sMap, 'Label', sMap.labels, 'LabelSize', 30);
%%%%% Testing
[Bmus, Qerrors] = som_bmus(sMap, data) % find best matching units
% labeling
%sMap.labels
dataClassified = sMap.labels(Bmus);
for i=1:length(dataClassified)
if isempty(dataClassified{i}), dataClassified{i} = '1', end;
end
C = cellfun(@str2num, dataClassified);
sz = size(X);
%figure(2)
%Ekstrak koefisien level 1
a1 = appcoef2(wc,s,wname,1);
h1 = detcoef2('h',wc,s,1);
v1 = detcoef2('v',wc,s,1);
d1 = detcoef2('d',wc,s,1);
cod_a1
cod_h1
cod_v1
cod_d1
=
=
=
=
wcodemat(a1,ncolors);
wcodemat(h1,ncolors);
wcodemat(v1,ncolors);
wcodemat(d1,ncolors);
cod_a1
cod_h1
cod_v1
cod_d1
=
=
=
=
wkeep(cod_a1,
wkeep(cod_h1,
wkeep(cod_v1,
wkeep(cod_d1,
sz/2);
sz/2);
sz/2);
sz/2);
if level == 1
else
=
=
=
=
wcodemat(a2,ncolors);
wcodemat(h2,ncolors);
wcodemat(v2,ncolors);
wcodemat(d2,ncolors);
cod_a2
cod_h2
cod_v2
cod_d2
end
%Mendapatkan nilai entropi dan energi
entropi = wentropy(wc, 'shannon');
energi = wentropy(wc,'log energy');
strent = mat2str(entropi);
strene = mat2str(energi);
%Menampilkan nilai entropi dan energi
set(proyek.txtentropi, 'String', strent);
set(proyek.txtenergi, 'String', strene);
%Rekonstruksi cabang
if level == 2
ra2 = wrcoef2('a',wc,s,wname,2);
rh2 = wrcoef2('h',wc,s,wname,2);
rv2 = wrcoef2('v',wc,s,wname,2);
rd2 = wrcoef2('d',wc,s,wname,2);
cod_ra2
cod_rh2
cod_rv2
cod_rd2
else
=
=
=
=
wcodemat(ra2,ncolors);
wcodemat(rh2,ncolors);
wcodemat(rv2,ncolors);
wcodemat(rd2,ncolors);
=
=
=
=
wkeep(cod_a2,
wkeep(cod_h2,
wkeep(cod_v2,
wkeep(cod_d2,
sz/4);
sz/4);
sz/4);
sz/4);
ra1
rh1
rv1
rd1
=
=
=
=
wrcoef2('a',wc,s,wname,1);
wrcoef2('h',wc,s,wname,1);
wrcoef2('v',wc,s,wname,1);
wrcoef2('d',wc,s,wname,1);
cod_ra1
cod_rh1
cod_rv1
cod_rd1
=
=
=
=
wcodemat(ra1,ncolors);
wcodemat(rh1,ncolors);
wcodemat(rv1,ncolors);
wcodemat(rd1,ncolors);
end
%Rekonstruksi citra cara 2
XXhat = waverec2(wc,s,wname);
%sprintf('Kesalahan rekonstruksi (menggunakan waverec2) = %g',
max(max(abs(X-XXhat))))
%Implementasi threshold dengan nilai ambang = 20
thr = 20;
[X_comp,wc_comp,s_comp,perf0,perfL2] =
wdencmp('gbl',wc,s,wname,2,thr,'h',1);
%Thresholding spasial
thr_h = [21 17];
% horizontal threshold.
thr_d = [23 19];
% diagonal threshold.
thr_v = [21 17];
% vertical threshold.
thr = [thr_h; thr_d; thr_v];
[X_comp,wc_comp,s_comp,perf0,perfL2] =
wdencmp('lvd',X,wname,2,thr,'h');
%Mengembalikan setting awal
dwtmode('zpd');
set(proyek.txtwaktu, 'String', cputime-inittime);
entropi = str2num(get(handles.txtentropi, 'String'));
energi = str2num(get(handles.txtenergi, 'String'));
proto = train
data = [entropi energi];
protoClass = classtrain
% main
dataClass = doSom(data, proto, protoClass, 8)
kelas = {'Tidak diketahui'; 'Ron Mbako'; 'Godong Cilik'; 'Sekar
Mentari'; 'Mbako Sakbayat'; 'Mbako Sakwit';}
set(handles.txtkelas, 'String', kelas{dataClass})
% plot proto
classLabel = unique(protoClass);
nClass
= length(classLabel);
plotLabel = {'r*', 'g*', 'b*'};
for i=1:nClass
A = proto(protoClass == classLabel(i), :);
plot(A(:, 1), A(:, 2), plotLabel{i});
hold on;
end
% plot data
plotLabel = {'ro', 'go', 'bo'};
for i=1:nClass
A = data(dataClass == classLabel(i), :);
plot(A(:, 1), A(:, 2), plotLabel{i});
hold on;
end
legend('1: proto','2: proto', '3: proto', '1: data', '2: data',
'3: data');
title('Self-organizing Map');
% handles
structure with handles and user data (see GUIDATA)
proyek=guidata(gcbo);
[namafile,direktori]=uigetfile({'*.jpg';'*.bmp';'*.png';'*.tif';'*
.*'},'Buka Gambar')
if isequal(namafile,0)
return;
end
eval(['cd ''' direktori ''';']);
I=imread(namafile);
set(proyek.figure1,'CurrentAxes',proyek.axes1);
set(imshow(I));
imshow(I);
set(proyek.figure1,'Userdata',I);
set(proyek.axes1,'Userdata',I);