Skip to content

Instantly share code, notes, and snippets.

@odebeir
Created July 11, 2014 14:07
Show Gist options
  • Save odebeir/2efd02b1c357ede5aee3 to your computer and use it in GitHub Desktop.
Save odebeir/2efd02b1c357ede5aee3 to your computer and use it in GitHub Desktop.
import matplotlib.pyplot as plt
from skimage.morphology import watershed,disk
from skimage.filter import rank
from skimage import data
import numpy as np
image = data.camera()
gradient = rank.gradient(image, disk(2))
markers = np.zeros(image.shape)
markers[100,150] = 1
markers[200,200] = 2
markers[240,200] = 3
labels = watershed(gradient, markers)
plt.imshow(labels, cmap=plt.cm.spectral, interpolation='nearest')
plt.imshow(markers, interpolation='nearest',alpha = .6)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment