major-colors
Color segmentation using kmeans+++ for clustering and CIEDE2000 algorithm for color distance. Attempt to generate the optimal color palette given an image
Client-only!
This implementation relies on the canvas api to process the image
Install
npm i major-colors
yarn add major-colors
Usage
const majorColors = imageDomNode;const clusterResult colors = majorColors;
Outputs
[[number]]
colors an array of arrays which represent the colors in RGB vector
k-means-plus
clusterResult - raw cluster ouput fromtype result = { model: { observations: [[number]], // the original vectors: colors in Lab space centroids: [[number]], // vectors of final cluster centers: colors in Lab space assignments: [number] // mapping from index of original vector to the index of cluter center it belongs to }, iterations: number, // number of iterations ran before converging durationMs: number // the duration of the algorithm}