필터 지우기
필터 지우기

Create a single matrix from regionprops outputs

조회 수: 2 (최근 30일)
Rdmato33
Rdmato33 2015년 10월 19일
댓글: Rdmato33 2015년 10월 19일
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!

채택된 답변

Walter Roberson
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
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.)
Rdmato33
Rdmato33 2015년 10월 19일
Ok. Great. Thank you for those comments. I will try.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by