https://github.com/goldensunliu/major-colors
color quantization using kmeans+++ for clustering and CIEDE2000 algorithm for color distance
https://github.com/goldensunliu/major-colors
ciede2000 color color-palette kmeans kmeans-clustering
Last synced: 4 months ago
JSON representation
color quantization using kmeans+++ for clustering and CIEDE2000 algorithm for color distance
- Host: GitHub
- URL: https://github.com/goldensunliu/major-colors
- Owner: goldensunliu
- Created: 2018-08-31T16:59:15.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-07-11T18:18:17.000Z (over 2 years ago)
- Last Synced: 2025-04-08T19:46:14.701Z (7 months ago)
- Topics: ciede2000, color, color-palette, kmeans, kmeans-clustering
- Language: JavaScript
- Homepage:
- Size: 553 KB
- Stars: 10
- Watchers: 1
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# major-colors
Color segmentation using kmeans+++ for clustering and CIEDE2000 algorithm for color distance.[Color Palette Picker App/Demo](https://out-bqkxoqnwce.now.sh) - Attempt to generate the optimal color palette given an image
[Blog Post](https://medium.com/@sitianliu_57680/how-to-pick-the-optimal-color-palette-from-any-image-ef1342da8b4f)
## Client-only!
This implementation relies on the canvas api to process the image### Install
```
npm i major-colors
yarn add major-colors
```
### Usage
```javascript
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](https://github.com/goldensunliu/k-means-plus#outputs)
```flow js
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
}
```