Appendix Identifikasi Bibit Unggul Daun Tanaman Karet Melalui Deteksi Tepi Menggunakan Metode Sobel
Lampiran 1. Fungsi Utama
function varargout = utama(varargin)
gui_Singleton = 1;
gui_Singleton = 1;
gui_State = struct('gui_Name',
'gui_Singleton',
mfilename, ...
gui_Singleton, ...
'gui_OpeningFcn', @utama_OpeningFcn, ...
'gui_OutputFcn',
@utama_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 utama_OpeningFcn(hObject, eventdata, handles,
varargin)
handles.output = hObject;
guidata(hObject, handles);
function varargout = utama_OutputFcn(hObject, eventdata,
handles)
varargout{1} = handles.output;
function pushbutton1_Callback(hObject, eventdata, handles)
axes(handles.axes1);
clear gca;
[FileName, PathName, FilterIndex] = uigetfile('*.JPG','Pilih
Citra','*JPG');
handles.NamaFile=FileName;
handles.PathName=PathName;
guidata(hObject,handles);
if isequal(FileName,0)
disp('User selected Cancel')
else
axes(handles.axes1);
clear gca;
set(gca,'ytick',[]);
set(gca,'xtick',[]);
axes(handles.axes1);
handles.Citra.RGB=imread([PathName FileName]);
image(handles.Citra.RGB),
set(gca,'ytick',[]);
set(gca,'xtick',[]);
guidata(hObject, handles);
imshow(handles.Citra.RGB);
end
function pushbutton3_Callback(hObject, eventdata, handles)
gambar1 = handles.Citra.RGB;
temp1=imread('BPM24_template.jpg');
temp2=imread('IRR5_template.jpg');
temp3=imread('IRR39_template.jpg');
temp4=imread('IRR42_template.jpg');
temp5=imread('IRR104_template.jpg');
temp6=imread('IRR107_230_template.jpg');
temp7=imread('IRR112_template.jpg');
temp8=imread('IRR118_template.jpg');
temp9=imread('IRR119_template.jpg');
temp10=imread('IRR220_template.jpg');
temp11=imread('PB260_template.jpg');
temp12=imread('PB330_template.jpg');
temp13=imread('pb340_template.jpg');
temp14=imread('RRIC100_template.jpg');
citra=gambar1;
temp1=processing(temp1);
temp2=processing(temp2);
temp3=processing(temp3);
temp4=processing(temp4);
temp5=processing(temp5);
temp6=processing(temp6);
temp7=processing(temp7);
temp8=processing(temp8);
temp9=processing(temp9);
temp10=processing(temp10);
temp11=processing(temp11);
temp12=processing(temp12);
temp13=processing(temp13);
temp14=processing(temp14);
citra=processing(citra);
temp=[temp1;temp2;temp3;temp4;temp5;temp6;temp7;temp8;temp9;
temp10;temp11;temp12;temp13;temp14];
n=14;%jumlah template
[kore t]=pencocokan_pola(citra,temp,n);
k=kore*100;
fprintf('Nilai koefisien korelasi = %f\n',k);
fprintf('Gambar yang diuji paling cocok dengan template
%d\n',t);
set(handles.hasil,'string',k)
set(handles.kemiripan,'string',t)
function pushbutton4_Callback(hObject, eventdata, handles)
close
function hasil_Callback(hObject, eventdata, handles)
function hasil_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
Lampiran 2. Fungsi Identifikasi
function output = processing (input)
b=rgb2gray(input);%aras keabuan
u=imresize(b,[256 256]);%ukuran citra
%pelembutan citra
median=medfilt2(u,[3 3]);
wiener=wiener2(median,[5 5]);
%Pengambangan (thresholding)
[m n]=size(u);
for i=1:m,
for j=1:n,
if(u(i,j)r)
t=i;
r=y;
end
end
return
function varargout = utama(varargin)
gui_Singleton = 1;
gui_Singleton = 1;
gui_State = struct('gui_Name',
'gui_Singleton',
mfilename, ...
gui_Singleton, ...
'gui_OpeningFcn', @utama_OpeningFcn, ...
'gui_OutputFcn',
@utama_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 utama_OpeningFcn(hObject, eventdata, handles,
varargin)
handles.output = hObject;
guidata(hObject, handles);
function varargout = utama_OutputFcn(hObject, eventdata,
handles)
varargout{1} = handles.output;
function pushbutton1_Callback(hObject, eventdata, handles)
axes(handles.axes1);
clear gca;
[FileName, PathName, FilterIndex] = uigetfile('*.JPG','Pilih
Citra','*JPG');
handles.NamaFile=FileName;
handles.PathName=PathName;
guidata(hObject,handles);
if isequal(FileName,0)
disp('User selected Cancel')
else
axes(handles.axes1);
clear gca;
set(gca,'ytick',[]);
set(gca,'xtick',[]);
axes(handles.axes1);
handles.Citra.RGB=imread([PathName FileName]);
image(handles.Citra.RGB),
set(gca,'ytick',[]);
set(gca,'xtick',[]);
guidata(hObject, handles);
imshow(handles.Citra.RGB);
end
function pushbutton3_Callback(hObject, eventdata, handles)
gambar1 = handles.Citra.RGB;
temp1=imread('BPM24_template.jpg');
temp2=imread('IRR5_template.jpg');
temp3=imread('IRR39_template.jpg');
temp4=imread('IRR42_template.jpg');
temp5=imread('IRR104_template.jpg');
temp6=imread('IRR107_230_template.jpg');
temp7=imread('IRR112_template.jpg');
temp8=imread('IRR118_template.jpg');
temp9=imread('IRR119_template.jpg');
temp10=imread('IRR220_template.jpg');
temp11=imread('PB260_template.jpg');
temp12=imread('PB330_template.jpg');
temp13=imread('pb340_template.jpg');
temp14=imread('RRIC100_template.jpg');
citra=gambar1;
temp1=processing(temp1);
temp2=processing(temp2);
temp3=processing(temp3);
temp4=processing(temp4);
temp5=processing(temp5);
temp6=processing(temp6);
temp7=processing(temp7);
temp8=processing(temp8);
temp9=processing(temp9);
temp10=processing(temp10);
temp11=processing(temp11);
temp12=processing(temp12);
temp13=processing(temp13);
temp14=processing(temp14);
citra=processing(citra);
temp=[temp1;temp2;temp3;temp4;temp5;temp6;temp7;temp8;temp9;
temp10;temp11;temp12;temp13;temp14];
n=14;%jumlah template
[kore t]=pencocokan_pola(citra,temp,n);
k=kore*100;
fprintf('Nilai koefisien korelasi = %f\n',k);
fprintf('Gambar yang diuji paling cocok dengan template
%d\n',t);
set(handles.hasil,'string',k)
set(handles.kemiripan,'string',t)
function pushbutton4_Callback(hObject, eventdata, handles)
close
function hasil_Callback(hObject, eventdata, handles)
function hasil_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
Lampiran 2. Fungsi Identifikasi
function output = processing (input)
b=rgb2gray(input);%aras keabuan
u=imresize(b,[256 256]);%ukuran citra
%pelembutan citra
median=medfilt2(u,[3 3]);
wiener=wiener2(median,[5 5]);
%Pengambangan (thresholding)
[m n]=size(u);
for i=1:m,
for j=1:n,
if(u(i,j)r)
t=i;
r=y;
end
end
return