I would be grateful to receive some example of usage of builtin function 'regionprops'
조회 수: 1 (최근 30일)
이전 댓글 표시
Dear MatLab Experts,
I would greatly appreciate your help at understanding how to use the output of builtin function 'regionprops'
My understanding is that it would output a scalar value for each selected property for each connected component.
I have a set of closed curves that I convert to binary masks. The attached zipped archive contains some of such curves.
Each closed curve is descrived by the ordered coordinates in a text file.
Each curve contain only one connected component.
However, when i call 'regionprops' I get a vector of values for each feature I selected.
For instance, how can I have 255 'Area' values and 255 centroid coordinate pairs?
I have attached my script 'Get-Collimator_Features.m' that calls builtin function 'regionprops'.
How can I reduce a vector to a single scalar value, for instance for the Area, etc...?
Some correct usage examples of 'regionprops' would be very appreciated.
Thank you very much.
Best regards,
maura
댓글 수: 2
Matt J
2019년 7월 18일
The code you've attached returns an error. Since the only important line is,
stats = regionprops('table',BW,'Area','FilledArea','ConvexArea','Centroid',...
'Circularity','Eccentricity','EquivDiameter',...
'MaxFeretProperties','MinFeretProperties','Orientation');
it would be better/simpler if you just attach BW in a .mat file so that we can test just that specific line of code.
채택된 답변
Matt J
2019년 7월 19일
Because I don't have R2019b, I had to run a somewhat modified version of the code
S=load('BWCurve.mat','CBW');
BW=S.CBW;
% Get Area Features
stats = regionprops('table',BW,'Area','FilledArea','ConvexArea','Centroid',...
'Eccentricity','EquivDiameter',...
'Orientation');
The result is
stats =
1×7 table
Area Centroid Eccentricity Orientation ConvexArea FilledArea EquivDiameter
__________ ________________ ____________ ___________ __________ __________ _____________
6.6497e+05 558.43 433.81 0.68914 -3.9677 1.0211e+06 1.0211e+06 920.15
This looks fine to me. I'm not sure what "vectors" you are referring to. Nevertheless, if you want to extract the 'Area" data from the table and put it in a separate numeric variable, you would do
Area=stats{:,'Area'}
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Linear Algebra에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!