Get the Centroid of a specific object in an image
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi,
I have a binarized image with a circle as shown below, and I wish to get the centroid of the circle.
Can anyone please guide me how?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/274934/image.png)
I have tried with using 'regionprops' with 'Centroid', however it does not provide me the centroid of the circle but the centroid of the whole image.
props = regionprops(binaryImage,'Centroid');
boundingBox = props.Centroid;
Also, I tried using 'BoundingBox' with 'regionprops' as well. But I am not sure whether the value given is location of the circle or the centroid of it.
props = regionprops(binaryImage,'BoundingBox');
boundingBox = props.BoundingBox;
Thank you if anyone would like to help me.
댓글 수: 0
채택된 답변
KSSV
2020년 3월 4일
I = imread("image.png") ;
[y,x] = find(I==0) ;
iwant = [mean(x) mean(y)] ;
% check
imshow(I)
hold on
plot(iwant(1),iwant(2),'+r')
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!