how to use drawcircle methods with centroids array from bwconncomp

1 回表示 (過去 30 日間)
mehmet baki
mehmet baki 2024 年 5 月 27 日
移動済み: DGM 2024 年 5 月 27 日
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 Center および File ExchangeGet 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