[PYTHON] SLIC Superpixel segmentation in scikit image

To calculate SLIC superpixels in python, we have two options:

I found that these provided completely different segmentation unless enforce_connectivity=True in skimage.segmentation.slic. Here I show a brief example describing how different they are, which we could not see at http://scikit-image.org/docs/dev/auto_examples/plot_segmentations.html

example.py



from skimage.segmentation import slic, mark_boundaries
from skimage.data import lena
import slic as slic_wrap # code available at https://github.com/amueller/slic-python
import matplotlib.pyplot as plt

img = lena()

plt.subplot(1,3,1)
plt.imshow(mark_boundaries(img, slic_wrap.slic_n(img, 40, 10)))
title('Original version')
plt.subplot(1,3,2)
plt.imshow(mark_boundaries(img, slic(img, 40, 10, sigma=1, enforce_connectivity=False)))
title('skimage version\n enforce_connectivity=False', size=9)
plt.subplot(1,3,3)
plt.imshow(mark_boundaries(img, slic(img, 40, 10, sigma=1, enforce_connectivity=True)))
title('skimage version\n  enforce_connectivity=True', size=9)

Here I tried to tune the parameter sigma in skimage version to obtain a similar output to the original version. Obviously, enforce_connectivity option is essential to avoid color-sensitive segments.

Screen Shot 2014-07-08 at 9.56.51.png

Recommended Posts

SLIC Superpixel segmentation in scikit image
Implemented image segmentation in python (Union-Find)
Image format in Python
Image segmentation using U-net
Image uploader in Flask
Image normalization in TensorFlow
Tweet with image in Python
Image Processing Collection in Python
Image addition memo in reportlab