How to convert centroid values to array

3 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Convert Image Type 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by