How to use UIAxes to display image in app viewer
8 views (last 30 days)
Show older comments
I am trying to reproduce a figure in my .m script in App Designer .mlapp script. I want to display a gray scale image and overlay on that image a yellow box, and also overlay a contour of the image all in one figure. I can do this in my .m script with imoshow(insertshape(img)); hold, contour(img) as shown below:
figure(6)
imshow(insertShape(ImgOut(:,:,round(Planes/2)),'FilledRectangle', mbox, 'Color', 'yellow', 'Opacity', 0.2),[])
title(['Site',num2str(s),' measurement ROI box placement'])
hold all
contour(ImgOut(:,:,round(Planes/2)),[TH,TH],'LineColor','white')
I want to imbed this figure in my App Designer .mlapp script using UIAxes command. I can display the image with the yellow box but I can't overlay the contour. This is what I've tried and it only displays the image with box, no contour:
imshow(insertShape(ImgOut(:,:,round(Planes/2)),'FilledRectangle', mbox, 'Color', 'yellow', 'Opacity', 0.2),[],'Parent',app.UIAxes)
hold all
contour(ImgOut(:,:,round(Planes/2)),[TH,TH],'LineColor','white')
0 Comments
Answers (1)
Cris LaPierre
on 29 May 2020
Edited: Cris LaPierre
on 29 May 2020
I suspect you need to specify the parent axes for the contour plot
contour(app.UIAxes,ImgOut(:,:,round(Planes/2)),[TH,TH],'LineColor','white')
3 Comments
Cris LaPierre
on 30 May 2020
I'm not testing this, but you do say the code at the top worked in a script, right? Try adding this hold command immediately before adding the contour plot.
hold(app.UIAxes,'on')
See Also
Categories
Find more on Lighting, Transparency, and Shading 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!