color quantization using kmeans+++ for clustering and CIEDE2000 algorithm for color distance
Branch: master
Clone or download
Latest commit 8f07efc Sep 17, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src lil bump Sep 14, 2018
.gitignore init Aug 31, 2018
.npmignore init Aug 31, 2018
README.md Update README.md Sep 17, 2018
package.json
webpack.config.js
yarn.lock

README.md

major-colors

Color segmentation using kmeans+++ for clustering and CIEDE2000 algorithm for color distance.

Color Palette Picker App/Demo - Attempt to generate the optimal color palette given an image

Blog Post

Client-only!

This implementation relies on the canvas api to process the image

Install

npm i major-colors
yarn add major-colors

Usage

import MajorColors from 'major-colors'

const majorColors = new MajorColors(imageDomNode);
const { clusterResult, colors } =
  majorColors.getMajorColors({ numberOfColors: 5, quality: .10});

Outputs

colors [[number]]

an array of arrays which represent the colors in RGB vector

clusterResult - raw cluster ouput from k-means-plus

type 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
}