エッジ検出
この演習では、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")