quantize
A node.js module for color quantization, based on Leptonica.
Last updated 13 years ago by olivierlesnicki .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install quantize 
SYNC missed versions from official npm registry.

quantize

Node.js module for color quantization, based on Leptonica.

Install

npm install quantize

Quick Overview

###Usage

var quantize = require('quantize');

var arrayOfPixels = [[190,197,190], [202,204,200], [207,214,210], [211,214,211], [205,207,207]];
var maximumColorCount = 4;

var colorMap = quantize(arrayOfPixels, maximumColorCount);
  • arrayOfPixels - An array of pixels (represented as [R,G,B arrays]) to quantize
  • maxiumColorCount - The maximum number of colours allowed in the reduced palette

#####Reduced Palette

The .palette() method returns an array that contains the reduced color palette.

// Returns the reduced palette
colorMap.palette(); 
// [[204, 204, 204], [208,212,212], [188,196,188], [212,204,196]]

#####Reduced pixel

The .map(pixel) method maps an individual pixel to the reduced color palette.

// Returns the reduced pixel
colorMap.map(arrayOfPixels[0]);
// [188,196,188]

Author

Contributors

License

Licensed under the MIT License.

Current Tags

  • 1.0.2                                ...           latest (11 years ago)

3 Versions

  • 1.0.2                                ...           11 years ago
  • 1.0.1                                ...           13 years ago
  • 1.0.0                                ...           13 years ago
Maintainers (1)
Downloads
Total 8
Today 0
This Week 3
This Month 7
Last Day 1
Last Week 0
Last Month 1
Dependencies (0)
None
Dev Dependencies (0)
None
Dependents (2)

© 2010 - cnpmjs.org x YWFE | Home | YWFE