Error when upload image to GUI

21 vues (au cours des 30 derniers jours)
Deema
Deema le 16 Sep 2023
Commenté : Deema le 16 Sep 2023
This the error:
GUITask1
Unrecognized field name "axes2".
Error in GUITask1>pushbutton2_Callback (line 117)
axes(handles.axes2);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in GUITask1 (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)GUITask1('pushbutton2_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback.
This the code:
function varargout = GUITask1(varargin)
% GUITASK1 MATLAB code for GUITask1.fig
% GUITASK1, by itself, creates a new GUITASK1 or raises the existing
% singleton*.
%
% H = GUITASK1 returns the handle to a new GUITASK1 or the handle to
% the existing singleton*.
%
% GUITASK1('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in GUITASK1.M with the given input arguments.
%
% GUITASK1('Property','Value',...) creates a new GUITASK1 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before GUITask1_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to GUITask1_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 GUITask1
% Last Modified by GUIDE v2.5 15-Sep-2023 18:29:04
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @GUITask1_OpeningFcn, ...
'gui_OutputFcn', @GUITask1_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 GUITask1 is made visible.
function GUITask1_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 GUITask1 (see VARARGIN)
% Choose default command line output for GUITask1
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes GUITask1 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = GUITask1_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 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)
axes(handles.axes2);
cla;
% --- Executes on button press in pushbutton9.
function pushbutton9_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton9 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes2);
imshow(imcomplement(get(handles.axes2, 'UserData')));
% --- Executes on button press in pushbutton10.
function pushbutton10_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton10 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes2);
edgeImage = edge(rgb2gray(get(handles.axes2, 'UserData')));
imshow(edgeImage);
% --- 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)
[baseFileName, folder] = uigetfile({'*.bmp;*.jpg;*.jpeg', 'Image Files (*.bmp,*.jpg,*.jpeg)'}, 'Select an image file');
if baseFileName == 0
% User canceled the file selection
return;
end
fullFileName = fullfile(folder, baseFileName);
% Store the original image in the UserData of axes2
axes(handles.axes2);
originalImage = imread(fullFileName);
imshow(originalImage);
set(handles.axes2, 'UserData', originalImage);
% --- 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)
axes(handles.axes2);
grayImage = rgb2gray(get(handles.axes2, 'UserData'));
imshow(grayImage);
% --- 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.axes2);
binaryImage = imbinarize(rgb2gray(get(handles.axes2, 'UserData')));
imshow(binaryImage);
% --- 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)
axes(handles.axes2);
imshow(get(handles.axes2, 'UserData'));
% --- 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)
axes(handles.axes1);
imhist(rgb2gray(get(handles.axes2, 'UserData')));
% --- Executes on button press in pushbutton8.
function pushbutton8_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes2);
complementedImage = imcomplement(get(handles.axes2, 'UserData'));
imshow(complementedImage)

Réponse acceptée

Image Analyst
Image Analyst le 16 Sep 2023
You do not have an axes with the name axes2. Open up GUIDE, click on all your axes controls, and look at the "Tag" property. See if any of them have axes2 as their tag property. You will find that you have no such axes with that tag name.
  1 commentaire
Deema
Deema le 16 Sep 2023
Thank you 🙏

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by