Escolar Documentos
Profissional Documentos
Cultura Documentos
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 = Morphological_Operation_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)
if ~isequal(filename,0)
Info = imfinfo(fullfile(pathname,filename));
if Info.BitDepth == 1
msgbox('Citra masukan harus citra RGB atau Grayscale');
return
elseif Info.BitDepth == 8
Img_Gray = imread(fullfile(pathname,filename));
axes(handles.axes1)
cla('reset')
imshow(Img_Gray)
title('Grayscale Image')
Img_bw = im2bw(Img_Gray,graythresh(Img_Gray));
axes(handles.axes2)
cla('reset')
imshow(Img_bw)
title('Binary Image')
else
Img_Gray = rgb2gray(imread(fullfile(pathname,filename)));
axes(handles.axes1)
cla('reset')
imshow(Img_Gray)
title('Grayscale Image')
Img_bw = im2bw(Img_Gray,graythresh(Img_Gray));
axes(handles.axes2)
cla('reset')
imshow(Img_bw)
title('Binary Image')
end
else
return
end
handles.Img_Gray = Img_Gray;
handles.Img_Gray2 = Img_Gray;
handles.Img_bw = Img_bw;
handles.Img_bw2 = Img_bw;
guidata(hObject,handles);
set(handles.pushbutton2,'Enable','on')
% Operations
val1 = get(handles.radiobutton1,'Value');
val2 = get(handles.radiobutton2,'Value');
val3 = get(handles.radiobutton3,'Value');
val4 = get(handles.radiobutton4,'Value');
% Structure Element
val5 = get(handles.radiobutton5,'Value');
val6 = get(handles.radiobutton6,'Value');
val7 = get(handles.radiobutton7,'Value');
val8 = get(handles.radiobutton8,'Value');
% R
R = str2double(get(handles.edit1,'String'));
%
if val5 == 1
se = strel('disk',R);
elseif val6 == 1
se = strel('diamond',R);
elseif val7 == 1
se = strel('square',R);
elseif val8 == 1
se = strel('line',R,45);
end
if val1 == 1
Morph_Gray = imerode(Img_Gray,se);
Morph_bw = imerode(Img_bw,se);
elseif val2 == 1
Morph_Gray = imdilate(Img_Gray,se);
Morph_bw = imdilate(Img_bw,se);
elseif val3 == 1
Morph_Gray = imopen(Img_Gray,se);
Morph_bw = imopen(Img_bw,se);
elseif val4 == 1
Morph_Gray = imclose(Img_Gray,se);
Morph_bw = imclose(Img_bw,se);
end
axes(handles.axes1)
cla('reset')
imshow(Img_Gray)
title('Grayscale Image')
axes(handles.axes2)
cla('reset')
imshow(Img_bw)
title('Binary Image')
axes(handles.axes3)
cla('reset')
imshow(Morph_Gray)
title('Morphological Operation')
axes(handles.axes4)
cla('reset')
imshow(Morph_bw)
title('Morphological Operation')
axes(handles.axes2)
cla('reset')
set(gca,'XTick',[])
set(gca,'YTick',[])
axes(handles.axes3)
cla('reset')
set(gca,'XTick',[])
set(gca,'YTick',[])
axes(handles.axes4)
cla('reset')
set(gca,'XTick',[])
set(gca,'YTick',[])
set(handles.pushbutton2,'Enable','off')
set(handles.edit1,'String',1)
set(handles.radiobutton1,'Value',1)
set(handles.radiobutton2,'Value',0)
set(handles.radiobutton3,'Value',0)
set(handles.radiobutton4,'Value',0)
set(handles.radiobutton5,'Value',1)
set(handles.radiobutton6,'Value',0)
set(handles.radiobutton7,'Value',0)
set(handles.radiobutton8,'Value',0)