边界跟踪matlab,边界跟踪 (bwtraceboundary函数).m

%11.边界跟踪 (bwtraceboundary函数)

clc; clear;

I=imread('e:\role0\003i.bmp');

figure;

imshow(I);

title('原始图像');

I1=rgb2gray(I); %将彩色图像转化灰度图像

threshold=graythresh(I1); %计算将灰度图像转化为二值图像所需的门限

BW=im2bw(I1, threshold); %将灰度图像转化为二值图像

figure imshow(BW);

title('二值图像');

dim=size(BW);

col=round(dim(2)/2)-90; %计算起始点列坐标

row=find(BW(:,col),1); %计算起始点行坐标

connectivity=8;

num_points=180;

contour=bwtraceboundary(BW,[row,col],'N',connectivity,num_points); %提取边界

figure imshow(I1);

hold on;

plot(contour(:,2),contour(:,1), 'g','LineWidth' ,2);

title('边界跟踪图像');

原文:http://blog.csdn.net/whk100312/article/details/45625253

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值