Open image in Gui from menu

2 ビュー (過去 30 日間)
Thomas Miller
Thomas Miller 2021 年 6 月 11 日
コメント済み: Thomas Miller 2021 年 6 月 14 日
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 ''.
Error in NewImTool>Image_Menu_Open_Image_Callback (line 249)
handles.ImageAxis.XLim = [0 m];
Error in gui_mainfcn (line 95)
Error in NewImTool (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in>@(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)
handles.ImageAxis.XLim = [0 m];
handles.ImageAxis.YLim = [0 n];
set(handles.info_txt,'String',strcat('File opened is: ',h));
  1 件のコメント
Jan 2021 年 6 月 12 日
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.


回答 (1 件)

Jan 2021 年 6 月 14 日
Unrecognized property 'XLim' for class ''.
XLim belongs to the axes. In the line:
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 件のコメント
Thomas Miller
Thomas Miller 2021 年 6 月 14 日
Thanks Jan - that seemed to have solved the problem





Community Treasure Hunt

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

Start Hunting!

Translated by