MATLAB Answers

how can I use imellipse or other ROIs in a gui axes created by appdesigner?

2 views (last 30 days)
Ayyoub
Ayyoub on 6 Mar 2017
I am trying to make a gui with appdesigner having three UIaxes. on one of the axes I intend to make a ROI with imellipse such that later on use its coordinate and size (which will be modified by the user) in order to do some processes on the images shown in other two axes but I am not able to show my ellipse on the axes that I want. My question: are the imrect/imellipse supported in appdesigner gui? and if they are, how can I show the ROI on one of the multiple axes in a UIfigure?

Answers (3)


Tim Jackman
Tim Jackman on 24 Sep 2018
Beginning in 18b, you can parent an axes into a uifigure. This means that it is possible to draw the new ellipse ROI in App Designer as follows:
ax = axes(app.UIFigure); drawellipse(ax);
This page has some more info on current axes support in uifigures:
https://www.mathworks.com/help/matlab/creating_guis/graphics-support-in-app-designer.html
Specific to the new ROIs, context menus and mouse pointers are not currently supported, but the basic interactions should work.

Michael Mutersbaugh
Michael Mutersbaugh on 5 Oct 2018
Edited: Michael Mutersbaugh on 5 Oct 2018
Hi, I ran into this problem as well. A loophole that worked for me was to create a new figure, read the image data into it, and offer the user an ROI prompt on THOSE axes instead. Here's an example from my GUI:
fig = figure;
imshow(app.current_frame,[]); % Image data stored in property, no axes called
set(fig, 'Position', get(0, 'Screensize')); % Fullscreen image
set(fig,'CloseRequestFcn','') % Prevent pop-up from closing
set(fig, 'MenuBar', 'none');
set(fig, 'ToolBar', 'none');
% Need this while loop because mouse events will prematurely exit
% the ROI functions, even with the CloseRequestFcn turned off
roi = [];
while isempty(roi)
switch app.roi_type
case 'Circular'; roi = imellipse();
case 'Rectangle'; roi = imrect();
case 'Freehand'; roi = imfreehand();
end
end
app.masks{end+1} = roi.createMask(); % Binary matrices stored in cell array
delete(fig)
Once you save the masks, you can use them to manipulate your image data before offering it to the uiaxes.

Community Treasure Hunt

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

Start Hunting!

Translated by