[matplotlib animation] 68. 隣接領域グラフ(RAG)によるmerge_hierarchicalのthresh変化アニメーション

matplotlib Animation

はじめに

matplotlibのFuncAnimationで画像の色が似ている領域を結合するskimage.feature graph merge_hierarchicalのパラメータであるtheshを変化させたときの画像の変化をアニメーションで表示する。

コード

解説

隣接領域グラフ(RAG)による色が似ている領域の結合

skimage.feature graph merge_hierarchicalによる隣接領域グラフ(RAG)を用いた色が似ている領域の結合については下記で説明した。

[scikit-image] 62. 隣接領域グラフ(RAG)による色が似ている領域の結合(skimage.feature graph merge_hierarchical)
skimage.feature graphのmerge_hierarchicalを用いて、隣接領域グラフ(RAG)を構築し、似ている色領域を結合する例について説明する。

アニメーションの設定

アニメーション以外のコードは上記記事と同じなので省略する。
ax.cla()でまず画像をクリアし、thresh=2*numとしたmerge_hierarchical画像を順次表示していく。
ax.set_title("thresh="+str(2*num))でタイトルに用いたthreshの値を表示する。

アニメーションの表示

HTML(ani.to_html5_video())により、jupyter notebook またはjupyter lab上にアニメーションを表示できる。

コードをダウンロード(.pyファイル)

コードをダウンロード(.ipynbファイル)

参考

[scikit-image] 62. 隣接領域グラフ(RAG)による色が似ている領域の結合(skimage.feature graph merge_hierarchical)
skimage.feature graphのmerge_hierarchicalを用いて、隣接領域グラフ(RAG)を構築し、似ている色領域を結合する例について説明する。
Page not found · GitHub Pages
https://matplotlib.org/api/_as_gen/matplotlib.animation.FuncAnimation.html

コメント