geometry.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:CElegansBehaviour 作者: ChristophKirst 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号