【问题标题】:Return structure field value from criteria从条件返回结构字段值
【发布时间】:2016-04-04 17:55:13
【问题描述】:

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

目前,我通过

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

返回结构struct中最大区域所在的行号。如何使用此行号输出作为最大面积对的质心值?或者有没有更好的方法来做到这一点?

谢谢!

【问题讨论】:

    标签: matlab field structure


    【解决方案1】:

    试试这个:

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

    【讨论】:

    • 完美!正是我想要的。谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-16
    相关资源
    最近更新 更多