Access MinFeretCoordinates data in regionprop table

1 次查看(过去 30 天)
How can I access each circle MinFeretCoordinates?
clc;
clear;
a = imread("circlesBrightDark.png");
bw = a < 50;
imshow(bw)
title("Image with Circles")
stats = regionprops("table",bw,"Centroid","MinFeretProperties", "MajorAxisLength","MinorAxisLength")
stats = 3×6 table
Centroid MajorAxisLength MinorAxisLength MinFeretDiameter MinFeretAngle MinFeretCoordinates ________________ _______________ _______________ ________________ _____________ ___________________ 300 120 79.517 79.517 79 -90 {2×2 double} 330.29 369.92 109.49 108.6 108 0 {2×2 double} 450 240 99.465 99.465 99 -90 {2×2 double}

采纳的回答

Matt J
Matt J 2023-11-26
编辑:Matt J 2023-11-26
For example,
stats{1,'MinFeretCoordinates'}
stats{2,'MinFeretCoordinates'}
stats{3,'MinFeretCoordinates'}
  2 个评论
Ely Raz
Ely Raz 2023-11-26
编辑:Ely Raz 2023-11-26
Thanks. How I can I get an access to the 4 numbers in each cell content {2×2 double}? they are all in one cell (1×1 cell array)
c1 = stats{1,'MinFeretCoordinates'}
Matt J
Matt J 2023-11-26
The same as any other cell, e.g.,
a = imread("circlesBrightDark.png");
bw = a < 50;
stats = regionprops("table",bw,"Centroid","MinFeretProperties",...
"MajorAxisLength","MinorAxisLength");
fourNumbers = stats{1,6}{1}
fourNumbers = 2×2
307.5000 80.5000 307.5000 159.5000

请先登录,再进行评论。

更多回答(1 个)

Walter Roberson
Walter Roberson 2023-11-26
a = imread("circlesBrightDark.png");
bw = a < 50;
imshow(bw)
title("Image with Circles")
stats = regionprops("table",bw,"Centroid","MinFeretProperties", "MajorAxisLength","MinorAxisLength")
stats = 3×6 table
Centroid MajorAxisLength MinorAxisLength MinFeretDiameter MinFeretAngle MinFeretCoordinates ________________ _______________ _______________ ________________ _____________ ___________________ 300 120 79.517 79.517 79 -90 {2×2 double} 330.29 369.92 109.49 108.6 108 0 {2×2 double} 450 240 99.465 99.465 99 -90 {2×2 double}
%then
MFC = cat(3,stats.MinFeretCoordinates{:});
The result would be a 2 x 2 x N numeric array where N is the number of regions detected.
hold on; plot(squeeze(MFC(:,1,:)), squeeze(MFC(:,2,:)), 'r-')

类别

Help CenterFile Exchange 中查找有关 Import, Export, and Conversion 的更多信息

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by