UNPKG

@thi.ng/pixel-dominant-colors

Version:

k-means based dominant color extraction from images/pixel buffers

35 lines 1.02 kB
import type { Fn2 } from "@thi.ng/api"; import type { ReadonlyVec } from "@thi.ng/vectors"; /** * Options for {@link dominantColors}, an extension of * [KMeansOpts](https://docs.thi.ng/umbrella/k-means/interfaces/KMeansOpts.html). */ export interface DominantColorOpts { /** * Predicate used to only include pixels in the analysis for which the * filter returns truthy result. E.g. to pre-exclude weakly saturated or * dark colors etc. The second arg is the index of the pixel in the image's * pixel buffer. * * If omitted, all pixels will be included (default). */ filter: Fn2<ReadonlyVec, number, boolean>; } /** * Result type for dominant color extraction functions */ export interface DominantColor { /** * RGB tuple */ color: number[]; /** * Normalized area (based on number of samples) */ area: number; /** * Sample IDs (indices) belonging to this cluster. */ items?: number[]; } //# sourceMappingURL=api.d.ts.map