Create multiple structure properties from a stack of 3D images

2 views (last 30 days)
Hello,
I have a stack of binary images(16 to be exact) in a 3D matrix that I named M2 and I wanted to extract centroids from each of those images inside that 3D matrix using regionprops using for loop, but without any success.
I labeled each of those images and stored them in a new 3D matrix called bw. I want to extract centroids of many labels contained by each image of that 3D matrix and store them in maybe separate structures. But I am not sure how to do that and use them later in my code. I want to be able to get perhaps separate sub-structures containing centroids of each labeled image so that I can access those centroids later on in my code.
I have done this so far:
numImages - is a number of images inside my 3D matrix
bw - is a 3D matrix of my labeled images
M2 - is a 3D matrix of my binary images
for i=1:numImages
s = regionprops(logical(bw(:,:,i)), M2(:,:,i), 'Centroid');
end
Here I am not sure how to get centroids stored in separate structures for each image of my 3D matrix. Any help would be much appreciated.
Thanks in advance!

Accepted Answer

Image Analyst
Image Analyst on 22 Mar 2015
In the loop, put this
strCentroids(i).Centroids = [s.Centroid];
  1 Comment
Mario
Mario on 23 Mar 2015
Thanks, that is working!
Now I have a 1x16 structure s containing all 16 labeled images with each of them having their regions centroids.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!