scikit に実装されているスーパーピクセルを試してみる
【関連する外部ページ】
スーパーピクセルに関する参考記事: http://scikit-image.org/docs/dev/auto_examples/segmentation/plot_segmentations.html
元画像
SLIC
felzenszwalb
quickshift
watershed
Windows での Python 3.10,関連パッケージ,Python 開発環境のインストール: 別ページ »で説明
【サイト内の関連ページ】
Python のまとめ: 別ページ »にまとめ
【関連する外部ページ】
Python の公式ページ: https://www.python.org/
コマンドプロンプトを管理者として実行: 別ページ »で説明
python -m pip install -U scikit-image matplotlib
SLIC を行う Python プログラムを実行してみる.
%matplotlib inline import matplotlib.pyplot as plt import warnings warnings.filterwarnings('ignore') # Suppress Matplotlib warnings 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_std.jpg") ) plt.imshow(img) a = skimage.segmentation.slic(img) plt.imshow( a ) plt.imshow( skimage.segmentation.mark_boundaries(img, a) )
felzenszwalb を行う.
Python プログラムを実行する.Matplotlib を使うので,Jupyter QtConsole や Jupyter ノートブック (Jupyter Notebook) の利用が便利である.
%matplotlib inline import matplotlib.pyplot as plt import warnings warnings.filterwarnings('ignore') # Suppress Matplotlib warnings 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_std.jpg") ) plt.imshow(img) a = skimage.segmentation.felzenszwalb(img) plt.imshow( a ) plt.imshow( skimage.segmentation.mark_boundaries(img, a) )
quickshift を行う.
Python プログラムを実行する.Matplotlib を使うので,Jupyter QtConsole や Jupyter ノートブック (Jupyter Notebook) の利用が便利である.
%matplotlib inline import matplotlib.pyplot as plt import warnings warnings.filterwarnings('ignore') # Suppress Matplotlib warnings 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_std.jpg") ) plt.imshow(img) a = skimage.segmentation.quickshift(img) plt.imshow( a ) plt.imshow( skimage.segmentation.mark_boundaries(img, a) )
watershed を行う.
Python プログラムを実行する.Matplotlib を使うので,Jupyter QtConsole や Jupyter ノートブック (Jupyter Notebook) の利用が便利である.
%matplotlib inline import matplotlib.pyplot as plt import warnings warnings.filterwarnings('ignore') # Suppress Matplotlib warnings 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_std.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) )