MATLAB Answers

0

Using App Designer to Draw Elliptical ROI's

Asked by Joseph Henry on 10 Jul 2019
Latest activity Edited by Joseph Henry on 12 Jul 2019
EDIT: See bottom of this post for solution.
Hi all,
I want to make a GUI that allows a user to draw an ellipse onto an image. The ellipse needs to be drawn with the mouse (i.e. like drawellipse function, not by entering coordinates, axes, etc) and the program needs to save the ellipse data (center coordinates, axes, and rotation angle) to a .mat file.
I'm having trouble with the first part. Currently, I have a GUI which displays an image onto UIAxes like so:
imshow(app.imgcur, 'Parent', app.UIAxes, ...
'XData', [1 app.UIAxes.Position(3)], ...
'YData', [1 app.UIAxes.Position(4)]);
When the user clicks the "Draw ROI" button, the following callback occurs
% Button pushed function: DrawROIButton
function DrawROIButtonPushed(app, event)
h = drawellipse('Color', app.UITable.Data{1,2}, 'Parent', app.UIAxes)
end
However, I get the following error:
Error using images.roi.Ellipse/set
Functionality not supported with UIAxes. For more information, see Graphics Support in App Designer.
From what I've read, drawing ROI's on UIAxes is not a feature supported by Matlab R2019a. Does anyone have a workaround for this issue? I'd rather be able to draw the ROI onto the Axes (or at least set up the code so that from the user's POV it looks that way) so that the app looks clean.
EDIT: If anyone else runs into the same problem for drawing ROIs on a UIAxes, the following code was helpful! Just change the Position vector to whatever your image specs are.
app.myAx = axes(app.UIFigure, 'Units', 'Pixels', 'Position',[1,332,800,450], 'XTick', [], 'YTick', []);
Then, to draw:
drawellipse('Parent', app.myAx)
Cheers

  0 Comments

Sign in to comment.

1 Answer

Answer by Shubham Sangle on 10 Jul 2019

drawellipse function is available in matlab
You can access documentation of drawellipse as https://in.mathworks.com/help/images/ref/drawellipse.html

  1 Comment

I am aware of this. But as far as I know, drawellipse will not work on a UIAxes in app designer correct?

Sign in to comment.