Open image in Gui from menu
Ältere Kommentare anzeigen
I am trying to write a simple gui that guides someone through collecting morphometric data from an image. The GUI "works" first time through, but when I want to move on to the next imge, I get errorrs related to handles.ImagesAxis.XLim - but I suspect it is related to a need to reset the image somewhere.
The specific error received was
Unrecognized property 'XLim' for class 'matlab.graphics.primitive.Image'.
Error in NewImTool>Image_Menu_Open_Image_Callback (line 249)
handles.ImageAxis.XLim = [0 m];
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in NewImTool (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)NewImTool('Image_Menu_Open_Image_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating Menu Callback.
Any guidance appreciated.
function Image_Menu_Open_Image_Callback(hObject, eventdata, handles)
% hObject handle to File_Menu_Open_Image (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
h=getImage();
handles.imageFile=h;
I=imread(h);
[m,n]=size(I);
handles.ImageAxis.XLim = [0 m];
handles.ImageAxis.YLim = [0 n];
handles.ImageAxis=imshow(I);
set(handles.info_txt,'String',strcat('File opened is: ',h));
guidata(hObject,handles);
1 Kommentar
Jan
am 12 Jun. 2021
If you mention, that you get "errorrs related to handles.ImagesAxis.XLim", please share the complete messages with us. It is easier to solve a problem than to guess, what the problem is.
Antworten (1)
Jan
am 14 Jun. 2021
Unrecognized property 'XLim' for class 'matlab.graphics.primitive.Image'.
XLim belongs to the axes. In the line:
handles.ImageAxis=imshow(I)
you store the handle of the image, not of the axes. Maybe you want to change it to:
handles.ImageAxis.XLim = [0 m];
handles.ImageAxis.YLim = [0 n];
handles.Image = imshow(I);
1 Kommentar
Thomas Miller
am 14 Jun. 2021
Kategorien
Mehr zu Image Preview and Device Configuration 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!