The few colours that stand for the many pixels of an image.
The pixels are a sequence of vectors of red, green, blue and alpha from 0 to 255, as image/pixels, a canvas or ImageIO gives them. Only the opaque ones count, with an alpha of 128 or more. Each function returns maps of a :colour and its :share of the opaque pixels, the largest share first.
The few colours that stand for the many pixels of an image. The pixels are a sequence of vectors of red, green, blue and alpha from 0 to 255, as image/pixels, a canvas or ImageIO gives them. Only the opaque ones count, with an alpha of 128 or more. Each function returns maps of a :colour and its :share of the opaque pixels, the largest share first.
(buckets pixels n)At most n colours of the pixels, each the mean of a bucket of those
that agree in the top three bits of each channel, the most common first.
It's fast and stable, but splits a cluster that straddles the edge of a
bucket, and counts in sRGB, which isn't perceptual.
At most `n` colours of the `pixels`, each the mean of a bucket of those that agree in the top three bits of each channel, the most common first. It's fast and stable, but splits a cluster that straddles the edge of a bucket, and counts in sRGB, which isn't perceptual.
(k-means pixels n)At most n colours of the pixels, by weighted k-means in Oklab over
cells of 5 bits a channel, from far-apart centres, the most common
first. Unlike buckets, it puts a colour where a cluster of pixels is.
At most `n` colours of the `pixels`, by weighted k-means in Oklab over cells of 5 bits a channel, from far-apart centres, the most common first. Unlike buckets, it puts a colour where a cluster of pixels is.
(opaque pixels)The pixels of pixels with an alpha of 128 or more.
The pixels of `pixels` with an alpha of 128 or more.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |