Matlab图像处理——图像边缘检测方法(算子)

1.edge函数语法

Matlab 复制代码
BW = edge(I)
BW = edge(I,method)
BW = edge(I,method,threshold)
BW = edge(I,method,threshold,direction)
BW = edge(___,"nothinning")
BW = edge(I,method,threshold,sigma)
BW = edge(I,method,threshold,h)

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" 时,此语法才有效。

BW = edge(___,"nothinning") 跳过边缘细化阶段,这可以提高性能。仅当 method 是 "Sobel"、"Prewitt" 或 "Roberts" 时,此语法才有效。

BW = edge(I,method,threshold,sigma) 指定 sigma,即滤波器的标准差。仅当 method 是 "log" 或 "Canny" 时,此语法才有效。

BW = edge(I,method,threshold,h) 使用 "zerocross" 方法和您指定的滤波器 h 检测边缘。仅当 method 是 "zerocross" 时,此语法才有效。

2.使用示例
Matlab 复制代码
clear
clc
I=imread('1.jpg');%读入图像
I=rgb2gray(I); %转换为灰度图像
I=im2double(I);
[J1,thresh]=edge(I,'Roberts',[],'both');
[J2,thresh]=edge(I,'Roberts',[],'horizontal');
[J3,thresh]=edge(I,'Roberts',[],'vertical');
subplot(221);imshow(I);title('原始图像');
subplot(222);imshow(J1);title('Roberts算子,水平和垂直方向');
subplot(223);imshow(J2);title('Roberts算子,水平方向');
subplot(224);imshow(J3);title('Roberts算子,垂直方向');

最后:

如果你想要进一步了解更多的相关知识,可以关注下面公众号联系~ 会不定期发布相关设计内容包括但不限于如下内容:信号处理、通信仿真、算法设计、matlab appdesigner,gui设计、simulink仿真......希望能帮到你!

相关推荐
春日见19 小时前
从底层思维3分钟彻底弄清卷积神经网络CNN
人工智能·深度学习·神经网络·计算机视觉·docker·cnn·计算机外设
FelixZhang02820 小时前
从 PDF 到 AI 知识库:RAG 数据预处理的六步标准流水线 (SOP)
人工智能·python·目标检测·计算机视觉·语言模型·ocr·numpy
盼小辉丶21 小时前
Transformer实战(38)——视觉Transformer (Vision Transformer, ViT)
深度学习·计算机视觉·transformer
Steiwe21 小时前
多模态大模型产生幻觉的直接原因是否是语言先验问题
人工智能·计算机视觉
大江东去浪淘尽千古风流人物21 小时前
【Basaalt】Visual-Inertial Mapping with Non-Linear Factor Recovery论文解读
人工智能·计算机视觉
88号技师21 小时前
2026年3月新锐一区SCI-随机社会学习优化算法Stochastic social learning-附Matlab免费代码
学习·算法·数学建模·matlab·优化算法
88号技师1 天前
2025年11月一区SCI-壁虎优化算法Gekko Japonicus Algorithm-附Matlab免费代码
开发语言·算法·数学建模·matlab·优化算法
PC_Clinic1 天前
技术不只向前,也能回头看。老照片翻新修复,让遗忘的重新被记起
图像处理·人工智能·生活
兮℡檬,1 天前
视觉几何(3D->2D,2D->3D)
人工智能·数码相机·计算机视觉
新缸中之脑1 天前
Nano Banana 相机控制
人工智能·数码相机·计算机视觉