Using App Designer to Draw Elliptical ROI's
1 次查看(过去 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
0 个评论
回答(1 个)
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
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!