How to display x and y axis to an image in app designer
22 views (last 30 days)
Show older comments
xiaobo wu
on 23 Jan 2024
Commented: Image Analyst
on 24 Jan 2024
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!
0 Comments
Accepted Answer
Image Analyst
on 23 Jan 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 Comments
Image Analyst
on 24 Jan 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.
More Answers (0)
See Also
Categories
Find more on Migrate GUIDE Apps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!