フィルターのクリア

How to draw an circle on the image where i show it on app.Image using app designer

13 ビュー (過去 30 日間)
Here's the image I used
imshow(image,'Parent', app.Images)
to show it on app.Image
I got the coordinate by using
app.point = get(0,'PointerLocation')
And I'm trying to draw an circle on the image when i click the image.
Is there anyway i could draw a circle on the image?
Also, I can't use the app.UIAxes buttonclick callback after getting the image on the UIAxes.
Thanks for all

採用された回答

Cameron
Cameron 2023 年 3 月 5 日
If you have the Image Processing Toolbox, you can use the function drawcircle().
imshow(imread('peacock.jpg'))
h = drawcircle('Color','k','FaceAlpha',0.4);
  7 件のコメント
Cameron
Cameron 2023 年 3 月 7 日
I found an easier workaround for you. The callback for the UIAxes is not passed to its children - in this case the image. So we would have to set the callback for the image to the callback for UIAxes. There are only two lines you would need to add for your code.
% Button pushed function: Button
function ButtonPushed(app, event)
[filename,pathname] = uigetfile({'*.jpg;*.tif;*.png;*.gif'});
image = strcat(pathname,filename);
imshow(image,'Parent', app.UIAxes);
img = app.UIAxes.Children(1);
img.ButtonDownFcn = app.UIAxes.ButtonDownFcn;
end
% Button down function: UIAxes
function UIAxesButtonDown(app, event)
function allevents(src,evt)
disp(['Circle current radius is: ' mat2str(evt.CurrentRadius)]);
disp(['Circle current center is: ' mat2str(evt.CurrentCenter)]);
end
h = drawcircle(app.UIAxes,...
'Color','k',...
'FaceAlpha',0.4);
addlistener(h,'MovingROI',@allevents);
addlistener(h,'ROIMoved',@allevents);
end
jaeyoung gwak
jaeyoung gwak 2023 年 3 月 8 日
Thank you.
Appreciate about your concern.
I recognize I have to click the image twice to draw a circle.
so I give a change to the code a little bit.
classdef CircleROI < matlab.apps.AppBase
properties (Access = private)
ro
end
methods (Access = private)
function roi = circle(app)
drawcircle(app.UIAxes,...
'Color','k',...
'FaceAlpha',0.4);
roi = app.ro;
end
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: Button
function ButtonPushed(app, event)
app.UIAxes.PositionConstraint = "innerposition";
imshow(imread('peacock.jpg'),'Parent',app.UIAxes);
img = app.UIAxes.Children(1);
% img.ButtonDownFcn = app.UIAxes.ButtonDownFcn;
img.ButtonDownFcn = app.circle;
end
But the problem is that I could only get the circle point once even if I click many times.
I draw some image to represent what i want to do.
Sorry for inconvenient and thank you for your help!!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeExplore and Edit Images with Image Viewer App についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by