[Python] How can I draw lines into numpy arrays?

Discussão em 'Python' iniciado por Stack, Agosto 5, 2025.

  1. Stack

    Stack Membro Participativo

    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 for some positions in a numpy array who an image of a given size would look like.

    I would like to be able to specify an image size and then draw strokes like this:

    import module
    im = module.new_image(width=800, height=200)
    im.add_stroke(from={'x': 123, 'y': 2}, to={'x': 42, 'y': 3})
    im.add_stroke(from={'x': 4, 'y': 3}, to={'x': 2, 'y': 1})
    features = im.get(x_min=12, x_max=15, y_min=0, y_max=111)


    Is something simple like that possible (preferably directly with numpy / scipy)?

    (Please note that I want grey-scale interpolation. So features should be a matrix of values in [0, 255].)

    Continue reading...

Compartilhe esta Página