This software converts a JPEG to GCode line segments for use on a drawbot, polargraph, or vplotter.
It is written in https://processing.org so its simple to change and tweak. The basic algorithm is as follows:
You can find more at http://www.dullbits.com/drawbot/drawbot