Roberts边缘检测算子




clear all;
sourcePic=imread('9.jpg'); %读取原图像
grayPic=rgb2gray(sourcePic); %转换成灰度图像
subplot(131);imshow(grayPic);title('原图');
[high,width]=size(grayPic);
newGrayPic=grayPic;%为保留图像的边缘一个像素
robertsNum=0; %经roberts算子计算得到的每个像素的值
robertThreshold=0.9; %设定阈值
for j=1:high-1 %进行边界提取
for k=1:width-1
robertsNum = abs(grayPic(j,k)-grayPic(j+1,k+1)) + abs(grayPic(j+1,k)-grayPic(j,k+1));
newGrayPic(j,k)=robertsNum;
end
end
subplot(132);imshow(newGrayPic);title('roberts算子的处理结果');
% Matlab自带函数边缘检测
% K为获取得到的关键帧的灰度图
BW3 = edge(grayPic,'roberts', 0.03);
subplot(133);imshow(BW3,[]);title('Matlab自带函数边缘检测');



评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值