Create a single matrix from regionprops outputs

7 views (last 30 days)
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!

Accepted Answer

Walter Roberson
Walter Roberson on 19 Oct 2015
for K = 1 : 103
rprops(K) = regionprops(....);
end
Areas = [props.Area];
MajorAxisLengths = [props.MajorAxisLength];
MinorAxisLengths = [props.MinorAxisLength];
[Areas(:), MajorAxisLengths(:), MinorAxisLengths(:)]
  3 Comments
Walter Roberson
Walter Roberson on 19 Oct 2015
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.)
Rdmato33
Rdmato33 on 19 Oct 2015
Ok. Great. Thank you for those comments. I will try.

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!