Open image in Gui from menu

1 visualización (últimos 30 días)
Thomas Miller
Thomas Miller el 11 de Jun. de 2021
Comentada: Thomas Miller el 14 de Jun. de 2021
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 comentario
Jan
Jan el 12 de Jun. de 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.

Iniciar sesión para comentar.

Respuestas (1)

Jan
Jan el 14 de Jun. de 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 comentario
Thomas Miller
Thomas Miller el 14 de Jun. de 2021
Thanks Jan - that seemed to have solved the problem

Iniciar sesión para comentar.

Categorías

Más información sobre Image Processing Toolbox en Help Center y File Exchange.

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by