Return 来自条件的结构字段值

Return structure field value from criteria

我有一个由 regionprops() 创建的 MATLAB 结构,它 return 是二值图像的面积和质心。目前,该结构有 16 对值(存在的每个二进制 blob 对应一个 Area 和 Centroid 对)。 我的问题是,如何 return Area 满足条件的质心值?如,return 最大区域的质心值。

目前,我通过

找到最大的面积值
maxArea = max([struct.Area]);

其中 return 是结构 struct 中最大区域所在的行号。如何使用此行号输出最大面积对的质心值?或者有更好的方法吗?

谢谢!

试试这个:

[maxArea, ind] = max([s.Area]); %//get the max Area, and the index
s(ind).Centroid %//the centroid with the max area