少一點銳利
現在來試著只找出葡萄柚的外輪廓,也就是圓形。你可以先套用更強的 Gaussian 濾波,讓影像更平滑,接著偵測邊緣。這可以透過在 canny 函式中設定更大的 sigma 來達成。
在這個練習中,你將嘗試不同的 canny() 函式 sigma 值。
grapefruit。show_image 已經預先載入。
本練習屬於課程
Python 影像處理
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Apply canny edge detector with a sigma of 1.8
canny_edges = canny(grapefruit, sigma=____)