Does there exist an algorithm that can analyze an array of pixel coordinates, and return an array of line coordinates that, when drawn using Bresenham's algorithm, would generate lines that cover the same pixels as the original array?
One use case is to optimize hand-drawn pixel art so it can be stored as lines rather than individual pixels.
Update: Here's a more concrete example: Say someone has drawn something by hand with a pencil tool, like a signature.
The red pixels are all stored in a single array. So, for example it might begin:
[ [27,31],[26,31],[25,30],[24,30],[23,29],[22,29],[21,28],[20,27],[19,26],[18,25],[18,24],[18,23],[18,22],[18,21],[18,20],[18,19],[18,18],[18,17],[18,16],[18,15],[18,14],[18,13] ... ]
Is there an algorithm that could iterate through this array of individual pixels and return an array of line coordinates? In my example, it would take the pixels I gave above and return the following line coordinates:
[ [[27,31],[22,29]], [[22,29],[18,25]], [[18,25],[18,13]] ... ]