MaskSLIC演示

此示例是关于比较使用普通SLIC方法获得的分割 1 和它的蒙版MaskSLIC 2.

MaskSLIC方法是SLIC方法的扩展,用于在感兴趣区域中生成超像素。MaskSLIC能够克服影响SLIC方法的边界问题,特别是在不规则掩模的情况下。

1

Radhakrishna Achanta,Appu Shaji,Kevin Smith,Aurelen Lucchi,Pascal Fua和Sabine Suesstrunk,SLIC超像素与最先进的超像素方法比较,TPAMI,2012年5月。 DOI:10.1109/TPAMI.2012.120

2

本杰明,欧文。《MaskSLIC:区域超像素生成及其在医学图像局部病理表征中的应用》,2016,, arXiv:1606.09518

Origin image, Mask, SLIC, maskSLIC
import matplotlib.pyplot as plt

from skimage import data
from skimage import color
from skimage import morphology
from skimage import segmentation

# Input data
img = data.immunohistochemistry()

# Compute a mask
lum = color.rgb2gray(img)
mask = morphology.remove_small_holes(
    morphology.remove_small_objects(
        lum < 0.7, 500),
    500)

mask = morphology.opening(mask, morphology.disk(3))

# SLIC result
slic = segmentation.slic(img, n_segments=200, start_label=1)

# maskSLIC result
m_slic = segmentation.slic(img, n_segments=100, mask=mask, start_label=1)

# Display result
fig, ax_arr = plt.subplots(2, 2, sharex=True, sharey=True, figsize=(10, 10))
ax1, ax2, ax3, ax4 = ax_arr.ravel()

ax1.imshow(img)
ax1.set_title("Origin image")

ax2.imshow(mask, cmap="gray")
ax2.set_title("Mask")

ax3.imshow(segmentation.mark_boundaries(img, slic))
ax3.contour(mask, colors='red', linewidths=1)
ax3.set_title("SLIC")

ax4.imshow(segmentation.mark_boundaries(img, m_slic))
ax4.contour(mask, colors='red', linewidths=1)
ax4.set_title("maskSLIC")

for ax in ax_arr.ravel():
    ax.set_axis_off()

plt.tight_layout()
plt.show()

脚本的总运行时间: (0分1.127秒)

Gallery generated by Sphinx-Gallery