はじめに
Seaborn-imageはmatplotlibベースの画像可視化ライブラリであり、簡潔なコードで画像データを明瞭に描写することができる。データ可視化ライブラリであるseabornの2次元データ版のような感じとなっている。ここでは、各種フィルタのパラメータを変化させた結果をまとめて表示できるParamGrid
について説明する。
seaborn-image: image data visualization — seaborn-image documentation
コード&解説
インストール
condaの方は
conda install -c conda-forge seaborn-image
pipの方は
pip install -U seaborn-image
でインストールできる。
モジュールのインポート
seaborn_image は isnsとして読み込む。
バージョン
全体の設定
isns.set_imageで、デフォルトのカラーマップをcmap=”viridis”とし、画像の原点の設定をupperにする。
データの読み込み
サボテンのすみれ丸の画像を読み込む。以下の画像を用いた。rgb2grayでグレースケール画像としておく。

グレースケール画像をisnsのimgplot
で表示すると以下のようになる。

ParamGrid ガウシアンフィルタ
ParamGridでcol=”sigma”, sigma=[2,3,4,5]とすることで、sigmaを2-5まで変化させた結果をまとめて表示可能となっている。col_wrap=2とすることで2列で表示できる。

uniformフィルタ
平均フィルタのsizeを変化させた場合も、ガウシアンフィルタと同様にできる。

diff_of_gaussians
diff_of_gaussians(バンドパスフィルタ)の場合、colに”low_sigma”rowに”high_sigma”を設定し、low_sigma、high_sigmaでそれぞれの値をリスト形式で指定することで、結果をまとめて表示できる。

percentile
percentileフィルタの場合、percentileとsizeを変化させてParamGridを行うと以下のようになる。

参考
seaborn_image.ParamGrid — seaborn-image documentation
コメント