1. 首页 > 星座 > 文章页面

matlab canny算子边缘检测函数代码

okx

币安 Binance,注册即可获得100 USDT的交易费用返还

全球交易量最高的加密资产交易平台,买比特币就上币安!

APP下载   官网注册
如何在matlab中查看自带canny算法

大家好,今天小编来为大家解答matlab canny算子边缘检测函数代码这个问题,数字图像处理边缘检测算子matlab很多人还不知道,现在让我们一起来看看吧!

本文目录

matlab canny算子边缘检测函数代码基于matlab的边缘检测的robert算子的算法怎么写matlab canny算子边缘检测函数代码

I= imread('lena.bmp');%%如果是其他类型图像,请先转换为灰度图

数字图像处理边缘检测算子matlab,使用roberts算子对图像进行边缘检测,并二值化的matlab代码实现...

%%没有噪声时的检测结果

BW_sobel= edge(I,'sobel');

BW_prewitt= edge(I,'prewitt');

BW_roberts= edge(I,'roberts');

BW_laplace= edge(I,'log');

BW_canny= edge(I,'canny'); figure(1);

subplot(2,3,1),imshow(I),xlabel('原始图像');

subplot(2,3,2),imshow(BW_sobel),xlabel('sobel检测');

subplot(2,3,3),imshow(BW_prewitt),xlabel('prewitt检测');

subplot(2,3,4),imshow(BW_roberts),xlabel('roberts检测');

subplot(2,3,5),imshow(BW_laplace),xlabel('laplace检测');

subplot(2,3,6),imshow(BW_canny),xlabel('canny检测');

%%加入高斯噪声(μ=0,σ^2=0.01)检测结果

I_g1= imnoise(I,'gaussian',0,0.01);

BW_sobel= edge(I_g1,'sobel');

BW_prewitt= edge(I_g1,'prewitt');

BW_roberts= edge(I_g1,'roberts');

BW_laplace= edge(I_g1,'log');

BW_canny= edge(I_g1,'canny'); figure(2);

subplot(2,3,1),imshow(I_g1),xlabel('加入高斯噪声(μ=0,σ^2=0.01)图像');

subplot(2,3,2),imshow(BW_sobel),xlabel('sobel检测');

subplot(2,3,3),imshow(BW_prewitt),xlabel('prewitt检测');

subplot(2,3,4),imshow(BW_roberts),xlabel('roberts检测');

subplot(2,3,5),imshow(BW_laplace),xlabel('laplace检测');

subplot(2,3,6),imshow(BW_canny),xlabel('canny检测');

%%加入高斯噪声(μ=0,σ^2=0.02)检测结果

I_g2= imnoise(I,'gaussian',0,0.02);

BW_sobel= edge(I_g2,'sobel');

BW_prewitt= edge(I_g2,'prewitt');

BW_roberts= edge(I_g2,'roberts');

BW_laplace= edge(I_g2,'log');

BW_canny= edge(I_g2,'canny'); figure(3);

subplot(2,3,1),imshow(I_g2),xlabel('加入高斯噪声(μ=0,σ^2=0.02)图像');

subplot(2,3,2),imshow(BW_sobel),xlabel('sobel检测');

subplot(2,3,3),imshow(BW_prewitt),xlabel('prewitt检测');

subplot(2,3,4),imshow(BW_roberts),xlabel('roberts检测');

subplot(2,3,5),imshow(BW_laplace),xlabel('laplace检测');

subplot(2,3,6),imshow(BW_canny),xlabel('c

基于matlab的边缘检测的robert算子的算法怎么写

matlab本身有库函数的。直接调用啊

VC代码:

void BianYuanJianCeDib::Robert()

{

LPBYTE p_data;//原图数据区指针

int wide,height;//原图长、宽

int i,j;//循环变量

int pixel[4];//Robert算子

p_data=this->GetData();

wide=this->GetWidth();

height=this->GetHeight();

LPBYTE temp=new BYTE[wide*height];//新图像缓冲区

//设定新图像初值为255

memset(temp,255, wide*height);

//由于使用2*2的模板,为防止越界,所以不处理最下边和最右边的两列像素

for(j=0;j<height-1;j++)

for(i=0;i<wide-1;i++)

{

//生成Robert算子

pixel[0]=p_data[j*wide+i];

pixel[1]=p_data[j*wide+i+1];

pixel[2]=p_data[(j+1)*wide+i];

pixel[3]=p_data[(j+1)*wide+i+1];

//处理当前像素

temp[j*wide+i]=(int)sqrt((pixel[0]-pixel[3])*(pixel[0]-pixel[3])

+(pixel[1]-pixel[2])*(pixel[1]-pixel[2]));

}

//将缓冲区中的数据复制到原图数据区

memcpy(p_data, temp,wide*height);

//删除缓冲区

delete temp;

}

关于本次matlab canny算子边缘检测函数代码和数字图像处理边缘检测算子matlab的问题分享到这里就结束了,如果解决了您的问题,我们非常高兴。

全网最全 Roberts Prewitt Sobel Laplacian LoG 和 Canny 边缘检测算子 MATLAB自写函数实现
icon

OKX欧易APP,比特币,以太坊交易所

全球顶尖交易所,注册即领最高¥1000元数字盲盒

APP下载   官网注册