# autoseg

Latest version **0.0.12** (published 2020-11-28) · LGPL license · 0 weekly downloads

## Install

```sh
npm install autoseg
pnpm add autoseg
yarn add autoseg
bun add autoseg
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.12 |
| Published | 2020-11-28 |
| First published | 2020-07-27 |
| Weekly downloads | 0 |
| License | LGPL |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 892.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | seveibar |
| Maintainers | seveibar |

## Links

- npm: https://www.npmjs.com/package/autoseg
- Repository: https://github.com/UniversalDataTool/autoseg
- Homepage: https://github.com/UniversalDataTool/autoseg#readme
- Issues: https://github.com/UniversalDataTool/autoseg/issues
- npm.io page: https://npm.io/package/autoseg

## Recent versions

- 0.0.12 (latest) — 2020-11-28
- 0.0.11 — 2020-08-27
- 0.0.10 — 2020-08-05
- 0.0.9 — 2020-08-05
- 0.0.8 — 2020-07-27
- 0.0.7 — 2020-07-27
- 0.0.6 — 2020-07-27
- 0.0.5 — 2020-07-27
- 0.0.4 — 2020-07-27
- 0.0.3 — 2020-07-27

## README

# autoseg | Automatic Fast WebAssembly Image Segmentation

> Are you looking to convert UDT annotations into png masks? Use [udt-to-png](https://github.com/UniversalDataTool/udt-to-png)

autoseg segments images from a list of points and polygons containing
classifications. Autoseg was originally created by [Severin Ibarluzea](https://twitter.com/seveibar) for usage with the [Universal Data Tool](https://github.com/UniversalDataTool/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](https://github.com/UniversalDataTool/universal-data-tool) and [UDT Format](https://github.com/UniversalDataTool/udt-format)

## Example Inputs -> Output

### Input Image

![Input Image](https://user-images.githubusercontent.com/1910070/88559148-75011400-cffa-11ea-912e-e4d53a64dc8d.png)

### Input Polygon

![Input Image Polygon](https://user-images.githubusercontent.com/1910070/88559149-7599aa80-cffa-11ea-9d7b-34f4190750f8.png)

### Output Mask

![Output Mask](https://user-images.githubusercontent.com/1910070/88559147-75011400-cffa-11ea-9ac7-d99e7bc77646.png)

## CLI

Make sure to format your file in the [\*.udt.json format](https://github.com/UniversalDataTool/udt-format).

```bash
npm install -g autoseg

# This will output a bunch of image pngs for the masks of a udt file
autoseg some_file.udt.json -o output-directory


autoseg --help

# Usage: autoseg path/to/dataset.udt.json -o output-masks-dir
#
# Options:
#   --help               Show help                                       [boolean]
#   --version            Show version number                             [boolean]
#   --use-sample-number  Use the number of the sample as the mask filename
#                       (mask0001.png, etc.)
#   --output-dir, -o     Output directory for masks                     [required]
```

## API

```javascript
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

```javascript
await autoseg.setConfig({
  maxClusters: 1000,
  classNames: ["dog", "cat"],
  classColors: [0xffffffff, 0xff000000],
})
```

---
_Source: https://npm.io/package/autoseg · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
