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仿真......希望能帮到你!

相关推荐
Rui_Freely8 小时前
Vins-Fusion之ROS2(节点创建、订阅者、发布者)(一)
人工智能·计算机视觉
wuk9989 小时前
使用PCA算法进行故障诊断的MATLAB仿真
算法·matlab
睡醒了叭10 小时前
图像分割-深度学习-FCN模型
人工智能·深度学习·计算机视觉
夏日白云15 小时前
《PDF解析工程实录》第 12 章|别让模型贴着墙走:为什么加一圈空白,效果反而更好?
图像处理·机器学习·pdf·llm·大语言模型·rag·文档解析
Dillon Dong16 小时前
从C到Simulink: 使用 `simulation_stubs`(仿真存根)处理MBD中的硬件依赖
c语言·stm32·matlab
keep_learning11117 小时前
Z-Image模型架构全解析
人工智能·算法·计算机视觉·大模型·多模态
或许好运来17 小时前
MATLAB 低级图形错误
matlab
奔袭的算法工程师18 小时前
论文解读--FocalFormer3D : Focusing on Hard Instance for 3D Object Detection
人工智能·目标检测·计算机视觉
yong999018 小时前
超宽带系统链路 MATLAB 仿真
开发语言·算法·matlab
only-lucky18 小时前
OpenCV(第一章)
人工智能·opencv·计算机视觉