How to insert multiple circles on selected points on an image?

8 views (last 30 days)
Anisha Jamil
Anisha Jamil on 8 Jul 2021
Commented: Anisha Jamil on 9 Jul 2021
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');
for i = 1:length(pos)
shape=insertShape(moving,'circle',[pos(i,:),40],'LineWidth',10,'Color', 'White');

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.
Anisha Jamil
Anisha Jamil on 9 Jul 2021
The link is where I posted an another question related to this

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by