필터 지우기
필터 지우기

How can I find the centroid of this circle of objects?

조회 수: 6 (최근 30일)
Love Matlab
Love Matlab 2020년 5월 29일
댓글: Ameer Hamza 2020년 5월 29일
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

답변 (1개)

Rik
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
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');
The fit looks quite accurate.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Image Segmentation and Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by