imfill

Fill image regions and holes.
    BW2 = imfill(BW1,LOCATIONS) performs a flood-fill operation on
    background pixels of the input binary image BW1, starting from the
    points specified in LOCATIONS. 

    BW2 = imfill(BW1,'holes') fills holes in the input image.  A hole is
    a set of background pixels that cannot be reached by filling in the
    background from the edge of the image.

    I2 = imfill(I1) fills holes in an intensity image, I1.  In this
    case a hole is an area of dark pixels surrounded by lighter pixels.

imfill - Free thought - Free Thought
需求:如上图所示,想将其中的闭合区域物体部分整体标记出来,去除掉里面的细小区域,用此函数即可达到此目的

 imfill(edgeMapTemp,'holes');
以下是结果:
imfill - Free thought - Free Thought
注意到其中的小区域已经消失,而靠近边缘处的区域也没有填充,因此此算法是flood fill算法,从边缘处开始寻找,如果有多余两处的非边缘闭合区域,则都被填充,如下图所示,将图1中最上面的非闭合区域进行闭合(只是加了一条线),再进行同样的操作后,会出现如下结果:
imfill - Free thought - Free Thought
  imfill - Free thought - Free Thought  
因此,在进行此操作时,一定要注意其中的闭合区域是否属于自己可控范围之内。
 
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值