How to load image through dialog box in GUI creation?
Ältere Kommentare anzeigen
Hello,
I've been working on my bachelors work and got stuck at GUI creation. After loading an image to my GUI, I want to proceed with an image segmentation and analysis. But I keep recieving an error
********************************************************************************************************************
Index exceeds matrix dimensions.
Error in rozhrani>segmentation_button (line 87) model_RG(:,:,2)= A (:,:,2);
Error in gui_mainfcn (line 95) feval(varargin{:});
Error in rozhrani (line 42) gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)rozhrani('segmentation_button',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback
********************************************************************************************************************
Program works fine when Iam loading the image manualy through imread('image.jpg'). But after using a dialog box I immediately end up with the error.
I've already tried all I could find on the internet and also in some matlab guides, but nothing worked. I would be really glad if someone could help me to solve this. Down below I will include an example of my code.
********************************************************************************************************************
function LoadImageButton_Callback(hObject, eventdata, handles)
image=uigetfile('*.jpg*')
axes(handles.axes2)
imshow(image)
handles.image=image;
guidata(hObject,handles);
function segmentation_button(hObject, eventdata, handles)
A=handles.image
axes(handles.axes2)
[r s k]=size(A);
model_RG(:,:,1)= A (:,:,1);
model_RG(:,:,2)= A (:,:,2);
model_RG(:,:,3)= zeros (r,s);
********************************************************************************************************************
This is the part of the code Iam getting error at.
I thank everyone who will try at least helping me out.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Images finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!