How to display x and y axis to an image in app designer

22 visualizaciones (últimos 30 días)
Hi I attempted to add x and y axis to the image in app designer as I did in GUIDE, I decided to give up and ask for help here.
Here below are my codes:
[filname,pathname] = uigetfile('*.tif', 'Select File to work with');
app.FileNameEditField.Value=filname;
img_ori = imread([pathname, '\', filname]);
[row_img,col_img,clr_img]=size(img_ori);
imshow(img_ori,'Parent',app.UIAxes)
This is an image I loaded in GUIDE, as you see there are X and Y Ticks. I want to see the same axis in the app designer. Could anyone help me figure out how to add the axis? Thanks!

Respuesta aceptada

Image Analyst
Image Analyst el 23 de En. de 2024
Did you try the axis function after you called imshow?
axis('on', 'image');
Under the image processing options/preferences you can set whether you want the axis to be visible by default or not if you use the imshow function (instead of the imagesc function).
  2 comentarios
xiaobo wu
xiaobo wu el 23 de En. de 2024
Awesome! axis('on', 'image') doesn't work as it opens another blank figure, but checking Axes visible works! Thank you so much!
Image Analyst
Image Analyst el 24 de En. de 2024
That seems weird. It should only open a new figure if there is no axes control visible yet. But if there is an axes control on your figure GUI, then axis should work on the current axes, called "gca". If you haven't "used" the axes yet to display anything, then maybe gca is null and it opens a new axes on a new figure. But if you displayed something in the axes, then it should apply. You can pass in the axes handle that you want the command to operate on, so something like
axes(app.axes1, 'on', 'image'); % Turn the axes on for the axes1 control.
If this Answer solves your original question, then could you please click the "Accept this answer" link to award the answerer with "reputation points" for their efforts in helping you? They'd appreciate it. Thanks in advance. 🙂 Note: you can only accept one answer (so pick the best one) but you can click the "Vote" icon for as many Answers as you want. Voting for an answer will also award reputation points.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by