Create multiple structure properties from a stack of 3D images

2 次查看(过去 30 天)
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!

采纳的回答

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

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by