2013-10-28 28 views
-3

我是MAT LAB的初學者。我試圖在圖像中找到對象的中心點,其中對象指的是圓形,方形,星形,三角形和五角形。任何人都可以幫助我或引導我在編碼中找到圖像中上述對象的中心?圖像處理。查找對象的中心

+0

使用'regionprops' – Shai

回答

0

你必須使用測量區域的屬性的圖像內部,例如功能regionprops的建議:該區域,一個區域的周長,該centroid ...

我建議你檢查這個page的第一個例子:計算圖像上的質心和疊加位置。該代碼顯示如何計算包含文本的圖像的不同區域(字母)的質心。

% 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