How can I store x y coordinates of centroids that are found using region props within a loop?

3 ビュー (過去 30 日間)
Mauricio Ramirez
Mauricio Ramirez 2015 年 3 月 10 日
回答済み: Christiaan 2015 年 3 月 11 日
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.

回答 (1 件)

Christiaan
Christiaan 2015 年 3 月 11 日
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

Community Treasure Hunt

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

Start Hunting!

Translated by