Berikut adalah semua fungsi callback dari GUI MATLAB:
function varargout = morfologi_citra(varargin)
% MORFOLOGI_CITRA MATLAB code for morfologi_citra.fig
% MORFOLOGI_CITRA, by itself, creates a new MORFOLOGI_CITRA or raises the existing
% singleton*.
%
% H = MORFOLOGI_CITRA returns the handle to a new MORFOLOGI_CITRA or the handle to
% the existing singleton*.
%
% MORFOLOGI_CITRA('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in MORFOLOGI_CITRA.M with the given input arguments.
%
% MORFOLOGI_CITRA('Property','Value',...) creates a new MORFOLOGI_CITRA or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before morfologi_citra_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to morfologi_citra_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 morfologi_citra
% Last Modified by GUIDE v2.5 09-Apr-2017 18:43:07
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @morfologi_citra_OpeningFcn, ...
'gui_OutputFcn', @morfologi_citra_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 morfologi_citra is made visible.
function morfologi_citra_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to morfologi_citra (see VARARGIN)
% Choose default command line output for morfologi_citra
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes morfologi_citra wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = morfologi_citra_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;
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[namafile namapath]=uigetfile('*.jpg;*.bmp;*.jpeg;*.png;*.tif;','Pilih Sebuah Citra');
namacitra=[namapath namafile];
axes(handles.axes1)
imshow(namacitra);title('Citra Semula');
if(size(namacitra,3) == 3)
namacitra = rgb2gray(namacitra);
end
axes(handles.axes4)
imhist(uint8(namacitra)); title('Diagram Histogram Citra Uji Tanpa Derau');
handles.lemparcitra=namacitra;
guidata(hObject, handles);
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on selection change in listbox1.
function listbox1_Callback(hObject, eventdata, handles)
% hObject handle to listbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns listbox1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from listbox1
namacitra=getimage(handles.axes1);
if(size(namacitra,3) == 3)
namacitra = rgb2gray(namacitra);
end
handles.output = hObject;
indeks = get(handles.listbox1,'value');
dimensi = str2num(get(handles.edit1,'string'));
panjang = str2num(get(handles.edit2,'string'));
derajat = str2num(get(handles.edit3,'string'));
radius1 = str2num(get(handles.edit4,'string'));
radius2 = str2num(get(handles.edit5,'string'));
tinggi = str2num(get(handles.edit6,'string'));
ukuran = str2num(get(handles.edit7,'string'));
jarak = str2num(get(handles.edit8,'string'));
switch get(get(handles.uipanel2,'SelectedObject'),'Tag')
case 'radiobutton1', se=strel('square',dimensi);
case 'radiobutton2', se=strel('line',panjang,derajat);
case 'radiobutton3', se=strel('disk',radius1);
case 'radiobutton4', se=strel('ball',radius2,tinggi);
case 'radiobutton5', se=strel('diamond',ukuran);
case 'radiobutton6', se=strel('octagon',jarak);
end
if (indeks == 1)
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
ed = imdilate(namacitra,se)-namacitra;
axes(handles.axes2)
imshow(ed);title('Hasil Morfologi DREO');
cla(handles.axes4,'reset');
axes(handles.axes4)
imhist(ed); title('Diagram Histogram Detektor DREO');
elseif (indeks == 2)
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
ed = namacitra - imerode(namacitra,se);
axes(handles.axes2)
imshow(ed);title('Hasil Morfologi EREO')
cla(handles.axes4,'reset');
axes(handles.axes4)
imhist(ed); title('Diagram Histogram Detektor EREO');
elseif (indeks == 3)
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
ed = imdilate(namacitra,se) - (imerode(namacitra,se));
axes(handles.axes2)
imshow(ed);title('Hasil Morfologi MGO')
cla(handles.axes4,'reset');
axes(handles.axes4)
imhist(ed); title('Diagram Histogram Detektor MGO');
elseif (indeks == 4)
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
ed = namacitra- imopen(namacitra,se);
axes(handles.axes2)
imshow(ed);title('Hasil Morfologi OTHT')
axes(handles.axes4)
cla(handles.axes4,'reset');
imhist(ed); title('Diagram Histogram Detektor OTHT');
elseif (indeks == 5)
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
ed = imclose(namacitra,se) - namacitra;
axes(handles.axes2)
imshow(ed);title('Hasil Morfologi CTHT')
axes(handles.axes4)
cla(handles.axes4,'reset');
imhist(ed); title('Diagram Histogram Detektor CTHT');
elseif (indeks == 6)
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
ed = imdilate(imclose(imopen(imclose(namacitra,se),se),se),se) - imopen(imclose(namacitra,se),se);
axes(handles.axes2)
imshow(ed);title('Hasil Morfologi EDA')
axes(handles.axes4)
cla(handles.axes4,'reset');
imhist(ed); title('Diagram Histogram Detektor EDA');
elseif (indeks == 8)
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
ed = edge(namacitra,'sobel','horizontal');
axes(handles.axes2)
imshow(ed);title('Hasil Tepi Sobel Horisontal')
axes(handles.axes4)
cla(handles.axes4,'reset');
imhist(ed); title('Diagram Histogram Detektor Sobel');
elseif (indeks == 9)
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
ed = edge(namacitra,'sobel','vertical');
axes(handles.axes2)
imshow(ed);title('Hasil Tepi Sobel Vertikal')
axes(handles.axes4)
cla(handles.axes4,'reset');
imhist(ed); title('Diagram Histogram Detektor Sobel Vertikal');
elseif (indeks == 10)
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
ed = edge(namacitra,'prewitt','horizontal');
axes(handles.axes2)
imshow(ed);title('Hasil Tepi Prewitt Horisontal')
axes(handles.axes4)
cla(handles.axes4,'reset');
imhist(ed); title('Diagram Histogram Detektor Prewitt Horisontal');
elseif (indeks == 11)
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
ed = edge(namacitra,'prewitt','vertical');
axes(handles.axes2)
imshow(ed);title('Hasil Tepi Prewitt Vertikal')
axes(handles.axes4)
cla(handles.axes4,'reset');
imhist(ed); title('Diagram Histogram Detektor Prewitt Vertikal');
elseif (indeks == 12)
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
ed = edge(namacitra,'roberts');
axes(handles.axes2)
imshow(ed);title('Hasil Tepi Roberts')
axes(handles.axes4)
cla(handles.axes4,'reset');
imhist(ed); title('Diagram Histogram Detektor Roberts');
elseif (indeks == 13)
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
ed = edge(namacitra,'log');
axes(handles.axes2)
imshow(ed);title('Hasil Tepi LoG')
axes(handles.axes4)
cla(handles.axes4,'reset');
imhist(ed); title('Diagram Histogram Detektor LoG');
elseif (indeks == 14)
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
ed = edge(namacitra,'canny');
axes(handles.axes2)
imshow(ed);title('Hasil Tepi Canny')
axes(handles.axes4)
cla(handles.axes4,'reset');
imhist(ed); title('Diagram Histogram Detektor Canny');
elseif (indeks == 16)
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
ed = imdilate(namacitra,se) - imerode(namacitra,se) + imopen(namacitra,se) - imclose(namacitra,se);% - I;
axes(handles.axes2)
imshow(ed);title('Hasil Morfologi RMED')
axes(handles.axes4)
cla(handles.axes4,'reset');
imhist(ed); title('Diagram Histogram Detektor Prewitt RMED');
elseif (indeks == 17)
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
ed = imdilate(imclose(namacitra,se),se) - imerode((imopen(namacitra,se)),se);
axes(handles.axes2)
imshow(ed);title('Hasil Morfologi SMED')
axes(handles.axes4)
cla(handles.axes4,'reset');
imhist(ed); title('Diagram Histogram Detektor SMED');
elseif (indeks == 18)
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
ed = namacitra - imdilate(namacitra,se) + imclose(imdilate(namacitra,se),se) - 0.1*imclose(namacitra,se) - imerode(namacitra,se);
axes(handles.axes2)
imshow(ed);title('Hasil Morfologi HMEO')
axes(handles.axes4)
cla(handles.axes4,'reset');
imhist(ed); title('Diagram Histogram Detektor HMEO');
end
% --- Executes during object creation, after setting all properties.
function listbox1_CreateFcn(hObject, eventdata, handles)
% hObject handle to listbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: listbox controls usually have a white background on Windows.
% See ISPC and COMPUTER.
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)
% hObject handle to listbox2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns listbox2 contents as cell array
% contents{get(hObject,'Value')} returns selected item from listbox2
% --- Executes during object creation, after setting all properties.
function listbox2_CreateFcn(hObject, eventdata, handles)
% hObject handle to listbox2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: listbox controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit2_Callback(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit2 as text
% str2double(get(hObject,'String')) returns contents of edit2 as a double
% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit3_Callback(hObject, eventdata, handles)
% hObject handle to edit3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit3 as text
% str2double(get(hObject,'String')) returns contents of edit3 as a double
% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit4_Callback(hObject, eventdata, handles)
% hObject handle to edit4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit4 as text
% str2double(get(hObject,'String')) returns contents of edit4 as a double
% --- Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit5_Callback(hObject, eventdata, handles)
% hObject handle to edit5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit5 as text
% str2double(get(hObject,'String')) returns contents of edit5 as a double
% --- Executes during object creation, after setting all properties.
function edit5_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit6_Callback(hObject, eventdata, handles)
% hObject handle to edit6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit6 as text
% str2double(get(hObject,'String')) returns contents of edit6 as a double
% --- Executes during object creation, after setting all properties.
function edit6_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit7_Callback(hObject, eventdata, handles)
% hObject handle to edit7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit7 as text
% str2double(get(hObject,'String')) returns contents of edit7 as a double
% --- Executes during object creation, after setting all properties.
function edit7_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit8_Callback(hObject, eventdata, handles)
% hObject handle to edit8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit8 as text
% str2double(get(hObject,'String')) returns contents of edit8 as a double
% --- Executes during object creation, after setting all properties.
function edit8_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes during object creation, after setting all properties.
function listbox4_CreateFcn(hObject, eventdata, handles)
% hObject handle to listbox4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: listbox controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
namacitra=getimage(handles.axes1);
if(size(namacitra,3) == 3)
namacitra = rgb2gray(namacitra);
end
citra_derau = imnoise(namacitra,'gaussian',0.01,0.01);
axes(handles.axes1)
imshow(citra_derau);title('Citra Berderau Gaussian');
axes(handles.axes4)
imhist(uint8(citra_derau)); title('Diagram Histogram Citra Uji BerDerau');
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
datacitra = guidata(handles.pushbutton1);
%datacitra = handles.data;
%datacitra = handles.pushbutton1.CData;
axes(handles.axes1)
imshow(datacitra.lemparcitra);title('Citra Semula');
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
namacitra=im2double(getimage(handles.axes2));
%penajaman
%H = fspecial('unsharp');
%namacitra = imfilter(namacitra,H,'replicate');
%Peningkatan dengan imadjust
namacitra_imadjust = imadjust(namacitra);
%namacitra_imadjust = im2bw(namacitra_imadjust,0.2);
namacitra_imadjust = imadjust(namacitra_imadjust);
%namacitra_imadjust = im2bw(namacitra_imadjust,0.2);
%namacitra_histeq = histeq(namacitra);
%namacitra_adapthisteq = adapthisteq(namacitra);
axes(handles.axes6)
imshow(namacitra_imadjust);title('Tepi Setelah Ditajamkan');
%axes(handles.axes5)
%imhist(namacitra_imadjust);
% --- Executes on key press with focus on listbox1 and none of its controls.
function listbox1_KeyPressFcn(hObject, eventdata, handles)
% hObject handle to listbox1 (see GCBO)
% eventdata structure with the following fields (see UICONTROL)
% Key: name of the key that was pressed, in lower case
% Character: character interpretation of the key(s) that was pressed
% Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
namacitra=im2double(getimage(handles.axes1));
if(size(namacitra,3) == 3)
namacitra = rgb2gray(namacitra);
end
save namacitra.mat;
dimensi = str2num(get(handles.edit1,'string'));
panjang = str2num(get(handles.edit2,'string'));
derajat = str2num(get(handles.edit3,'string'));
radius1 = str2num(get(handles.edit4,'string'));
radius2 = str2num(get(handles.edit5,'string'));
tinggi = str2num(get(handles.edit6,'string'));
ukuran = str2num(get(handles.edit7,'string'));
jarak = str2num(get(handles.edit8,'string'));
switch get(get(handles.uipanel2,'SelectedObject'),'Tag')
case 'radiobutton1', se=strel('square',dimensi);
case 'radiobutton2', se=strel('line',panjang,derajat);
case 'radiobutton3', se=strel('disk',radius1);
case 'radiobutton4', se=strel('ball',radius2,tinggi);
case 'radiobutton5', se=strel('diamond',ukuran);
case 'radiobutton6', se=strel('octagon',jarak);
end
%Hitung Detektor DREO
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
DREO = imdilate(namacitra,se)-namacitra;
%Hitung Detektor EREO
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
EREO = namacitra - imerode(namacitra,se);
%Hitung Detektor MGO
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
MGO = imdilate(namacitra,se) - (imerode(namacitra,se));
%Hitung Detektor OTHT
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
OTHT = namacitra- imopen(namacitra,se);
%Hitung Detektor CTHT
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
CTHT = imclose(namacitra,se) - namacitra;
%Hitung Detektor EDA
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
EDA = imdilate(imclose(imopen(imclose(namacitra,se),se),se),se) - imopen(imclose(namacitra,se),se);
%Hitung Detektor Sobel Horisontal
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
SH = edge(namacitra,'sobel','horizontal');
%Hitung Detektor Sober Vertikal
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
SV = edge(namacitra,'sobel','vertical');
%Hitung Prewitt Horisontal
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
PH = edge(namacitra,'prewitt','horizontal');
%Hitung Prewitt Vertikal
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
PV = edge(namacitra,'prewitt','vertical');
%Hitung Detektor Roberts
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
RO = edge(namacitra,'roberts');
%Hitung Detektor LoG
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
LoG = edge(namacitra,'log');
%Hitung Detektor Canny
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
CA = edge(namacitra,'canny');
%Hitung Detektor RMED
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
RMED = imdilate(namacitra,se) - imerode(namacitra,se) + imopen(namacitra,se) - imclose(namacitra,se);% - I;
%Hitung Detektor SMED
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
SMED = imdilate(imclose(namacitra,se),se) - imerode((imopen(namacitra,se)),se);
%Hitung Detektor HMEO
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
HMEO = namacitra - imdilate(namacitra,se) + imclose(imdilate(namacitra,se),se) - 0.1*imclose(namacitra,se) - imerode(namacitra,se);
%Hitung MSE
[M,N]=size(namacitra);
error1 = double(DREO) - double(CA);
MSE_DREO = sum(sum(error1 .* error1)) / (M * N);
error2 = double(EREO) - double(CA);
MSE_EREO = sum(sum(error2 .* error2)) / (M * N);
error3 = double(MGO) - double(CA);
MSE_MGO = sum(sum(error3 .* error3)) / (M * N);
error4 = double(OTHT) - double(CA);
MSE_OTHT = sum(sum(error4 .* error4)) / (M * N);
error5 = double(CTHT) - double(CA);
MSE_CTHT = sum(sum(error5 .* error5)) / (M * N);
error6 = double(EDA) - double(CA);
MSE_EDA = sum(sum(error6 .* error6)) / (M * N);
error7 = double(SH) - double(CA);
MSE_SH = sum(sum(error7 .* error7)) / (M * N);
error8 = double(SV) - double(CA);
MSE_SV = sum(sum(error8 .* error8)) / (M * N);
error9 = double(PH) - double(CA);
MSE_PH = sum(sum(error9 .* error9)) / (M * N);
error10 = double(PV) - double(CA);
MSE_PV = sum(sum(error10 .* error10)) / (M * N);
error11 = double(RO) - double(CA);
MSE_RO = sum(sum(error11 .* error11)) / (M * N);
error12 = double(LoG) - double(CA);
MSE_LoG = sum(sum(error12 .* error12)) / (M * N);
error13 = double(RMED) - double(CA);
MSE_RMED = sum(sum(error13 .* error13)) / (M * N);
error14 = double(SMED) - double(CA);
MSE_SMED = sum(sum(error14 .* error14)) / (M * N);
error15 = double(HMEO) - double(CA);
MSE_HMEO = sum(sum(error15 .* error15)) / (M * N);
%Menampilkan dalam tabel
t = handles.uitable1;
d = [MSE_DREO MSE_EREO MSE_MGO MSE_OTHT MSE_CTHT MSE_EDA MSE_SH MSE_SV...
MSE_PH MSE_PV MSE_RO MSE_LoG MSE_RMED MSE_SMED MSE_HMEO];
set(t,'Data',d);
set(t,'ColumnName',{'DREO';'EREO';'MGO';'OTHT';'CTHT';'EDA';'SH';...
'SV';'PH';'PV';'RO';'LoG';'RMED';'SMED';'HMEO'})
set(t,'RowName',{'CA'});
%Menampilkan grafik
axes(handles.axes4);
cla(handles.axes4,'reset');
%p1 = bar(d);
%set(p1,'FaceColor','red');
bar(1,d(1),'r')
hold on
bar(2,d(2),'k')
hold on
bar(3,d(3),'y')
hold on
bar(4,d(4),'m')
hold on
bar(5,d(5),'c')
hold on
bar(6,d(6),'g')
hold on
bar(7,d(7),'b')
hold on
bar(8,d(8),'r')
hold on
bar(9,d(9),'k')
hold on
bar(10,d(10),'y')
hold on
bar(11,d(11),'m')
hold on
bar(12,d(12),'c')
hold on
bar(13,d(13),'g')
hold on
bar(14,d(14),'b')
hold on
bar(15,d(15),'r')
%Menempatkan nilai di atas grafik batang
x=1:15;
for i1=1:numel(d)
text(x(i1),d(i1),num2str(d(i1),'%0.2f'),...
'HorizontalAlignment','center',...
'VerticalAlignment','bottom')
end
title('MSE Terhadap Tepi Sesungguhnya Berbasis Detektor Canny');
set(gca,'XTick',1:15)
set(gca,'XTickLabel',{'DREO','EREO','MGO','OTHT','CTHT','EDA','SH',...
'SV','PH','PV','RO','LoG','RMED','SMED','HMEO'});
% --------------------------------------------------------------------
function parameter_kinerja_Callback(hObject, eventdata, handles)
% hObject handle to parameter_kinerja (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
run parameter_kinerja_morfologi;
% --- Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
namacitra=im2double(getimage(handles.axes1));
if(size(namacitra,3) == 3)
namacitra = rgb2gray(namacitra);
end
dimensi = str2num(get(handles.edit1,'string'));
panjang = str2num(get(handles.edit2,'string'));
derajat = str2num(get(handles.edit3,'string'));
radius1 = str2num(get(handles.edit4,'string'));
radius2 = str2num(get(handles.edit5,'string'));
tinggi = str2num(get(handles.edit6,'string'));
ukuran = str2num(get(handles.edit7,'string'));
jarak = str2num(get(handles.edit8,'string'));
se=strel('square',dimensi);
%Hitung Detektor DREO
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
DREO = imdilate(namacitra,se)-namacitra;
%Hitung Detektor EREO
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
EREO = namacitra - imerode(namacitra,se);
%Hitung Detektor MGO
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
MGO = imdilate(namacitra,se) - (imerode(namacitra,se));
%Hitung Detektor OTHT
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
OTHT = namacitra- imopen(namacitra,se);
%Hitung Detektor CTHT
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
CTHT = imclose(namacitra,se) - namacitra;
%Hitung Detektor EDA
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
EDA = imdilate(imclose(imopen(imclose(namacitra,se),se),se),se) - imopen(imclose(namacitra,se),se);
%Hitung Detektor Sobel Horisontal
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
SH = edge(namacitra,'sobel','horizontal');
%Hitung Detektor Sober Vertikal
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
SV = edge(namacitra,'sobel','vertical');
%Hitung Prewitt Horisontal
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
PH = edge(namacitra,'prewitt','horizontal');
%Hitung Prewitt Vertikal
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
PV = edge(namacitra,'prewitt','vertical');
%Hitung Detektor Roberts
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
RO = edge(namacitra,'roberts');
%Hitung Detektor LoG
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
LoG = edge(namacitra,'log');
%Hitung Detektor Canny
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
CA = edge(namacitra,'canny');
%Hitung Detektor RMED
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
RMED = imdilate(namacitra,se) - imerode(namacitra,se) + imopen(namacitra,se) - imclose(namacitra,se);% - I;
%Hitung Detektor SMED
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
SMED = imdilate(imclose(namacitra,se),se) - imerode((imopen(namacitra,se)),se);
%Hitung Detektor HMEO
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
HMEO = namacitra - imdilate(namacitra,se) + imclose(imdilate(namacitra,se),se) - 0.1*imclose(namacitra,se) - imerode(namacitra,se);
%Hitung MSE
[M,N]=size(namacitra);
error1 = double(DREO) - double(CA);
MSE_DREO = sum(sum(error1 .* error1)) / (M * N);
error2 = double(EREO) - double(CA);
MSE_EREO = sum(sum(error2 .* error2)) / (M * N);
error3 = double(MGO) - double(CA);
MSE_MGO = sum(sum(error3 .* error3)) / (M * N);
error4 = double(OTHT) - double(CA);
MSE_OTHT = sum(sum(error4 .* error4)) / (M * N);
error5 = double(CTHT) - double(CA);
MSE_CTHT = sum(sum(error5 .* error5)) / (M * N);
error6 = double(EDA) - double(CA);
MSE_EDA = sum(sum(error6 .* error6)) / (M * N);
error7 = double(SH) - double(CA);
MSE_SH = sum(sum(error7 .* error7)) / (M * N);
error8 = double(SV) - double(CA);
MSE_SV = sum(sum(error8 .* error8)) / (M * N);
error9 = double(PH) - double(CA);
MSE_PH = sum(sum(error9 .* error9)) / (M * N);
error10 = double(PV) - double(CA);
MSE_PV = sum(sum(error10 .* error10)) / (M * N);
error11 = double(RO) - double(CA);
MSE_RO = sum(sum(error11 .* error11)) / (M * N);
error12 = double(LoG) - double(CA);
MSE_LoG = sum(sum(error12 .* error12)) / (M * N);
error13 = double(RMED) - double(CA);
MSE_RMED = sum(sum(error13 .* error13)) / (M * N);
error14 = double(SMED) - double(CA);
MSE_SMED = sum(sum(error14 .* error14)) / (M * N);
error15 = double(HMEO) - double(CA);
MSE_HMEO = sum(sum(error15 .* error15)) / (M * N);
d1 = [MSE_DREO MSE_EREO MSE_MGO MSE_OTHT MSE_CTHT MSE_EDA MSE_SH MSE_SV...
MSE_PH MSE_PV MSE_RO MSE_LoG MSE_RMED MSE_SMED MSE_HMEO];
save d1.mat;
%SE LINE
namacitra=im2double(getimage(handles.axes1));
if(size(namacitra,3) == 3)
namacitra = rgb2gray(namacitra);
end
dimensi = str2num(get(handles.edit1,'string'));
panjang = str2num(get(handles.edit2,'string'));
derajat = str2num(get(handles.edit3,'string'));
radius1 = str2num(get(handles.edit4,'string'));
radius2 = str2num(get(handles.edit5,'string'));
tinggi = str2num(get(handles.edit6,'string'));
ukuran = str2num(get(handles.edit7,'string'));
jarak = str2num(get(handles.edit8,'string'));
se=strel('line',panjang,derajat);
%Hitung Detektor DREO
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
DREO = imdilate(namacitra,se)-namacitra;
%Hitung Detektor EREO
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
EREO = namacitra - imerode(namacitra,se);
%Hitung Detektor MGO
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
MGO = imdilate(namacitra,se) - (imerode(namacitra,se));
%Hitung Detektor OTHT
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
OTHT = namacitra- imopen(namacitra,se);
%Hitung Detektor CTHT
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
CTHT = imclose(namacitra,se) - namacitra;
%Hitung Detektor EDA
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
EDA = imdilate(imclose(imopen(imclose(namacitra,se),se),se),se) - imopen(imclose(namacitra,se),se);
%Hitung Detektor Sobel Horisontal
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
SH = edge(namacitra,'sobel','horizontal');
%Hitung Detektor Sober Vertikal
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
SV = edge(namacitra,'sobel','vertical');
%Hitung Prewitt Horisontal
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
PH = edge(namacitra,'prewitt','horizontal');
%Hitung Prewitt Vertikal
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
PV = edge(namacitra,'prewitt','vertical');
%Hitung Detektor Roberts
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
RO = edge(namacitra,'roberts');
%Hitung Detektor LoG
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
LoG = edge(namacitra,'log');
%Hitung Detektor Canny
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
CA = edge(namacitra,'canny');
%Hitung Detektor RMED
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
RMED = imdilate(namacitra,se) - imerode(namacitra,se) + imopen(namacitra,se) - imclose(namacitra,se);% - I;
%Hitung Detektor SMED
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
SMED = imdilate(imclose(namacitra,se),se) - imerode((imopen(namacitra,se)),se);
%Hitung Detektor HMEO
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
HMEO = namacitra - imdilate(namacitra,se) + imclose(imdilate(namacitra,se),se) - 0.1*imclose(namacitra,se) - imerode(namacitra,se);
%Hitung MSE
[M,N]=size(namacitra);
error1 = double(DREO) - double(CA);
MSE_DREO = sum(sum(error1 .* error1)) / (M * N);
error2 = double(EREO) - double(CA);
MSE_EREO = sum(sum(error2 .* error2)) / (M * N);
error3 = double(MGO) - double(CA);
MSE_MGO = sum(sum(error3 .* error3)) / (M * N);
error4 = double(OTHT) - double(CA);
MSE_OTHT = sum(sum(error4 .* error4)) / (M * N);
error5 = double(CTHT) - double(CA);
MSE_CTHT = sum(sum(error5 .* error5)) / (M * N);
error6 = double(EDA) - double(CA);
MSE_EDA = sum(sum(error6 .* error6)) / (M * N);
error7 = double(SH) - double(CA);
MSE_SH = sum(sum(error7 .* error7)) / (M * N);
error8 = double(SV) - double(CA);
MSE_SV = sum(sum(error8 .* error8)) / (M * N);
error9 = double(PH) - double(CA);
MSE_PH = sum(sum(error9 .* error9)) / (M * N);
error10 = double(PV) - double(CA);
MSE_PV = sum(sum(error10 .* error10)) / (M * N);
error11 = double(RO) - double(CA);
MSE_RO = sum(sum(error11 .* error11)) / (M * N);
error12 = double(LoG) - double(CA);
MSE_LoG = sum(sum(error12 .* error12)) / (M * N);
error13 = double(RMED) - double(CA);
MSE_RMED = sum(sum(error13 .* error13)) / (M * N);
error14 = double(SMED) - double(CA);
MSE_SMED = sum(sum(error14 .* error14)) / (M * N);
error15 = double(HMEO) - double(CA);
MSE_HMEO = sum(sum(error15 .* error15)) / (M * N);
d2 = [MSE_DREO MSE_EREO MSE_MGO MSE_OTHT MSE_CTHT MSE_EDA MSE_SH MSE_SV...
MSE_PH MSE_PV MSE_RO MSE_LoG MSE_RMED MSE_SMED MSE_HMEO];
save d2.mat;
%SE DISK
namacitra=im2double(getimage(handles.axes1));
if(size(namacitra,3) == 3)
namacitra = rgb2gray(namacitra);
end
dimensi = str2num(get(handles.edit1,'string'));
panjang = str2num(get(handles.edit2,'string'));
derajat = str2num(get(handles.edit3,'string'));
radius1 = str2num(get(handles.edit4,'string'));
radius2 = str2num(get(handles.edit5,'string'));
tinggi = str2num(get(handles.edit6,'string'));
ukuran = str2num(get(handles.edit7,'string'));
jarak = str2num(get(handles.edit8,'string'));
se=strel('disk',radius1);
%Hitung Detektor DREO
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
DREO = imdilate(namacitra,se)-namacitra;
%Hitung Detektor EREO
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
EREO = namacitra - imerode(namacitra,se);
%Hitung Detektor MGO
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
MGO = imdilate(namacitra,se) - (imerode(namacitra,se));
%Hitung Detektor OTHT
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
OTHT = namacitra- imopen(namacitra,se);
%Hitung Detektor CTHT
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
CTHT = imclose(namacitra,se) - namacitra;
%Hitung Detektor EDA
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
EDA = imdilate(imclose(imopen(imclose(namacitra,se),se),se),se) - imopen(imclose(namacitra,se),se);
%Hitung Detektor Sobel Horisontal
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
SH = edge(namacitra,'sobel','horizontal');
%Hitung Detektor Sober Vertikal
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
SV = edge(namacitra,'sobel','vertical');
%Hitung Prewitt Horisontal
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
PH = edge(namacitra,'prewitt','horizontal');
%Hitung Prewitt Vertikal
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
PV = edge(namacitra,'prewitt','vertical');
%Hitung Detektor Roberts
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
RO = edge(namacitra,'roberts');
%Hitung Detektor LoG
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
LoG = edge(namacitra,'log');
%Hitung Detektor Canny
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
CA = edge(namacitra,'canny');
%Hitung Detektor RMED
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
RMED = imdilate(namacitra,se) - imerode(namacitra,se) + imopen(namacitra,se) - imclose(namacitra,se);% - I;
%Hitung Detektor SMED
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
SMED = imdilate(imclose(namacitra,se),se) - imerode((imopen(namacitra,se)),se);
%Hitung Detektor HMEO
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
HMEO = namacitra - imdilate(namacitra,se) + imclose(imdilate(namacitra,se),se) - 0.1*imclose(namacitra,se) - imerode(namacitra,se);
%Hitung MSE
[M,N]=size(namacitra);
error1 = double(DREO) - double(CA);
MSE_DREO = sum(sum(error1 .* error1)) / (M * N);
error2 = double(EREO) - double(CA);
MSE_EREO = sum(sum(error2 .* error2)) / (M * N);
error3 = double(MGO) - double(CA);
MSE_MGO = sum(sum(error3 .* error3)) / (M * N);
error4 = double(OTHT) - double(CA);
MSE_OTHT = sum(sum(error4 .* error4)) / (M * N);
error5 = double(CTHT) - double(CA);
MSE_CTHT = sum(sum(error5 .* error5)) / (M * N);
error6 = double(EDA) - double(CA);
MSE_EDA = sum(sum(error6 .* error6)) / (M * N);
error7 = double(SH) - double(CA);
MSE_SH = sum(sum(error7 .* error7)) / (M * N);
error8 = double(SV) - double(CA);
MSE_SV = sum(sum(error8 .* error8)) / (M * N);
error9 = double(PH) - double(CA);
MSE_PH = sum(sum(error9 .* error9)) / (M * N);
error10 = double(PV) - double(CA);
MSE_PV = sum(sum(error10 .* error10)) / (M * N);
error11 = double(RO) - double(CA);
MSE_RO = sum(sum(error11 .* error11)) / (M * N);
error12 = double(LoG) - double(CA);
MSE_LoG = sum(sum(error12 .* error12)) / (M * N);
error13 = double(RMED) - double(CA);
MSE_RMED = sum(sum(error13 .* error13)) / (M * N);
error14 = double(SMED) - double(CA);
MSE_SMED = sum(sum(error14 .* error14)) / (M * N);
error15 = double(HMEO) - double(CA);
MSE_HMEO = sum(sum(error15 .* error15)) / (M * N);
d3 = [MSE_DREO MSE_EREO MSE_MGO MSE_OTHT MSE_CTHT MSE_EDA MSE_SH MSE_SV...
MSE_PH MSE_PV MSE_RO MSE_LoG MSE_RMED MSE_SMED MSE_HMEO];
save d3.mat;
%SE DIAMOND
namacitra=im2double(getimage(handles.axes1));
if(size(namacitra,3) == 3)
namacitra = rgb2gray(namacitra);
end
dimensi = str2num(get(handles.edit1,'string'));
panjang = str2num(get(handles.edit2,'string'));
derajat = str2num(get(handles.edit3,'string'));
radius1 = str2num(get(handles.edit4,'string'));
radius2 = str2num(get(handles.edit5,'string'));
tinggi = str2num(get(handles.edit6,'string'));
ukuran = str2num(get(handles.edit7,'string'));
jarak = str2num(get(handles.edit8,'string'));
se=strel('diamond',ukuran);
%Hitung Detektor DREO
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
DREO = imdilate(namacitra,se)-namacitra;
%Hitung Detektor EREO
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
EREO = namacitra - imerode(namacitra,se);
%Hitung Detektor MGO
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
MGO = imdilate(namacitra,se) - (imerode(namacitra,se));
%Hitung Detektor OTHT
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
OTHT = namacitra- imopen(namacitra,se);
%Hitung Detektor CTHT
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
CTHT = imclose(namacitra,se) - namacitra;
%Hitung Detektor EDA
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
EDA = imdilate(imclose(imopen(imclose(namacitra,se),se),se),se) - imopen(imclose(namacitra,se),se);
%Hitung Detektor Sobel Horisontal
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
SH = edge(namacitra,'sobel','horizontal');
%Hitung Detektor Sober Vertikal
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
SV = edge(namacitra,'sobel','vertical');
%Hitung Prewitt Horisontal
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
PH = edge(namacitra,'prewitt','horizontal');
%Hitung Prewitt Vertikal
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
PV = edge(namacitra,'prewitt','vertical');
%Hitung Detektor Roberts
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
RO = edge(namacitra,'roberts');
%Hitung Detektor LoG
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
LoG = edge(namacitra,'log');
%Hitung Detektor Canny
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
CA = edge(namacitra,'canny');
%Hitung Detektor RMED
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
RMED = imdilate(namacitra,se) - imerode(namacitra,se) + imopen(namacitra,se) - imclose(namacitra,se);% - I;
%Hitung Detektor SMED
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
SMED = imdilate(imclose(namacitra,se),se) - imerode((imopen(namacitra,se)),se);
%Hitung Detektor HMEO
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
HMEO = namacitra - imdilate(namacitra,se) + imclose(imdilate(namacitra,se),se) - 0.1*imclose(namacitra,se) - imerode(namacitra,se);
%Hitung MSE
[M,N]=size(namacitra);
error1 = double(DREO) - double(CA);
MSE_DREO = sum(sum(error1 .* error1)) / (M * N);
error2 = double(EREO) - double(CA);
MSE_EREO = sum(sum(error2 .* error2)) / (M * N);
error3 = double(MGO) - double(CA);
MSE_MGO = sum(sum(error3 .* error3)) / (M * N);
error4 = double(OTHT) - double(CA);
MSE_OTHT = sum(sum(error4 .* error4)) / (M * N);
error5 = double(CTHT) - double(CA);
MSE_CTHT = sum(sum(error5 .* error5)) / (M * N);
error6 = double(EDA) - double(CA);
MSE_EDA = sum(sum(error6 .* error6)) / (M * N);
error7 = double(SH) - double(CA);
MSE_SH = sum(sum(error7 .* error7)) / (M * N);
error8 = double(SV) - double(CA);
MSE_SV = sum(sum(error8 .* error8)) / (M * N);
error9 = double(PH) - double(CA);
MSE_PH = sum(sum(error9 .* error9)) / (M * N);
error10 = double(PV) - double(CA);
MSE_PV = sum(sum(error10 .* error10)) / (M * N);
error11 = double(RO) - double(CA);
MSE_RO = sum(sum(error11 .* error11)) / (M * N);
error12 = double(LoG) - double(CA);
MSE_LoG = sum(sum(error12 .* error12)) / (M * N);
error13 = double(RMED) - double(CA);
MSE_RMED = sum(sum(error13 .* error13)) / (M * N);
error14 = double(SMED) - double(CA);
MSE_SMED = sum(sum(error14 .* error14)) / (M * N);
error15 = double(HMEO) - double(CA);
MSE_HMEO = sum(sum(error15 .* error15)) / (M * N);
d4 = [MSE_DREO MSE_EREO MSE_MGO MSE_OTHT MSE_CTHT MSE_EDA MSE_SH MSE_SV...
MSE_PH MSE_PV MSE_RO MSE_LoG MSE_RMED MSE_SMED MSE_HMEO];
save d4.mat;
%SE OCTAGON
namacitra=im2double(getimage(handles.axes1));
if(size(namacitra,3) == 3)
namacitra = rgb2gray(namacitra);
end
dimensi = str2num(get(handles.edit1,'string'));
panjang = str2num(get(handles.edit2,'string'));
derajat = str2num(get(handles.edit3,'string'));
radius1 = str2num(get(handles.edit4,'string'));
radius2 = str2num(get(handles.edit5,'string'));
tinggi = str2num(get(handles.edit6,'string'));
ukuran = str2num(get(handles.edit7,'string'));
jarak = str2num(get(handles.edit8,'string'));
se=strel('octagon',jarak);
%Hitung Detektor DREO
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
DREO = imdilate(namacitra,se)-namacitra;
%Hitung Detektor EREO
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
EREO = namacitra - imerode(namacitra,se);
%Hitung Detektor MGO
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
MGO = imdilate(namacitra,se) - (imerode(namacitra,se));
%Hitung Detektor OTHT
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
OTHT = namacitra- imopen(namacitra,se);
%Hitung Detektor CTHT
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
CTHT = imclose(namacitra,se) - namacitra;
%Hitung Detektor EDA
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
EDA = imdilate(imclose(imopen(imclose(namacitra,se),se),se),se) - imopen(imclose(namacitra,se),se);
%Hitung Detektor Sobel Horisontal
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
SH = edge(namacitra,'sobel','horizontal');
%Hitung Detektor Sober Vertikal
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
SV = edge(namacitra,'sobel','vertical');
%Hitung Prewitt Horisontal
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
PH = edge(namacitra,'prewitt','horizontal');
%Hitung Prewitt Vertikal
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
PV = edge(namacitra,'prewitt','vertical');
%Hitung Detektor Roberts
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
RO = edge(namacitra,'roberts');
%Hitung Detektor LoG
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
LoG = edge(namacitra,'log');
%Hitung Detektor Canny
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
CA = edge(namacitra,'canny');
%Hitung Detektor RMED
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
RMED = imdilate(namacitra,se) - imerode(namacitra,se) + imopen(namacitra,se) - imclose(namacitra,se);% - I;
%Hitung Detektor SMED
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
SMED = imdilate(imclose(namacitra,se),se) - imerode((imopen(namacitra,se)),se);
%Hitung Detektor HMEO
H = fspecial('average',5);
namacitra = imfilter(namacitra,H,'replicate');
HMEO = namacitra - imdilate(namacitra,se) + imclose(imdilate(namacitra,se),se) - 0.1*imclose(namacitra,se) - imerode(namacitra,se);
%Hitung MSE
[M,N]=size(namacitra);
error1 = double(DREO) - double(CA);
MSE_DREO = sum(sum(error1 .* error1)) / (M * N);
error2 = double(EREO) - double(CA);
MSE_EREO = sum(sum(error2 .* error2)) / (M * N);
error3 = double(MGO) - double(CA);
MSE_MGO = sum(sum(error3 .* error3)) / (M * N);
error4 = double(OTHT) - double(CA);
MSE_OTHT = sum(sum(error4 .* error4)) / (M * N);
error5 = double(CTHT) - double(CA);
MSE_CTHT = sum(sum(error5 .* error5)) / (M * N);
error6 = double(EDA) - double(CA);
MSE_EDA = sum(sum(error6 .* error6)) / (M * N);
error7 = double(SH) - double(CA);
MSE_SH = sum(sum(error7 .* error7)) / (M * N);
error8 = double(SV) - double(CA);
MSE_SV = sum(sum(error8 .* error8)) / (M * N);
error9 = double(PH) - double(CA);
MSE_PH = sum(sum(error9 .* error9)) / (M * N);
error10 = double(PV) - double(CA);
MSE_PV = sum(sum(error10 .* error10)) / (M * N);
error11 = double(RO) - double(CA);
MSE_RO = sum(sum(error11 .* error11)) / (M * N);
error12 = double(LoG) - double(CA);
MSE_LoG = sum(sum(error12 .* error12)) / (M * N);
error13 = double(RMED) - double(CA);
MSE_RMED = sum(sum(error13 .* error13)) / (M * N);
error14 = double(SMED) - double(CA);
MSE_SMED = sum(sum(error14 .* error14)) / (M * N);
error15 = double(HMEO) - double(CA);
MSE_HMEO = sum(sum(error15 .* error15)) / (M * N);
d5 = [MSE_DREO MSE_EREO MSE_MGO MSE_OTHT MSE_CTHT MSE_EDA MSE_SH MSE_SV...
MSE_PH MSE_PV MSE_RO MSE_LoG MSE_RMED MSE_SMED MSE_HMEO];
save d5.mat;
run parameter_kinerja_morfologi;
No comments:
Post a Comment