0.0.12 • Published 3 years ago
autoseg v0.0.12
autoseg | Automatic Fast WebAssembly Image Segmentation
autoseg segments images from a list of points and polygons containing classifications. Autoseg was originally created by Severin Ibarluzea for usage with the Universal Data Tool.
Features
- Simple API
- WebWorker background computation
- Deterministic, suitable for mask compression
- Fast. WebAssembly compiled from state of the art C++ implementations of SLIC superpixeling and graph cut
- Fully compliant with the Universal Data Tool and UDT Format
Example Inputs -> Output
Input Image
Input Polygon
Output Mask
API
const autoseg = require("autoseg") // OR require("autoseg/node")
await autoseg.loadImage({ data: imData, width: 320, height: 249 })
// Points/polygons are in the UDT Shape format
// https://github.com/UniversalDataTool/udt-format
const maskImageData = await autoseg.getMask([
{ regionType: "point", x: 50, y: 50, cls: 0 },
{ regionType: "point", x: 150, y: 150, cls: 1 },
])
// If you have a canvas, you can draw the image of the mask
canvasContext.putImageData(maskImageData, 0, 0)
// NOTE: nodejs doesn't have builtin support for ImageData, but you
// can use the returned data in a similar way, it's an object with
// { data: Uint8ClampedArray, width: number, height: number }
Configuring
await autoseg.setConfig({
maxClusters: 1000,
classNames: ["dog", "cat"],
classColors: [0xffffffff, 0xff000000],
})