def polyline2coords(points):
"""
Return row and column coordinates for a polyline.
>>> rr, cc = polyline2coords([(0, 0), (2, 2), (2, 4)])
>>> list(rr)
[0, 1, 2, 2, 3, 4]
>>> list(cc)
[0, 1, 2, 2, 2, 2]
:param list of tuple points: Polyline in format [(x1,y1), (x2,y2), ...]
:return: tuple with row and column coordinates in numpy arrays
:rtype: tuple of numpy array
"""
coords = []
for i in range(len(points) - 1):
xy = list(map(int, points[i] + points[i + 1]))
coords.append(skd.line(xy[1], xy[0], xy[3], xy[2]))
return [np.hstack(c) for c in zip(*coords)]
评论列表
文章目录