How to use roipoly command in app designer?

13 vues (au cours des 30 derniers jours)
Ali Zulfikaroglu
Ali Zulfikaroglu le 4 Mar 2021
I have an image . I want to show this image app designer with using axes button .
and then use roipoly command to draw a region on that axes button in app designer.
how will I do that ? I couldn't manage it.
I have codes to add image and show it in app designer . With image button I am adding image.
But I can't use roipoly command in app designer. I want to use it when I click second button .
properties (Access = private)
t % Using this description
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: SelectAnImageButton
function SelectAnImageButtonPushed(app, event)
[filename pathname]= uigetfile({'*.jpg'},"Open file");
fullpathname= strcat(pathname,filename);
imgf=imread(fullpathname);
if(size(imgf,3)>1)
imgf=rgb2gray(imgf);
end
imshow(imgf,'parent',app.UIAxes);
app.t=imgf % t is in here property function and it should be app.t
end
% Till here I am adding image and show it in app designer on UIaxes
% And below codes I want to use roiploy command I mean draw a region on app designer on UIAxes but it doesn't work
% Button pushed function: SegmentImageButton
function SegmentImageButtonPushed(app, event)
mask=roipoly(app.t);
imshow(app.t,'parent',app.UIAxes);
end
end

Réponse acceptée

Monisha Nalluru
Monisha Nalluru le 10 Mar 2021
Hi Ali,
From my understand, you want to display the mask of roi in the app designer.
roipoly command doesnot gives you the input parameter to target the UIAxes. So when ever you use roiploy command its open a new figure window and gives interactive tool select region of interest.
Once the roipoly command execution is done, close the figure window and use the output to display the in app designer.
% Button pushed function: ROIbuttonButton
function ROIbuttonButtonPushed(app, event)
roi = roipoly(app.Image); % app.Image is image which is display through button press initally
close(gcf); % close the roipoly provided figure window
imshow(roi,'Parent',app.UIAxes); % display the mask of roi
end
I am attaching a sample app for your reference using roiploy.
  1 commentaire
Ali Zulfikaroglu
Ali Zulfikaroglu le 10 Mar 2021
Thank you for your answer. I did similar method when I didn't find anything.
But I wiil accept true your answer :)

Connectez-vous pour commenter.

Plus de réponses (1)

Ali Hamad
Ali Hamad le 5 Juin 2022
As per documentation, roipoly function is not valid in app design. Please use drawcircle or drawrectangle to do the similar action.

Community Treasure Hunt

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

Start Hunting!

Translated by