Can anyone help me? I don't know how to fix errors from this Guide

1 回表示 (過去 30 日間)
Shynta Nanda
Shynta Nanda 2019 年 12 月 27 日
コメント済み: Image Analyst 2019 年 12 月 30 日
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)Hitung_Luas_GUI('pushbutton2_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating DestroyedObject Callback.
function varargout = Hitung_Luas_GUI(varargin)
% HITUNG_LUAS_GUI MATLAB code for Hitung_Luas_GUI.fig
% HITUNG_LUAS_GUI, by itself, creates a new HITUNG_LUAS_GUI or raises the existing
% singleton*.
%
% H = HITUNG_LUAS_GUI returns the handle to a new HITUNG_LUAS_GUI or the handle to
% the existing singleton*.
%
% HITUNG_LUAS_GUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in HITUNG_LUAS_GUI.M with the given input arguments.
%
% HITUNG_LUAS_GUI('Property','Value',...) creates a new HITUNG_LUAS_GUI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before Hitung_Luas_GUI_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to Hitung_Luas_GUI_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 Hitung_Luas_GUI
% Last Modified by GUIDE v2.5 25-Dec-2019 00:30:57
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Hitung_Luas_GUI_OpeningFcn, ...
'gui_OutputFcn', @Hitung_Luas_GUI_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 Hitung_Luas_GUI is made visible.
function Hitung_Luas_GUI_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 Hitung_Luas_GUI (see VARARGIN)
% Choose default command line output for Hitung_Luas_GUI
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
movegui(hObject,'center');
% UIWAIT makes Hitung_Luas_GUI wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = Hitung_Luas_GUI_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 togglebutton1.
function togglebutton1_Callback(hObject, eventdata, handles)
% hObject handle to togglebutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of togglebutton1
% --- Executes on button press in togglebutton2.
function togglebutton2_Callback(hObject, eventdata, handles)
% hObject handle to togglebutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of togglebutton2
% --- 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)
[filename, pathname] = uigetfile('*.*');
if ~isequal(filename,0)
set(handles.pushbutton2,'Enable','on')
axes(handles.axes1)
cla reset
set(gca,'XTick',[])
set(gca,'YTick',[])
axes(handles.axes2)
cla reset
set(gca,'XTick',[])
set(gca,'YTick',[])
axes(handles.axes3)
cla reset
set(gca,'XTick',[])
set(gca,'YTick',[])
Img = imread(fullfile(pathname, filename));
axes(handles.axes1)
imshow(Img,[])
title('Citra Asli')
set(handles.pushbutton2,'Enable','on')
set(handles.pushbutton3,'Enable','off')
else
return
end
handles.Img = Img;
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)
Img = handles.Img;
axes(handles.axes2)
cla reset
set(gca,'XTick',[])
set(gca,'YTick',[])
axes(handles.axes3)
cla reset
set(gca,'XTick',[])
set(gca,'YTick',[])
set(handles.pushbutton3,'Enable','off')
set(handles.edit1,'String',[])
set(handles.edit2,'String',[])
axes(handles.axes1)
cla reset
imshow(Img,[])
title('Citra Asli')
h = imrect;
setColor(h,'b')
mask = createMask(h);
% delete(h);
bw = activecontour(Img,mask,1000);
bw = imfill(bw,'holes');
bw = bwareaopen(bw,500);
bw = imclearborder(bw);
axes(handles.axes2)
cla reset
imshow(Img,[])
title('Hasil Segmentasi')
axis off
hold on
[c,~] = bwboundaries(bw,'noholes');
for k = 1:length(c)
boundary = c{k};
plot(boundary(:,2), boundary(:,1),'y','LineWidth',3)
end
hold off
axes(handles.axes3)
cla reset
imshow(bw)
title('Citra Biner')
set(handles.pushbutton3,'Enable','on')
handles.bw = bw;
guidata(hObject, handles)
% --- 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)
bw = handles.bw;
s = regionprops(bw, 'area','perimeter');
area_bw = cat(1, s.Area);
perim_bw = cat(1, s.Perimeter);
res = 1.362; % resolusi spasial 1.362 pixel/mm
area = area_bw/(res^2)/100;
perimeter = perim_bw/res/10;
set(handles.edit1,'String',[num2str(area),' cm2'])
set(handles.edit2,'String',[num2str(perimeter),' cm'])
set(handles.CTScanImageProcessing,'string',out);
% --- 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)
axes(handles.axes1)
cla reset
set(gca,'XTick',[])
set(gca,'YTick',[])
axes(handles.axes2)
cla reset
set(gca,'XTick',[])
set(gca,'YTick',[])
axes(handles.axes3)
cla reset
set(gca,'XTick',[])
set(gca,'YTick',[])
set(handles.edit1,'String',[])
set(handles.edit2,'String',[])
set(handles.pushbutton2,'Enable','off')
set(handles.pushbutton3,'Enable','off')
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
thank you...
  2 件のコメント
Walter Roberson
Walter Roberson 2019 年 12 月 27 日
Under what circumstances does the error show up?
Note: I recommend against using imshow() for anything other than exploratory work where it is feasible to go back and pull commands out of the command history to restore the properties and graphics that imshow() destroyed on you. imshow() likes to not only clear the axes but also destroy it and create a new one. It is too difficult to work with in a GUI where you are counting on axes retaining properties. Use image() and colormap() instead.
Image Analyst
Image Analyst 2019 年 12 月 30 日
If you're still having a problem, attach both the .fig file and .m file with the paper clip icon.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by