@federicobond/quantize
v1.5.0
Published
A node.js module for color quantization, based on Leptonica.
Readme
quantize
Node.js module for color quantization, based on Leptonica.
Install
npm install @federicobond/quantizeQuick Overview
Usage
import quantize from '@federicobond/quantize';
const arrayOfPixels = [[190, 197, 190], [202, 204, 200], [207, 214, 210], [211, 214, 211], [205, 207, 207]];
const maximumColorCount = 4;
const colorMap = quantize(arrayOfPixels, maximumColorCount);arrayOfPixels- An array of pixels (represented as [R, G, B] arrays) to quantizemaximumColorCount- The maximum number of colors 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.
