I recently published img2plot, a Python script that generates artistic pen-plotter sketches from arbitrary images.
A lot of plotter projects have code for drawing images. Usually they do something with line density and pixel intensities – a semi-random stippling or wave pattern, for example, with smoothly higher density for darker pixels. These can very faithfully represent the image, but they don’t look very human-made. Another approach is to find and draw Canny or other edge-detector results – which do faithfully represent edges, but again, don’t look very human.
With img2plot, I wanted to try to mimic what a human might do – which is draw lines on edges or perpendicular to gradients.
The approach is relatively straightforward:
This will progressively draw over the “strongest edges” in the image, until a user-specified termination point is reached.
From a computer-vision edge detection perspective, this is awful at marking edges – the lines will frequently miss real edges, especially if they curve, or are wide / nearby each other. However, this lends itself well to the output’s artistic appearance:
I’ve found this works well on video game screenshots – especially objects with low polygon count and relatively simple textures, which makes sense given the basis is straight lines. It makes it great for making wall art around the house with a pen plotter.
The code can be found on Github and requires relatively few dependencies – OpenCV’s Python bindings are not required here, though I might later port this algorithm to C++/OpenCV for speed.
I’m not quite finished with developing this – I’ve been experimenting with simple Bezier curves, since humans generally don’t draw perfectly straight lines. I’ll update once I’m satisfied with how that looks.