スーパー ピクセルセグメンテーション
この演習では、顔検出の Machine Learning モデルに渡す前に、同じ画像に対して教師なしセグメンテーションを適用します。
つまり、この画像を \(265 \times 191 = 50,615\) ピクセルから \(400\) の領域にまで削減します。
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")