img2vec: A simple vectorizer for images

  2015-04-01


Back in 2009 I wrote a little flood filling, edge hashing vectorizer in Java which took raster images (PNGs, JPEGs, GIFs) as inputs and produced SVG files as outputs.
The algorithm itself became part of a larger project dealing with vectorizing geographic raster data and 2d slices of 3d datasets produced by scientific calculations.

The prototype itself never made it to sunshine as it only was just a proof of concept. A few years later during a acquisition of a project that wasn’t realized later on I wrote a Python variant of the core algorithm. It only dealt with some very special hydrological time/space discrete datasets so it was not of broader use. As a consequence it was set to rot on my disk.

Fast forward to present. Currently working with a 3d dataset (maybe later more about this on this blog) I’ve run into vectorizing rasters in a similar way. To study my own work I’ve decided to re-implement my old Java prototype in Go and release it as Free Software (MIT license). You can find the sources here.

Lenna quantized to eight colors

Click here to get the generated SVG from this source.