def contours_from_shape_discrete(left, right):
"""Convert the worm shape to contours
Arguments:
left, right (nx2 arrays): left and right side of the worm
Returns
nx2: contours of the worm
"""
poly = geom.Polygon(np.vstack([left, right[::-1,:]]));
poly = poly.buffer(0)
bdr = poly.boundary;
if isinstance(bdr, geom.multilinestring.MultiLineString):
cts = [];
for b in bdr:
x,y = b.xy;
cts.append(np.vstack([x,y]).T);
else: # no self intersections
x,y = bdr.xy;
cts = np.vstack([x,y]).T;
return tuple(cts)
评论列表
文章目录