hey ,I make GUI Application in matlab for brain tumor segmentation and I have this problem

4 visualizaciones (últimos 30 días)
function varargout = GUi(varargin)
% GUI MATLAB code for GUi.fig
% GUI, by itself, creates a new GUI or raises the existing
% singleton*.
%
% H = GUI returns the handle to a new GUI or the handle to
% the existing singleton*.
%
% GUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in GUI.M with the given input arguments.
%
% GUI('Property','Value',...) creates a new GUI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before GUi_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to 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 GUi
% Last Modified by GUIDE v2.5 06-Jul-2019 01:31:00
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @GUi_OpeningFcn, ...
'gui_OutputFcn', @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 GUi is made visible.
function 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 GUi (see VARARGIN)
% Choose default command line output for GUi
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes GUi wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = 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 load.
function load_Callback(hObject, eventdata, handles)
% hObject handle to load (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global im im2
[path,user_cancel]=imgetfile();
if user_cancel
msbox(sprintf('Invalide selection'),'Error','Error');
return
end
im=imread(path); %read the path of the image
im=im2double(im); %convert to double
im2=im; %Backup of image
axes(handles.axes1);
imshow(im)
title('\fontsize{18}\color[rgb]{0.635 0.078 0.184}Patient''s Brain')
% --- Executes on button press in detect.
function detect_Callback(hObject, eventdata, handles)
% hObject handle to detect (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global im
axes(handles.axes2);
bw=imbinarize(img,0.7); %Thresholding value if less than 0.7 color is black ,if morr than 0.7 color is white
label = bwlabel(logical(bw)); %area of tumor
stats = regionprops(label , 'Solidity', 'Area'); % properties of healthy region
denisty = [stats.Solidity];
area = [stats.Area];
high_dense_area = denisty > 0.5 ; %Area of tumor
max_area = max(area(high_dense_area)); %max area
tumor_label = find(area == max_area); %place of tumor
tumor = ismember(label, tumor_label);
se = strel('square',5);
tumor = imdilate(tumor,se);
B= bwboundaries(tumor,'noholes');
imshow(im);
hold on
for i=1:length(B)
plot(B{i}(:,2), B{i}(:,1),'y','linewidth',1.45)
end
title('\fontsize{18}\color[rgb]{0.635 0.078 0.184}Detect Brain')
hold off
% --------------------------------------------------------------------
function about_Callback(hObject, eventdata, handles)
% hObject handle to about (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --------------------------------------------------------------------
function author_Callback(hObject, eventdata, handles)
% hObject handle to author (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
msgbox(sprintf('Name:Aml omar\nEmail:amlomar782@gmail.com\nID1100602'),'Author','Help')
and problem is
Error in GUi (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)GUi('detect_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback.

Respuestas (1)

Geoff Hayes
Geoff Hayes el 8 de Jul. de 2019
Editada: Geoff Hayes el 8 de Jul. de 2019
Mohamed - you haven't copied and pasted the full error message, but looking at the code to your callback
function detect_Callback(hObject, eventdata, handles)
% hObject handle to detect (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global im
axes(handles.axes2);
bw=imbinarize(img,0.7); %Threshol
there is a global variable named im but you are passing img into the imbinarize function. I suspect that you mean to do
bw=imbinarize(im,0.7); %Threshol
instead.
Please note that using the handles structure to store user data is an alternative to using global variables.

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Productos


Versión

R12.1

Community Treasure Hunt

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

Start Hunting!

Translated by