App designer - display multiple ROI on the same image

9 views (last 30 days)
Hi,
I want to display a crosshair and a circle right in the middle of my image. I wanted to do this by defining a function, as below.
I'm not sure how to proceed but whilst a similar approach works in the live editor, the app design function doesn't like this syntax. Is there any way to approach this please? I'm not familiar with the app design environment.
The image is always displayed in a UIFigure object. I've input the values [472, 323] as a position vector for testing. Ideally, they would point to the centre of the image.
Thanks in advance!
function DisplayImage(app)
app.Image.ImageSource = app.fullname;
app.crossHair = images.roi.Crosshair(gca, 'Position', [472, 323], 'Color', 'w');
app.circle = images.roi.Circle(gca, 'Centre', [472, 323], 'Radius', 100, 'Color', 'w');
end

Accepted Answer

Adam Danz
Adam Danz on 10 Mar 2021
I assume "doesn't like this syntax" means that the crosshairs and circle are appearing on a different figure.
The reason that would happen is because of your use of gca instead of the actual axis handle.
Assuming your axis handle is app.UIAxes,
function DisplayImage(app)
app.Image.ImageSource = app.fullname; % ??? Not sure what this is
app.crossHair = images.roi.Crosshair(app.UIAxes, 'Position', [472, 323], 'Color', 'w');
% ^^^^^^^^^^
app.circle = images.roi.Circle(app.UIAxes, 'Center', [472, 323], 'Radius', 100, 'Color', 'w');
% ^^^^^^^^^^^
end
  3 Comments

Sign in to comment.

More Answers (0)

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by