sobel算子 matlab实现6,Sobel算子matlab实现

布满荆棘的人生 2023-01-16 09:36 240阅读 0赞

算子实际上是用来对图像进行卷积处理,其本质是用变分法来处理梯度问题,用途就是边缘检测。45度和135度效果一般,水平检测加垂直检测效果还可以。

function Sobel(name,Threshold)

f = imread(name);

f = rgb2gray(f);

f = im2double(f);

subplot(231);

imshow(f),title(‘rawpicture’);

a45 = [-2 -1 0;

-1 0 1;

0 1 2];

Sobel45 = imfilter(f,a45,’replicate’);

Sobel45 = Sobel45>=Threshold;

subplot(232);

imshow(Sobel45),title(‘45 Sobel edge detect’);

a135 = [0 -1 -2;

1 0 -1;

2 1 0];

Sobel135 = imfilter(f,a135,’replicate’);

Sobel135 = Sobel135>=Threshold;

subplot(233);

imshow(Sobel135),title(‘135 Sobel edge detect’);

[Vertical,Threshold] = edge(f,’sobel’, ‘vertical’);

subplot(234);

imshow(Vertical),title(‘Vertical Sobel edge detect’)

[Horizontal,Threshold] = edge(f,’sobel’,’horizontal’);

subplot(235);

imshow(Horizontal),title(‘Horizontal Sobel edge detect’);

HandV = edge(f,’sobel’,Threshold);

subplot(236);

imshow(HandV),title(‘Horizontal and Vertical Sobel edge detect’);

sobell=edge(f,’sobel’);

figure(2),subplot(121),imshow(HandV);

subplot(122),imshow(sobell);

end

0818b9ca8b590ca3270a3433284dd417.png

发表评论

表情:
评论列表 (有 0 条评论,240人围观)

还没有评论,来说两句吧...

相关阅读

    相关 sobel算子

      彻底理解数字图像处理中的卷积-以Sobel算子为例[https://www.cnblogs.com/freeblues/p/5738987.html][https_www