-3

我是 MAT LAB 的初学者。我试图在图像中找到对象的中心点,其中对象指的是圆形、正方形、星形、三角形和五边形。任何人都可以帮助我或指导我在编码中找到图像中上述对象的中心吗?

4

2 回答 2

1

regionprops@Shai建议的示例

于 2013-10-28T14:22:08.313 回答
0

您必须使用regionprops测量图像内区域属性的功能,例如:面积、区域周长、质心...

我建议您查看本页中的第一个示例:Calculate Centroids and Superimpose Locations on Image。该代码显示了如何计算包含文本的图像的不同区域(字母)的质心。

% read image text.png
BW = imread('text.png');

%Calculate centroids for connected components in the image using regionprops.
s = regionprops(BW,'centroid');

%Concatenate structure array containing centroids into a single matrix.
centroids = cat(1, s.Centroid);

% Display binary image with centroid locations superimposed.
imshow(BW)
hold on
plot(centroids(:,1),centroids(:,2), 'b*')
hold off
于 2015-05-30T16:57:06.430 回答