# `Linocut.Quantise`
[🔗](https://github.com/jaman/cauldron/blob/v0.2.2/linocut/lib/linocut/quantise.ex#L1)

A picture reduced to a small palette.

    {reduced, palette} = Linocut.Quantise.reduce(raster, 16)

The palette is chosen by median cut over the picture's opaque pixels and every pixel is
then moved to its nearest entry. A pixel whose alpha is under the threshold stays clear
and takes no palette entry.

# `colour`

```elixir
@type colour() :: {0..255, 0..255, 0..255}
```

# `nearest`

```elixir
@spec nearest([colour()], colour()) :: colour()
```

The entry of `palette` closest to `colour`.

# `palette`

```elixir
@spec palette(FrenchCurve.Raster.t(), pos_integer(), keyword()) :: [colour()]
```

At most `count` colours chosen from `raster`'s opaque pixels, darkest first.

## Options

  * `:alpha` — the alpha at or above which a pixel counts as opaque. Default `128`

# `reduce`

```elixir
@spec reduce(FrenchCurve.Raster.t(), pos_integer(), keyword()) ::
  {FrenchCurve.Raster.t(), [colour()]}
```

`raster` with at most `count` colours, and the palette it was given.

## Options

  * `:alpha` — the alpha at or above which a pixel counts as opaque. Default `128`

# `to_palette`

```elixir
@spec to_palette(FrenchCurve.Raster.t(), [colour()], keyword()) ::
  FrenchCurve.Raster.t()
```

`raster` with every opaque pixel moved to its nearest entry in `palette`.

## Options

  * `:alpha` — the alpha at or above which a pixel counts as opaque. Default `128`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
