1.3 图像边缘检测edge函数的用法
(1)語法和說明
①BW = edge(I): 返回二值圖像 BW,其中的值 1 對應于灰度或二值圖像 I 中函數找到邊緣的位置,值 0 對應于其他位置。默認情況下,edge 使用 Sobel 邊緣檢測方法。
②BW = edge(I,method): 使用 method 指定的邊緣檢測算法檢測圖像 I 中的邊緣。
③BW = edge(I,method,threshold): 返回強度高于 threshold 的所有邊緣。
④BW = edge(I,method,threshold,direction): 指定要檢測的邊緣的方向。Sobel 和 Prewitt 方法可以檢測垂直方向和/或水平方向的邊緣。Roberts 方法可以檢測與水平方向成 45 度角和/或 135 度角的邊緣。僅當 method 是 ‘Sobel’、‘Prewitt’ 或 ‘Roberts’ 時,此語法才有效。
⑤BW = edge(___,‘nothinning’) : 跳過邊緣細化階段,這可以提高性能。僅當 method 是 ‘Sobel’、‘Prewitt’ 或 ‘Roberts’ 時,此語法才有效。
⑥BW = edge(I,method,threshold,sigma): 指定 sigma,即濾波器的標準差。僅當 method 是 ‘log’ 或 ‘Canny’ 時,此語法才有效。
⑦BW = edge(I,method,threshold,h) : 使用 ‘zerocross’ 方法和您指定的濾波器 h 檢測邊緣。僅當 method 是 ‘zerocross’ 時,此語法才有效。
⑧[BW,threshOut] = edge(___): 返回閾值。
⑨[BW,threshOut,Gv,Gh] = edge(___) : 還返回定向梯度幅值。對于 Sobel 和 Prewitt 方法,Gv 和 Gh 對應于垂直和水平梯度。對于 Roberts 方法,Gv 和 Gh 分別對應于與水平方向成 45° 和 135° 角的梯度。僅當 method 是 ‘Sobel’、‘Prewitt’ 或 ‘Roberts’ 時,此語法才有效。
例:圖像邊緣檢測
I=imread('i678.png'); I1=I(:,:,2); subplot(2,2,1),imshow(I1) title('原圖'); J1=edge(I1 ,'sobel'); subplot(2,2,2),imshow(J1) title('邊緣檢測方法為''sobel'''); J2=edge(I1,'prewitt'); subplot(2,2,3),imshow(J2) title('邊緣檢測方法為''prewitt'''); J3=edge(I1,'log'); subplot(2,2,4),imshow(J3) title('邊緣檢測方法為''log''');總結
以上是生活随笔為你收集整理的1.3 图像边缘检测edge函数的用法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 2.2 图像类型转换
- 下一篇: MATLAB编程练习题