How to store the blobs centroid in array one by one in loop

1 回表示 (過去 30 日間)
saravanakumar D
saravanakumar D 2014 年 1 月 14 日
回答済み: Image Analyst 2014 年 1 月 14 日
I have 6 blobs in my picture. I want to store the centroid of each blob in one array. I tried so much time but i get error. Why the below code get error
I think i have to form array inside array? that is each address of the centroid pixel array is in one array
pixelval=zeros(length(STATS),1);
centroid = STATS(i).Centroid;
pixelval(i) = centroid;

採用された回答

Image Analyst
Image Analyst 2014 年 1 月 14 日
Instead of those three lines, try this single line
centroids = [STATS.Centroid];
centroids is an N by 2 array where the first column are the x's and the second column are the y's. Or:
xCentroids = centroids(:,1);
yCentroids = centroids(:,2);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by