邊緣偵測
在這個練習中,你將套用 Sobel 濾波器來偵測影像中的邊緣。
soaps_image。show_image() 函式已為你載入。
來看看它是否能找到影像中的所有圖形。
本練習屬於課程
Python 影像處理
練習說明
- 匯入
color模組,以便將影像轉為灰階。 - 從
filters模組匯入sobel()函式。 - 使用
color模組中的適當方法將soaps_image轉為灰階。 - 對取得的灰階影像
soaps_image_gray套用 Sobel 邊緣偵測濾波器。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Import the color module
from ____ import ____
# Import the filters module and sobel function
from skimage.____ import ____
# Make the image grayscale
soaps_image_gray = ____.____(soaps_image)
# Apply edge detection filter
edge_sobel = ____(____)
# Show original and resulting image to compare
show_image(soaps_image, "Original")
show_image(edge_sobel, "Edges with Sobel")