始める無料で始める

スーパー ピクセルセグメンテーション

この演習では、顔検出の Machine Learning モデルに渡す前に、同じ画像に対して教師なしセグメンテーションを適用します。

つまり、この画像を \(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")
コードを編集して実行