Create a single matrix from regionprops outputs
7 次查看(过去 30 天)
显示 更早的评论
Hello, I use an active contour algorithm in order to get morphometry of 103 features from a raster image. I create a loop in order to launch the algorithm for each matrix which represents a feature. When I start it, I obtain a binary image of the first extracted feature but also its morphometrical properties (using regionprops function). The algorithm restart automatically and overwrites the previous results. Then, I obtain a binary image of the second extracted feature and its morphometrical properties. And so on, until the 103rd feature.
My question is : How can I save the regionprops output of my 103 features in a single matrix ? Do I have to save each binary image and not overwriting it?
%I use regionprops function on a binary image called "mask".
regionprops(mask,'Area','Eccentricity','MajorAxisLengt','MinorAxisLengt','MinorAxisLengt','Perimeter')
%For example, this is the output for feature 52 (on 103):
ans =
Area: 242
MajorAxisLength: 18.2367
MinorAxisLength: 17.0530
Eccentricity: 0.3544
Perimeter: 53.1110
%I wanna get this kind of matrix :
Feature Area MajorAxisLength MinorAxisLength Eccentricity Perimeter
Mask1 106 12.2514 8.6161 0.6054 32.1123
Mask2 217 16.2455 15.6546 0.9851 42.1565
Maskn .................................
Mask103 164 15.8454 9.1564 0.5463 35.1654
Thanks for your help!
0 个评论
采纳的回答
Walter Roberson
2015-10-19
for K = 1 : 103
rprops(K) = regionprops(....);
end
Areas = [props.Area];
MajorAxisLengths = [props.MajorAxisLength];
MinorAxisLengths = [props.MinorAxisLength];
[Areas(:), MajorAxisLengths(:), MinorAxisLengths(:)]
3 个评论
Walter Roberson
2015-10-19
You would need to be updating your "mask" variable inside your loop in order for this to be of use.
If you have disjoint regions on your mask then you do not need to execute in a loop but can still use the technique I show here. The technique I show here is not quite correct for the situation where you have multiple disjoint regions per mask and you are changing mask from loop to loop (but you would have received an error message if that was the case.)
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!