scikit に実装されているスーパーピクセルを試してみる
スーパーピクセルに関する参考記事: http://scikit-image.org/docs/dev/auto_examples/segmentation/plot_segmentations.html
先人に感謝.
元画像
SLIC
felzenszwalb
quickshift
watershed
上に実行結果例を示しているが,パラメータの調整により結果が変わりますので,上の図だけで,どれが良いと結論を出さないようにしてください.
キーワード:superpixel, SLIC, felzenszwalb, quickshift, watershed, scikit-image, Python
Python の URL: http://www.python.org/
インストール手順の詳細は: 別ページで説明している.
コマンドプロンプトを管理者として実行し,次のコマンドを実行.
python -m pip install -U pip setuptools python -m pip install -U jupyterlab jupyter jupyter-console jupytext nteract_on_jupyter spyder
システム Python を使用(インストール操作は不要)
端末で,次のコマンドを実行.
sudo apt -y install python3-dev python3-pip python3-setuptools sudo pip3 uninstall ptyprocess sniffio terminado tornado jupyterlab jupyter jupyter-console jupytext nteract_on_jupyter spyder sudo apt -y install jupyter jupyter-qtconsole spyder3 sudo apt -y install python3-ptyprocess python3-sniffio python3-terminado python3-tornado sudo pip3 install jupyterlab nteract_on_jupyter
python -m pip install -U scikit-image matplotlib
SLIC を行う Python プログラムを実行してみる.
jupyter qtconsole
Python プログラムを動かして,結果を見たい.
Jupyter Qt Console, spyder, PyCharm, PyScripter が便利である. Windows では,スタートメニューの「IDLE (Python ...)」も便利である.
※ 「jupyter qtconsole」を入れたのに,jupyter qtconsole が起動しない という場合には,次の操作で,インストールを行ってから,もう一度試してみる.
※ Windows では「python」,Ubuntu では「sudo python3 -m pip」
python -m pip install -U jupyterlab jupyter jupyter-console jupytext spyder
import matplotlib.pyplot as plt import skimage.data import skimage.color import skimage.filters import skimage.util import skimage.segmentation img = skimage.util.img_as_float( plt.imread("d:\lena.jpg") ) plt.imshow(img) a = skimage.segmentation.slic(img) plt.imshow( a ) plt.imshow( skimage.segmentation.mark_boundaries(img, a) )
felzenszwalb を行う Python プログラムを実行してみる.
import matplotlib.pyplot as plt import skimage.data import skimage.color import skimage.filters import skimage.util import skimage.segmentation img = skimage.util.img_as_float( plt.imread("d:\lena.jpg") ) plt.imshow(img) a = skimage.segmentation.felzenszwalb(img) plt.imshow( a ) plt.imshow( skimage.segmentation.mark_boundaries(img, a) )
quickshift を行う Python プログラムを実行してみる.
import matplotlib.pyplot as plt import skimage.data import skimage.color import skimage.filters import skimage.util import skimage.segmentation img = skimage.util.img_as_float( plt.imread("d:\lena.jpg") ) plt.imshow(img) a = skimage.segmentation.quickshift(img) plt.imshow( a ) plt.imshow( skimage.segmentation.mark_boundaries(img, a) )
watershed を行う Python プログラムを実行してみる.
import matplotlib.pyplot as plt import skimage.data import skimage.color import skimage.filters import skimage.util import skimage.segmentation img = skimage.util.img_as_float( plt.imread("d:\lena.jpg") ) plt.imshow(img) a = skimage.segmentation.watershed( skimage.filters.sobel( skimage.color.rgb2gray( img ) ), markers=250 ) plt.imshow( a ) plt.imshow( skimage.segmentation.mark_boundaries(img, a) )
本サイトは金子邦彦研究室のWebページです.サイトマップは,サイトマップのページをご覧下さい. 本サイト内の検索は,サイト内検索のページをご利用下さい.
問い合わせ先: 金子邦彦(かねこ くにひこ)