Open image in Gui from menu

1 回表示 (過去 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 '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 件のコメント
Jan
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
Jan 2021 年 6 月 14 日
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 件のコメント
Thomas Miller
Thomas Miller 2021 年 6 月 14 日
Thanks Jan - that seemed to have solved the problem

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by