how to use drawcircle methods with centroids array from bwconncomp

1 次查看(过去 30 天)
I want to draw circles from bwconncomp I have centroids but I could not draw with drawcircles all circles
imshow(image);hold on;title(['Delik Sayısı: ', num2str(length(stats))]);
%viscircles(centroids,8);
for i=1:length(centroids)
h=drawcircle("Center",[centroids(i,1),centroids(i,2)],"Radius",10,'Color','r');
end
mask = createMask(h);
imshow(mask)

采纳的回答

DGM
DGM 2024-5-27
移动:DGM 2024-5-27
You're repeatedly overwriting h before you do anything with it. It's not clear what you expect to happen. If you just want the union of masks, accumulate the union by generating the mask in the loop.
Something like this:
% preallocate the mask based on the appropriate page geometry
% use a variable name other than "image" for your image
% otherwise you're shadowing the function image().
mask = false(size(myimage,1:2));
% accumulate the union of masks
for k = 1:size(centroids,1)
ROI = drawcircle("Center",[centroids(k,1),centroids(k,2)],"Radius",10,'Color','r');
mask = mask | createMask(ROI);
end
imshow(mask)
Otherwise, you'll have to do something different.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with Image Processing Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by