How to convert centroid values to array

3 ビュー (過去 30 日間)
Ad
Ad 2017 年 4 月 25 日
回答済み: Image Analyst 2017 年 5 月 7 日
distance=l(1).centroid; %works fine
1 2
1 12.79 9.970
*while performing loop I am getting an error of array mismatch.(I think centroid has two values but I am trying to assign it to single array.)
for i=1:N
distance(i)=l(i).Centroid % getting an error
end
centroid values
[12.7956777996070,9.97053045186637]
[12.3260393873085,45.6477024070019]
[12.2386934673366,63.8693467336681]
[17.4170755642790,86.2463199214916]
[13.3798076923078,118.569711538463]

回答 (1 件)

Image Analyst
Image Analyst 2017 年 5 月 7 日
I wouldn't call it l - It's probably the single worst name, other than O that you could use. I looks too much like 1(one) and l (lower case L). Call it props since it comes from regionprops(). So
allCentroids = [props.Centroid];
xCentroids = allCentroids(1:2:end);
yCentroids = allCentroids(2:2:end);

カテゴリ

Help Center および File ExchangeComputer Vision with Simulink についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by