はじめに
ここではsobelなどで検出したエッジ画像のしきい値処理をskimage.filtersのapply_hysteresis_thresholdでやる方法について説明する。
コード

解説
モジュールのインポート
画像データの読み込み
下のロフォフォラの画像を読み込み、rgb2grayにより、グレースケール化する。

Sobel法によるエッジの検出
詳細は下記で解説した。

[scikit-image] 16. エッジ演算子(filters.roberts, sobel)
skimage.filters の roberts, sobelを用いた画像のエッジ検出について説明する。
しきい値処理
sobelで検出したedgeをヒストグラムとすると、下記のようになる。

lowt, hightではそれぞれ0.05, 0.25以上で2値化した画像となっている。astype(int)でbool値を0か1に変換している。
hystはfilters.apply_hysteresis_threshold(edges, low, high)により、ヒステリシスしきい値処理された画像で、低いしきい値(0.05)を超える領域が、高いしきい値(0.25)を超える領域に隣接している場合にしきい値を超えていると見なされる。
そのため、ロフォフォラの棘座(緑色の物体に点在する白い点)はlowtでは確認できるが、hystでは消失していることがわかる。
画像の表示
Imagegridにより、cmapを’cividis’で表示した。

[matplotlib] 19. mpl_toolkits.axes_grid1 の使い方(画像の表示)
axes_grid1のImageGridを用いて複数の画像を表示する方法
参考
Hysteresis thresholding — skimage 0.25.1 documentation
skimage.filters — skimage 0.25.2rc1.dev0 documentation
skimage.filters — skimage 0.25.2rc1.dev0 documentation
コメント