imageutil.py 文件源码

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

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


问题


面经


文章

微信
公众号

扫码关注公众号