Skip to content

Instantly share code, notes, and snippets.

@valentina-s
Created October 20, 2016 18:01
Show Gist options
  • Save valentina-s/87922dfef4fd9f87d3ea99297312ca8b to your computer and use it in GitHub Desktop.
Save valentina-s/87922dfef4fd9f87d3ea99297312ca8b to your computer and use it in GitHub Desktop.
import numpy as np
import matplotlib.pyplot as plt
im = plt.imread('cells.png')
fig = plt.figure()
ax = fig.add_subplot(111)
# ax.add_image(im)
plt.imshow(im)
coords = []
import cell_magic_wand
def onclick(event):
global ix, iy
ix, iy = event.xdata, event.ydata
print 'x = %d, y = %d'%(
ix, iy)
mask = cell_magic_wand.cell_magic_wand_single_point(im,(ix,iy),5,200,roughness=5)[0]
plt.contour(mask)
print(mask)
cid = fig.canvas.mpl_connect('button_press_event', onclick)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment