How to convert centroid values to array

3 vues (au cours des 30 derniers jours)
Ad
Ad le 25 Avr 2017
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]

Réponses (1)

Image Analyst
Image Analyst le 7 Mai 2017
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);

Catégories

En savoir plus sur Convert Image Type dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by