matlab实现图像边缘检测

函数edge():查找强度图像的边缘

常用函数说明:

BW = edge(I) 返回二值图像 BW,其中的值 1 对应于输入图像 I 中函数找到边缘的位置,值 0 对应于其他位置。默认情况下,edge 使用 Sobel 边缘检测方法。

BW = edge(I,method) 使用 method 指定的边缘检测算法检测图像 I 中的边缘。

BW = edge(I,method,threshold) 返回强度高于 threshold 的所有边缘。

BW = edge(I,method,threshold,direction) 指定要检测的边缘的方向。Sobel 和 Prewitt 方法可以检测垂直方向和/或水平方向的边缘。Roberts 方法可以检测与水平方向成 45 度角和/或 135 度角的边缘。仅当 method 是 'Sobel''Prewitt' 或 'Roberts' 时,此语法才有效。

边缘检测所涉及的method如下:

学习后变成实现的小练习:

clear all
clc
I=imread('cameraman.tif');
figure(1)
subplot(1,2,1)
imshow(I);
title('原始图像');
BW=edge(I,'sobel');
subplot(1,2,2)
imshow(BW);
title('边缘检测')

[BW,thresh]=edge(I,'sobel');
disp('Sobel算法自动选择的阈值为:')
disp(thresh);
figure(2)
BW1=edge(I,'sobel',0.02,'horizontal');
subplot(2,2,1)
imshow(BW1);
title('水平方向阈值为0.02')
BW2=edge(I,'sobel',0.02,'vertical');
subplot(2,2,2)
imshow(BW2)
title('垂直方向阈值为0.02')
BW3=edge(I,'sobel',0.05,'horizontal');
subplot(2,2,3)
imshow(BW3)
title('水平方向阈值为0.05')
BW4=edge(I,'sobel',0.05,'vertical');
subplot(2,2,4)
imshow(BW4)
title('垂直方向阈值为0.05')

 效果图如下:

 

 

 

  • 5
    点赞
  • 71
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值