How to insert multiple circles on selected points on an image?
9 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
DGM
2021-7-9
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.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!