def onselect(vertices): path = Path( vertices, closed = True) # fraction of a pixel difference below which vertices will be simplified out path.simplify_threshold = 1.0 path.should_simplify = True # path.contains_points(points = ) vertfilename = "maskselection.npz" savez_dict = dict(vertices = vertices) np.savez_compressed(vertfilename, **savez_dict)
# <codecell> import matplotlib.path as mpath from matplotlib.path import Path vertfilename = "maskselection.npz" data = np.load(vertfilename) verts = data['vertices'] path = Path(verts, closed = True) print len(path) path.should_simplify = True path.simplify_threshold = 10.0 # <codecell> vertices = [] codes = [] for (vertex, code) in path.iter_segments(simplify = True): vertices.append(vertex.tolist()) codes.append(code) # <codecell> cleanpath = Path(vertices, codes) len(cleanpath)