【问题标题】:MATLAB: isolating perimeters of regions of interest in binary image: bwmorph issuesMATLAB:隔离二进制图像中感兴趣区域的周长:bwmorph 问题
【发布时间】:2016-06-15 01:14:39
【问题描述】:

我有一个二进制图像(附加),其中连接的组件用 bwconncomps 隔离。我正在尝试识别这些组件中的每一个的轮廓,但我仍然可以参考填充的对象-(我使用轮廓作为灰度图像上的蒙版来提取一些值,然后取决于那个值对填充的原始感兴趣区域执行操作)

当我在附加图像上运行 bwconncomps 时,我识别出 814 个对象。我可以运行 bwmorph(D,'remove');我得到了对象的轮廓/周长,但是当我在上面运行 bwconncomps 时,我得到了 827 个对象——(不确定这些额外的对象来自哪里,这会破坏我根据值 I 引用填充对象的能力从其轮廓中拉出)。

基本上,我需要一个 bwmorph(D,'remove') 版本,它会留下与原始二进制图像的 bwconncomps 中看到的相同数量的连接组件..以便我可以将原始二进制中的组件 #30 与bwconncomps 中相同 #30 的轮廓。

希望这很清楚,有什么建议吗?

谢谢

【问题讨论】:

    标签: matlab binary region connected-components


    【解决方案1】:

    您可以使用 bwboundaries 找到白色连通分量的像素边界,这样每个连通分量都有一组对应的边界。

    %calculate boundries and generate boundry mask
    B = bwboundaries(im,'noholes');
    boundriesImage = zeros(size(im));
    boundriesPixels = cell2mat(B);
    boundriesImage(sub2ind(size(im),boundriesPixels(:,1),boundriesPixels(:,2)))=1;
    
    %finds the connected component in the original image and in the boundry
    %mask
    CC = bwconncomp(im);
    CC2 = bwconncomp(boundriesImage);
    

    结果:CC 和 CC2 包含相同数量的连通分量

    CC = 
    
        Connectivity: 8
           ImageSize: [535 1571]
          NumObjects: 814
        PixelIdxList: {1x814 cell}
    
    CC2 = 
    
        Connectivity: 8
           ImageSize: [535 1571]
          NumObjects: 814
        PixelIdxList: {1x814 cell}
    

    此外,每个连接的组件 CC2{ii} 都与它的 CC{ii} 匹配,如以下测试结果所示:

    %tests that for each ii, CC{ii} is contained in CC{i}
    CC2MatchesToCC1 = true;
    for ii=1:length(CC.PixelIdxList)
        if length(intersect(CC2.PixelIdxList{ii},CC.PixelIdxList{ii}))~=length(CC2.PixelIdxList{ii})
            CC2MatchesToCC1 = false;
        end
    end
    

    结果:

    CC2MatchesToCC1 =
    
     1
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-15
      • 2011-08-10
      • 1970-01-01
      • 2012-03-08
      • 1970-01-01
      相关资源
      最近更新 更多