開始使用免費開始

Superpixel 分割

在這個練習中,你會在影像送進人臉偵測機器學習模型之前,先對同一張影像做非監督式分割。

因此,你會把這張影像從 \(265 \times 191 = 50,615\) 個像素,縮減為 \(400\) 個區域。

Young woman
已經以 face_image 預先載入。

show_image() 函式也已為你預先載入。

本練習屬於課程

Python 影像處理

檢視課程

練習說明

  • segmentation 模組匯入 slic() 函式。
  • color 模組匯入 label2rgb() 函式。
  • 使用 slic() 取得含 400 個區域的分割結果。
  • 使用 label2rgb() 將分割結果疊加在原始影像上進行比較。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Import the slic function from segmentation module
from skimage.____ import ____

# Import the label2rgb function from color module
from skimage.____ import ____

# Obtain the segmentation with 400 regions
segments = ____(____, ____= ____)

# Put segments on top of original image to compare
segmented_image = ____(____, ____, kind='avg')

# Show the segmented image
show_image(segmented_image, "Segmented image, 400 superpixels")
編輯並執行程式碼