Skip to content

Super-Pixels using SLIC (Simple Linear Iterative Clustering)

Notifications You must be signed in to change notification settings

marawangamal/slic-image-segmentation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Project Description

Segmentation using SLIC to obtain super-pixels, VGG16-FCN to obtain a pixel-wise prediction and Loopy Belief Propagation to perform inference in a Conditional Random Field that encourages smoothness in labelling.

SLIC - Simple Linear Iterative Clustering python implementation to obtain Super-Pixels. Paper: http://www.kev-smith.com/papers/SLIC_Superpixels.pdf (A K-Means implementation is also available as SLIC class inherits from KMeans).

Loopy Belief Propagation - Inference algorithm to find optimal labelling in a factor graph.

Example output

Parameters: m = 20, K =100

Paris

Code Description

  • slic.py
    • Contains SLIC and K-Means algorithms
  • max_sum.py
    • Contains graph building routine and max-sum algorithm

Usage

SLIC

from slic import *

# 1. Instatiate SLIC object 
sl = SLIC()

# 2. Obtain cluster centers and assignments as an integer mask
mus, sets, = sl.run(img_CIElab, k=100, iters=5)

# 3. Obtain a colour mask (i.e. each pixel is given the colour cluster center it's assigned to)
clr_mask = sl.get_color_mask(mus, sets) 

# 4. Plot
plt.imshow(clr_mask); plt.show()

K-Means

from slic import *


# SLIC EXAMPLE

# 1. Instatiate SLIC object 
 km = KMeans()

# 2. Obtain cluster centers and assignments as an integer mask
mus, sets = km.run(img, k=10)

# 3. Plot
plt.imshow(sets[:,:,0]); plt.show()

About

Super-Pixels using SLIC (Simple Linear Iterative Clustering)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages