Image Quantization Library in TypeScript (MIT License)

Image Color Number Reduction with alpha support using RgbQuant/NeuQuant/Xiaolin Wu's algorithms and Euclidean/Manhattan/CIEDE2000 color distance formulas in TypeScript
| title | description |
|---|---|
| Import | HTMLImageElement, HTMLCanvasElement, NodeCanvas, ImageData, Array, CanvasPixelArray, Uint8Array, Uint32Array |
| Palette | NeuQuant, RgbQuant, Xiaolin Wu's method |
| Image | Nearest Color, Error Diffusion Dithering |
| Export | Uint32Array, Uint8Array |
/// <reference path='<path-to-iq>/src/iq.ts' />
var iq = require("<path-to-iq>/dist/node-iq.js");
<script src="<path-to-iq>/dist/browser-iq.js" type="text/javascript" charset="utf-8"></script>
var img = document.createElement("img");
img.onload = function() {
// image is loaded, here should be all code utilizing image
...
}
img.src = "http://pixabay.com/static/uploads/photo/2012/04/11/11/32/letter-a-27580_640.png"
// desired colors number
var targetColors = 256;
// create pointContainer and fill it with image
var pointContainer = IQ.Utils.PointContainer.fromHTMLImageElement(img);
// create chosen distance calculator (see classes implementing `IQ.Distance.IDistanceCalculator`)
var distanceCalculator = new IQ.Distance.Euclidean();
// create chosen palette quantizer (see classes implementing `IQ.Palette.IPaletteQuantizer`)
var paletteQuantizer = new IQ.Palette.RgbQuant(distanceCalculator, targetColors);
// feed out pointContainer filled with image to paletteQuantizer
paletteQuantizer.sample(pointContainer);
... (you may sample more than one image to create mutual palette)
// take generated palette
var palette = paletteQuantizer.quantize();
// create image quantizer (see classes implementing `IQ.Image.IImageDitherer`)
var imageDitherer = new IQ.Image.NearestColor(distanceCalculator);
// apply palette to image
var resultPointContainer = imageQuantizer.quantize(pointContainer, palette);
You may work with resultPointContainer directly or you may convert it to Uint8Array/Uint32Array
var uint8array = resultPointContainer.toUint8Array();
1. notification about progress
~~2. riemersma dithering~~
3. ordered dithering
+ Refactoring
+ Riemersma dithering added (Hilbert Curve)
+ Readme.md updated
+ build.cmd updated
+ NeuQuant is fixed (again) according to original Anthony Dekker source code (all values should be integer)
+ Error Diffusion Dithering is now calculates error like XNVIEW
+ Refactoring
+ Documentation generation fixed
+ File name case problem fixed
+ Auto-generated documentation added
+ Refactoring
+ Code cleanup, removed unnecessary files
+ PNGQUANT color distance added, need to check its quality
+ CIEDE2000 and CIE94 fixed for use in NeuQuant
+ NeuQuant is fixed according to original Anthony Dekker source code (all values should be integer)
+ Code refactoring and cleanup
* We have some slowdown because of red/green/blue/alpha normalization according to white point per each calculateRaw/calculateNormalized call
+ CIEDE2000 color distance equation optimized (original CIEDE2000 equation is available as class `CIEDE2000_Original`)
+ CMETRIC color distance fixed
+ Cleanup
+ Draft of CMETRIC color distance added
+ rgb2xyz & xyz2lab fixed. CIEDE2000 works much better now.
+ CIE94 distance formula added. More investigation is needed.
+ Initial
License MIT (NeuQuant use also forces to add it's copyright notice into source code)
Thanks to Leon Sorokin for information share and his original RgbQuant!
Palette Quantization Algorithms
JavaScriptTypeScriptJavaScriptJavaScriptCC C#C#GPLv3Image Quantization Algorithms
Color Distance Formulas
DRAFT!Color conversion formulas
Be sure to fix rgb2xyz/xyz2lab. Issue is with strange part of code:
r = r > 0.04045 ? .... Check http://en.wikipedia.org/wiki/Lab_color_space
Image Quality Assessment
Java License: MITOther
Generated using TypeDoc