How can I draw lines into numpy arrays?

前端 未结 4 1119
抹茶落季
抹茶落季 2020-12-10 11:51

I would like to be able to draw lines into numpy arrays to get off-line features for on-line handwriting recognition. This means I don\'t need the image at all, but I need f

4条回答
  •  感情败类
    2020-12-10 12:02

    Thanks to Joe Kington for the answer! I was looking for skimage.draw.line_aa.

    import scipy.misc
    import numpy as np
    from skimage.draw import line_aa
    img = np.zeros((10, 10), dtype=np.uint8)
    rr, cc, val = line_aa(1, 1, 8, 4)
    img[rr, cc] = val * 255
    scipy.misc.imsave("out.png", img)
    

提交回复
热议问题