Using App Designer to Draw Elliptical ROI's

4 次查看(过去 30 天)
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

回答(1 个)

Shubham Sangle
Shubham Sangle 2019-7-10
drawellipse function is available in matlab
You can access documentation of drawellipse as https://in.mathworks.com/help/images/ref/drawellipse.html
  1 个评论
Joseph Henry
Joseph Henry 2019-7-10
I am aware of this. But as far as I know, drawellipse will not work on a UIAxes in app designer correct?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by