图像边缘检测

一、实验目的:熟悉边缘检测的基本方法

二、实验内容:chairgray.jpg图像为例,分别采用sobelprewittroberts

log对该图像及其加上噪声后的图像进行边缘检测。用到的matlab函数为edge,imnoise

复制代码
复制代码
 1 a=imread('D:/picture/ZiXia.jpg');
 2 a=rgb2gray(a);
 3 figure('name','图像分割');
 4 subplot(2,5,1)
 5 imshow(a);
 6 bw1=edge(a,'sobel');
 7 bw2=edge(a,'prewitt');
 8 bw3=edge(a,'roberts');
 9 bw4=edge(a,'log');
10 subplot(2,5,2),imshow(bw1);
11 xlabel('sobel');
12 subplot(2,5,3),imshow(bw2);
13 xlabel('prewitt');
14 subplot(2,5,4),imshow(bw3);
15 xlabel('roberts');
16 subplot(2,5,5),imshow(bw4);
17 xlabel('log');
18 a=imnoise(a,'gaussian',0.02);
19 subplot(2,5,6)
20 imshow(a);
21 bw1=edge(a,'sobel');
22 bw2=edge(a,'prewitt');
23 bw3=edge(a,'roberts');
24 bw4=edge(a,'log');
25 subplot(2,5,7),imshow(bw1);
26 xlabel('sobel');
27 subplot(2,5,8),imshow(bw2);
28 xlabel('prewitt');
29 subplot(2,5,9),imshow(bw3);
30 xlabel('roberts');
31 subplot(2,5,10),imshow(bw4);
32 xlabel('log');
复制代码

 

复制代码

 

可以得知噪声对边缘检测的结果会产生一定的影响

edge函数介绍

复制代码
BW = edge(I)
采用灰度或一个二值化图像I作为它的输入,并返回一个与I相同大小的二值化图像BW,在函数检测到边缘的地方为1,其他地方为0

BW = edge(I,'sobel') 自动选择阈值用Sobel算子进行边缘检测。

BW = edge(I,'sobel',thresh) 根据所指定的敏感度阈值thresh,用Sobel算子进行边缘检测,它忽略了所有小于阈值的边缘。当thresh为空时,自动选择阈值。

BW = edge(I,'sobel',thresh,direction) 根据所指定的敏感度阈值thresh,在所指定的方向direction上,用Sobel 算子进行边缘检测。Direction可取的字符串值为horizontal(水平方向)、vertical(垂直方向)或both(两个方向)。

[BW,thresh] = edge(I,'sobel',...) 返回阈值

BW = edge(I,'prewitt') 自动选择阈值用prewitt算子进行边缘检测。

BW = edge(I,'prewitt',thresh) 根据所指定的敏感度阈值thresh,用prewitt算子进行边缘检测,它忽略了所有小于阈值的边缘。当thresh为空时,自动选择阈值。

BW = edge(I,'prewitt',thresh,direction) 根据所指定的敏感度阈值thresh,在所指定的方向direction上,用prewitt算子进行边缘检测。Direction可取的字符串值为horizontal(水平方向)、vertical(垂直方向)或both(两个方向)默认方向为both

[BW,thresh] = edge(I,'prewitt',...) 返回阈值

BW = edge(I,'roberts') 自动选择阈值用roberts算子进行边缘检测。

BW = edge(I,'roberts',thresh) 根据所指定的敏感度阈值thresh,用Roberts算子进行边缘检测,它忽略了所有小于阈值的边缘。当thresh为空时,自动选择阈值。 Matlab中文论坛

[BW,thresh] = edge(I,'roberts',...) 返回阈值

BW = edge(I,'log') 自动选择阈值用LOG算子进行边缘检测。
复制代码

 

posted @   你的雷哥  阅读(864)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 25岁的心里话
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!
· 零经验选手,Compose 一天开发一款小游戏!
点击右上角即可分享
微信分享提示