1

所以我在 Matlab 中做了这样的事情:

s = fspecial('sobel');
imshow(conv2(image, s));

在matlab中,当我创建一个sobel掩码fspecial并在图像上使用该掩码时conv2,卷积图像中的边缘是水平边缘还是垂直边缘,还是已经添加了水平边缘和垂直边缘?那么对角线边缘呢?

4

1 回答 1

5

文件fspecial告诉我们

h = fspecial('sobel') 返回一个 3×3 过滤器 h(如下所示),它通过近似垂直梯度使用平滑效果强调水平边缘。如果您需要强调垂直边缘,请转置过滤器

要转置过滤器,请使用

hvert = ( fspecial('sobel') )'

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
于 2013-03-16T15:33:40.037 回答