How to use UIAxes to display image in app viewer

8 visualizaciones (últimos 30 días)
Scott Chegwidden
Scott Chegwidden el 29 de Mayo de 2020
Comentada: Scott Chegwidden el 30 de Mayo de 2020
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')

Respuestas (1)

Cris LaPierre
Cris LaPierre el 29 de Mayo de 2020
Editada: Cris LaPierre el 29 de Mayo de 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 comentarios
Cris LaPierre
Cris LaPierre el 30 de Mayo de 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')
Scott Chegwidden
Scott Chegwidden el 30 de Mayo de 2020
This works! Guess I just needed the right hold syntax. Thanks!!

Iniciar sesión para comentar.

Categorías

Más información sobre Lighting, Transparency, and Shading en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by