matlab 中如何使用bwboundaries获取连通区域并求取其轮廓

[B,L] =bwboundaries(...)

B是一个 P x 1的数组,其中P代表连通体的个数.B内每一行是一个 Q x 2的矩阵,Q内每一行表示连通体的边界像素的位置坐标(第一列是纵坐标Y,第二列是横坐标X),Q为边界像素的个数.
附:引用原文
bwboundaries returnsB, a P-by-1 cell array, where P isthe number of objects and holes. Each cell in the cell arraycontains a Q-by-2 matrix. Each row in the matrix contains the rowand column coordinates of a boundary pixel. Q is the number ofboundary pixels for the corresponding region.

I = imread('rice.png');%读入图像
BW = im2bw(I, graythresh(I));%转换成2进制图像
[B,L] = bwboundaries(BW,'noholes');%寻找边缘,不包括孔
imshow(label2rgb(L, @jet, [.5 .5 .5]))%显示图像
hold on
for k = 1:length(B)
   boundary = B{k};
   plot(boundary(:,2), boundary(:,1), 'w', 'LineWidth', 2)
end%整个循环表示的是描边


  • 10
    点赞
  • 72
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值