How to insert multiple circles on selected points on an image?
9 views (last 30 days)
Show older comments
Hello, I am trying to find the (x,y) coordinates of 14 points on an image and draw circles and label them with numbers.
I have the following code. I am able to find the coordinates, however, it's only showing one circle on the last point I select. Can someone please help me and figure out what I am doing wrong? Also, how do I insert numbers along with the circles?
Thanks in advance!
%%
moving=imread('biopsy burn 2.JPG');
imagesc(moving);
[x,y]=getpts;
pos=[x,y];
for i = 1:length(pos)
shape=insertShape(moving,'circle',[pos(i,:),40],'LineWidth',10,'Color', 'White');
end
figure
imagesc(shape)
0 Comments
Answers (1)
DGM
on 9 Jul 2021
I don't have CVT, so I can't test this, but you're never saving the output of shape. Each time, you're starting from the source image.
You shouldn't need to use the loop anyway. InsertShape() accepts a point list directly
% should be able to pass a list of all points and radii in one call without the loop
shape=insertShape(moving,'circle',[pos,40*ones(size(pos,1),1)],'LineWidth',10,'Color', 'White');
See the section on the 'position' property:
As far as text labels go, you should be able to use insertText(), which can similarly take multiple points at once.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!