Pure Go implementation of Potrace vectorization library. Supports simple SVG output generation.
Original image
Vectorized image
go get github.com/dennwc/gotrace
Process image, generate SVG:
paths, _ := gotrace.Trace(img, nil)
gotrace.WriteSvg(file, img.Bounds(), paths, "")
Custom threshold function:
params := gotrace.Defaults()
params.ThresholdFunc = func(c color.Color) bool {
r,g,b,_ := c.RGBA()
return r+g+b > 128
}
paths, _ := gotrace.Trace(img, params)