how to plot centroids of objects? and how to find mid point between them?
6 次查看(过去 30 天)
显示 更早的评论
hello friends,
I want to find centroids of the only connected component objects of binary image.
I have used code is :
if true
figure()
imshow(D);
[L Ne]=bwlabel(D,8);
%%Measure properties of image regions
propied=regionprops(L,'BoundingBox');
hold on
%%Plot Bounding Box
for n=1:size(propied,1)
rectangle('Position',propied(n).BoundingBox,'EdgeColor','g','LineWidth',2)
s = regionprops(D,'centroid');
centroids = cat(1,s.Centroid);
hold on
plot(centroids(:,1),centroids(:,2), 'b*')
hold off
end
end
The result is :
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/154259/image.jpeg)
after that I have found mid point between two centroids.
for that I have used mid= mean(centroids); plot(mid(:,1),'r*');
The result is :
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/154261/image.jpeg)
But its give the mid point of two corner points which is unwanted. how to remove the centroids from the corner points? I want to find mid point between two objects. I would be thankful if somebody helps me to solve this issue.
0 个评论
回答(1 个)
Image Analyst
2016-2-7
I answered this in your duplicate question: http://www.mathworks.com/matlabcentral/answers/266889-how-to-draw-polar-histogram-of-the-object-of-image#comment_341030
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Object Properties 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!