Socket
Socket
Sign inDemoInstall

major-colors

Package Overview
Dependencies
2
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    major-colors

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


Version published
Weekly downloads
2
Maintainers
1
Install size
353 kB
Created
Weekly downloads
 

Readme

Source

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

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
}

FAQs

Last updated on 14 Sep 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc