How can I find the centroid of this circle of objects?
6 ビュー (過去 30 日間)
古いコメントを表示
Is it possible to find the center of this circle of unconnected objects?
I have tried using regionprops, however, it does not give me a centroid in the center.
Thank you

0 件のコメント
回答 (1 件)
Rik
2020 年 5 月 29 日
There are at least two options here. The first is to take the average of the x coordinates and y coordinates of the white pixels.
The second in a bit more involved. You can define a cost function (e.g. the sum of all the distances from the centroid to each point) and fit a value to that function. The performance would probably improve if you skeletonize your image first.
1 件のコメント
Ameer Hamza
2020 年 5 月 29 日
This code follows the Rik's idea
img = imbinarize(rgb2gray(im2double(imread('image.jpeg'))));
rgs = regionprops(img);
[~,idx] = max([rgs.Area]);
rgs(idx) = [];
center = vertcat(rgs.Centroid);
[xc, yc, R] = circfit(center(:,1), center(:,2));
imshow(img);
hold on
plot(xc, yc, 'r+', 'LineWidth', 2)
images.roi.Circle(gca,'Center',[xc yc],'Radius',R,'Color','r');
circfit() is used from here: https://www.mathworks.com/matlabcentral/fileexchange/5557-circle-fit

The fit looks quite accurate.
参考
カテゴリ
Help Center および File Exchange で Image Segmentation and Analysis についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!