2013-03-16 73 views

回答

5

fspecial文檔告訴我們

H = fspecial(「索貝爾」)返回一個3×3濾波器h(如下所示),強調通過近似垂直梯度使用平滑化效果的水平邊緣。如果你需要強調垂直邊緣,調換過濾

轉置過濾器,使用

hvert = (fspecial('sobel'))' 

Sobel filter基本上是一個平滑的微分算。通過檢測水平和垂直邊緣,您基本上可以檢索圖像梯度的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