How can I store x y coordinates of centroids that are found using region props within a loop?
3 views (last 30 days)
Show older comments
s = regionprops(L, 'Area', 'Centroid', 'BoundingBox'); % code
I have found these properties using region props.
I need to find a way of storing the x and y coordinates from a loop for use later on and if they can be numbered with the iteration number too would be great.
0 Comments
Answers (1)
Christiaan
on 11 Mar 2015
Dear Mauricio,
As you stated finds the line (stat = regionprops(I,'centroid');) all the centroids in the image. (here 'I' is the image) Now the values of the centroids are stored in this variable. An example to extract those codes can be:
for i=1:length(stat)
x_centroid(i) = stat(i).Centroid(1);
y_centroid(i) = stat(i).Centroid(2);
end
For more information about plotting the centroids, you coud have a look at a previous post of mine here.
Kind regards, Christiaan
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!