【问题标题】:Calculating area with regionprops matlab用regionprops matlab计算面积
【发布时间】:2015-03-25 18:50:28
【问题描述】:

我有这个使用 contourf 制作的情节

这是一张显微图片,我试图在其中了解每一层的方向。我制作了一个颜色图,其中每 10 度都有一个恒定的颜色。所以基本上我有点假设一个恒定的颜色对应于一个恒定的层。现在我想计算每层的面积。我不知道该怎么做。 所以首先我希望能够让 matlab 告诉我 0 到 10 度的区域是 XX(以像素 ^ 2 为单位)。 但其次,我希望能够指定单层。因为0到10有几个区域,但是我想知道每个区域的面积。

你知道这是否可能吗? 干杯 D

编辑 所以我使用了你的建议,我得到了这样的东西 好的,所以我做到了,一张照片,例如我得到了这个

R = 

  Columns 1 through 3

    [32x1 struct]    [450x1 struct]    [1110x1 struct]

  Columns 4 through 6

    [1978x1 struct]    [2778x1 struct]    [3392x1 struct]

  Columns 7 through 9

    [5249x1 struct]    [8215x1 struct]    [15711x1 struct]

  Columns 10 through 12

    [12019x1 struct]    [5335x1 struct]    [2643x1 struct]

  Columns 13 through 15

    [1804x1 struct]    [1018x1 struct]    [670x1 struct]

  Columns 16 through 18

    [579x1 struct]    [344x1 struct]    [50x1 struct]

我希望能够得到这样的东西(来自 matlab 帮助),但对于该区域

stats = 

        Centroid        MajorAxisLength    MinorAxisLength
    ________________    _______________    _______________

     256.5     256.5    834.46             834.46         
       300       120    81.759             81.759         
    330.47    369.83    111.78             110.36         
       450       240    101.72             101.72         

我还在 matlab 上看到你可以在区域周围重新绘制,就像这里 获取圆的中心和半径。

centers = stats.Centroid;
diameters = mean([stats.MajorAxisLength stats.MinorAxisLength],2);
radii = diameters/2;
Plot the circles.

hold on
viscircles(centers,radii);
hold off

他们从这张图片到那张:

我很想为每个地区都这样做。

【问题讨论】:

    标签: matlab area color-mapping contourf


    【解决方案1】:

    contourf 用于展示,我认为这不是解决您问题的最佳方法。这是基于regionprops 的解决方案(来自图像处理工具箱):

    假设 A 包含您的原始数组/图像

    angs = -90:10:90;
    
    for i = 1:numel(angs)-1
    
        BW = A>=angs(i) & A<angs(i+1);
    
        R{i} = regionprops(BW, 'Area');
    
    end
    

    对于每个区间,R{i} 将包含一个结构,该结构具有与不同区域一样多的元素和一个字段 Area,以像素数为单位。

    希望这会有所帮助,

    【讨论】:

    • 好吧,我做到了,用一张图片,就像我得到这个,例如 R = Columns 1 到 3 [32x1 struct] [450x1 struct] [1110x1 struct] Columns 4 到 6 [1978x1 struct] [2778x1 结构] [3392x1 结构] 第 7 到 9 列 [5249x1 结构] [8215x1 结构] [15711x1 结构] 第 10 到 12 列 [12019x1 结构] [5335x1 结构] [2643x1 结构] 第 13 到 15 列 [1804x1 结构] [1018x1 struct] [670x1 struct] 第 16 到 18 列 [579x1 struct] [344x1 struct] [50x1 struct]
    猜你喜欢
    • 1970-01-01
    • 2017-09-04
    • 1970-01-01
    • 1970-01-01
    • 2015-11-05
    • 1970-01-01
    • 2012-01-29
    • 2011-02-08
    • 2016-12-16
    相关资源
    最近更新 更多