来自fspecial的sobel面具是否找到水平或垂直边缘?

Car*_*ven 1 matlab image-processing edge-detection

所以我在Matlab中做了类似的事情:

s = fspecial('sobel');
imshow(conv2(image, s));
Run Code Online (Sandbox Code Playgroud)

在matlab中,当我创建一个sobel蒙fspecial版并conv2在图像上使用该蒙版时,复杂图像中的边缘是水平边缘还是垂直边缘还是已经添加了水平和垂直边缘?对角边缘怎么样?

sfs*_*man 5

文档fspecial告诉我们

h = fspecial('sobel')返回一个3乘3的滤波器h(如下所示),它通过近似垂直梯度使用平滑效果强调水平边缘.如果需要强调垂直边缘,请调换滤镜

要转置过滤器,请使用

hvert = ( fspecial('sobel') )'
Run Code Online (Sandbox Code Playgroud)

Sobel滤波器基本上是平滑的导数算.通过检测水平和垂直边缘,您基本上可以检索图像渐变的Sobel近似值,这也可以为您提供对角线边缘.

要实际强调边缘而不必担心它们的方向,请使用此渐变的大小:

hy = fspecial('sobel');
hx = hy';
gx = imfilter(image, hx); % x component of Sobel gradient
gy = imfilter(image, hy); % y component 

gmag = hypot(gx,gy); % magnitude of Sobel gradient
Run Code Online (Sandbox Code Playgroud)