Comparing version
@@ -19,3 +19,2 @@ /** | ||
})(Y || (Y = {})); | ||
// tslint:disable-next-line:naming-convention | ||
export var x; | ||
@@ -28,3 +27,2 @@ (function (x) { | ||
})(x || (x = {})); | ||
// tslint:disable-next-line:naming-convention | ||
export var y; | ||
@@ -31,0 +29,0 @@ (function (y) { |
@@ -10,3 +10,2 @@ /** | ||
import { xyz2rgb } from './xyz2rgb'; | ||
// tslint:disable-next-line:naming-convention | ||
export function lab2rgb(L, a, b) { | ||
@@ -13,0 +12,0 @@ const xyz = lab2xyz(L, a, b); |
@@ -14,3 +14,2 @@ /** | ||
} | ||
// tslint:disable-next-line:naming-convention | ||
export function lab2xyz(L, a, b) { | ||
@@ -17,0 +16,0 @@ const y = (L + 16) / 116; |
@@ -16,11 +16,2 @@ /** | ||
export class AbstractCIE94 extends AbstractDistanceCalculator { | ||
/** | ||
* Weight in distance: 0.25 | ||
* Max DeltaE: 100 | ||
* Max DeltaA: 255 | ||
*/ | ||
_kA; | ||
_Kl; // tslint:disable-line:naming-convention | ||
_K1; // tslint:disable-line:naming-convention | ||
_K2; // tslint:disable-line:naming-convention | ||
calculateRaw(r1, g1, b1, a1, r2, g2, b2, a2) { | ||
@@ -27,0 +18,0 @@ const lab1 = rgb2lab(inRange0to255(r1 * this._whitePoint.r), inRange0to255(g1 * this._whitePoint.g), inRange0to255(b1 * this._whitePoint.b)); |
@@ -11,4 +11,2 @@ /** | ||
import { degrees2radians, inRange0to255 } from '../utils/arithmetic'; | ||
// tslint:disable:variable-name | ||
// tslint:disable:naming-convention | ||
/** | ||
@@ -25,3 +23,3 @@ * CIEDE2000 algorithm - Adapted from Sharma et al's MATLAB implementation at | ||
static _kA = (0.25 * 100) / 255; | ||
static _pow25to7 = 25 ** 7; // 1Math.pow(25, 7); | ||
static _pow25to7 = 25 ** 7; | ||
static _deg360InRad = degrees2radians(360); | ||
@@ -28,0 +26,0 @@ static _deg180InRad = degrees2radians(180); |
@@ -14,6 +14,2 @@ /** | ||
export class AbstractEuclidean extends AbstractDistanceCalculator { | ||
_kR; | ||
_kG; | ||
_kB; | ||
_kA; | ||
calculateRaw(r1, g1, b1, a1, r2, g2, b2, a2) { | ||
@@ -20,0 +16,0 @@ const dR = r2 - r1; |
@@ -14,6 +14,2 @@ /** | ||
export class AbstractManhattan extends AbstractDistanceCalculator { | ||
_kR; | ||
_kG; | ||
_kB; | ||
_kA; | ||
calculateRaw(r1, g1, b1, a1, r2, g2, b2, a2) { | ||
@@ -20,0 +16,0 @@ let dR = r2 - r1; |
@@ -84,3 +84,2 @@ import { ProgressTracker } from '../../utils/progressTracker'; | ||
} | ||
// eslint-disable-next-line default-case | ||
switch (direction) { | ||
@@ -87,0 +86,0 @@ case Direction.LEFT: |
@@ -38,6 +38,5 @@ /* | ||
this._hueStats = new HueStatistics(ColorHistogram._hueGroups, this._minHueCols); | ||
this._histogram = Object.create(null); // tslint:disable-line:no-null-keyword | ||
this._histogram = Object.create(null); | ||
} | ||
sample(pointContainer) { | ||
// eslint-disable-next-line default-case | ||
switch (this._method) { | ||
@@ -44,0 +43,0 @@ case 1: |
@@ -84,3 +84,3 @@ /* | ||
const colorArray = palette.getPointContainer().getPointArray(); | ||
const usageArray = new Array(idxi32.length); // tslint:disable-line:prefer-array-literal | ||
const usageArray = new Array(idxi32.length); | ||
for (let i = 0; i < idxi32.length; i++) { | ||
@@ -87,0 +87,0 @@ colorArray.push(Point.createByUint32(idxi32[i])); |
@@ -569,3 +569,2 @@ /** | ||
// cuts in a certain direction | ||
// eslint-disable-next-line default-case | ||
switch (direction) { | ||
@@ -572,0 +571,0 @@ case WuQuant._red: |
import { Y } from '../constants/bt709'; | ||
// based on https://github.com/rhys-e/structural-similarity | ||
// http://en.wikipedia.org/wiki/Structural_similarity | ||
const K1 = 0.01; // tslint:disable-line:naming-convention | ||
const K2 = 0.03; // tslint:disable-line:naming-convention | ||
const K1 = 0.01; | ||
const K2 = 0.03; | ||
export function ssim(image1, image2) { | ||
@@ -12,3 +12,3 @@ if (image1.getHeight() !== image2.getHeight() || | ||
const bitsPerComponent = 8; | ||
const L = (1 << bitsPerComponent) - 1; // tslint:disable-line:naming-convention | ||
const L = (1 << bitsPerComponent) - 1; | ||
const c1 = (K1 * L) ** 2; | ||
@@ -15,0 +15,0 @@ const c2 = (K2 * L) ** 2; |
@@ -46,3 +46,3 @@ export function degrees2radians(n) { | ||
if (type === 'number' || type === 'string') { | ||
const ord = Object.create(null); // tslint:disable-line:no-null-keyword | ||
const ord = Object.create(null); | ||
for (let i = 0, l = arrayToSort.length; i < l; i++) { | ||
@@ -49,0 +49,0 @@ const val = arrayToSort[i]; |
@@ -82,3 +82,3 @@ /** | ||
_getNearestIndex(colorDistanceCalculator, point) { | ||
let idx = this._nearestPointFromCache('' + point.uint32); // eslint-disable-line prefer-template | ||
let idx = this._nearestPointFromCache('' + point.uint32); | ||
if (idx >= 0) | ||
@@ -85,0 +85,0 @@ return idx; |
@@ -60,8 +60,6 @@ /** | ||
const height = img.naturalHeight; | ||
// eslint-disable-next-line no-undef | ||
const canvas = document.createElement('canvas'); | ||
canvas.width = width; | ||
canvas.height = height; | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
const ctx = canvas.getContext('2d'); // tslint:disable-line:no-non-null-assertion | ||
const ctx = canvas.getContext('2d'); | ||
ctx.drawImage(img, 0, 0, width, height, 0, 0, width, height); | ||
@@ -73,4 +71,3 @@ return PointContainer.fromHTMLCanvasElement(canvas); | ||
const height = canvas.height; | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
const ctx = canvas.getContext('2d'); // tslint:disable-line:no-non-null-assertion | ||
const ctx = canvas.getContext('2d'); | ||
const imgData = ctx.getImageData(0, 0, width, height); | ||
@@ -77,0 +74,0 @@ return PointContainer.fromImageData(imgData); |
{ | ||
"name": "image-q", | ||
"version": "3.0.5", | ||
"version": "3.0.6", | ||
"description": "Image Quantization Library in **TypeScript** *(MIT Licensed)*", | ||
@@ -58,3 +58,3 @@ "license": "MIT", | ||
}, | ||
"readme": "## image-q\n\nComplete Image Quantization Library in **TypeScript** _(MIT License)_\n\n[](https://ibezkrovnyi.github.io/image-quantization-demo/)\n[](https://github.com/ibezkrovnyi/image-quantization/tree/main/packages/image-q)\n[](https://www.npmjs.com/package/image-q)\n[](http://ibezkrovnyi.github.io/image-quantization/)\n[](LICENSE)\n\n\n\n## Table of Contents\n\n- [<span style=\"color: red\">API Documentation and Usage</span>](http://ibezkrovnyi.github.io/image-quantization/)\n- [Introduction](#introduction)\n- [Features](#features)\n- [Todo](#todo)\n- [Breaking changes](#breaking-changes)\n- [Changelog](#changelog)\n- [Credits](#credits)\n- [References](#references)\n- [License](#license)\n\n## Introduction\n\nImage Color Number Reduction with alpha support using RGBQuant/NeuQuant/Xiaolin Wu's algorithms and Euclidean/Manhattan/CIEDE2000 color distance formulas in TypeScript\n\n## Features\n\n1. Platforms supported\n\n - Browser (Chrome 7.0+, FireFox 4.0+, IE 10+, Opera 11.6+, Safari 5.1+)\n - Node.js 6.0+\n\n2. API\n - Basic API: sync and promise-based async\n - Advanced API: sync and generator-based\n3. Builds\n\n - `dist/cjs/image-q.js` - CommonJS\n - `dist/esm/image-q.js` - ESM (ESNext)\n - `dist/cjs/image-q.js` - UMD\n\n4. Import\n - `HTMLImageElement`\n - `HTMLCanvasElement`\n - `NodeCanvas`\n - `ImageData`\n - `Array`\n - `CanvasPixelArray`\n - `Uint8Array`\n - `Uint32Array`\n5. Color Distance\n\n - `Euclidean` - 1/1/1/1 coefficients (originally used in Xiaolin Wu's Quantizer **WuQuant**)\n - `EuclideanBT709NoAlpha` - BT.709 sRGB coefficients (originally used in **RGBQuant**)\n - `EuclideanBT709` BT.709 sRGB coefficients + alpha support\n - `Manhattan` - 1/1/1/1 coefficients (originally used in **NeuQuant**)\n - `ManhattanBT709` - BT.709 sRGB coefficients\n - `ManhattanNommyde` - see https://github.com/igor-bezkrovny/image-quantization/issues/4#issuecomment-234527620\n - `CIEDE2000` - CIEDE2000 (very slow)\n - `CIE94Textiles` - CIE94 implementation for textiles\n - `CIE94GraphicArts` - CIE94 implementation for graphic arts\n - `CMetric` - see http://www.compuphase.com/cmetric.htm\n - `PNGQuant` - used in pngQuant tool\n\n6. Palette Quantizers\n - `NeuQuant` (original code ported, integer calculations)\n - `NeuQuantFloat` (floating-point calculations)\n - `RGBQuant`\n - `WuQuant`\n7. Image Quantizers\n\n - `NearestColor`\n - `ErrorDiffusionArray` - two modes of error propagation are supported: `xnview` and `gimp`\n 1. `FloydSteinberg`\n 2. `FalseFloydSteinberg`\n 3. `Stucki`\n 4. `Atkinson`\n 5. `Jarvis`\n 6. `Burkes`\n 7. `Sierra`\n 8. `TwoSierra`\n 9. `SierraLite`\n - `ErrorDiffusionRiemersma` - Hilbert space-filling curve is used\n\n8. Output\n - `Uint32Array`\n - `Uint8Array`\n\n## Include `image-q` library into your project\n\n##### ES6 module\n\n```javascript\n// will import ESM (ESNext) or UMD version depending on your bundler/node\nimport * as iq from 'image-q';\n```\n\n##### CommonJS\n\n```javascript\nvar iq = require('image-q');\n```\n\n##### As a global variable (Browser)\n\n```html\n<script\n src=\"<path-to image-q/dist/umd/image-q.js>\"\n type=\"text/javascript\"\n charset=\"utf-8\"\n></script>\n```\n\n## How to use\n\nPlease refer to [API Documentation and Usage](http://ibezkrovnyi.github.io/image-quantization/)\n\n## Breaking changes\n\n#### 2.1.1\n\n + PaletteQuantizer#quantize => PaletteQuantizer#quantizeSync\n + ImageQuantizer#quantize => ImageQuantizer#quantizeSync\n\n#### 2.0.1 - 2.0.4 (2018-02-22)\n\n + EuclideanRgbQuantWOAlpha => EuclideanBT709NoAlpha\n + EuclideanRgbQuantWithAlpha => EuclideanBT709\n \t+ ManhattanSRGB => ManhattanBT709\n \t+ IImageDitherer => AbstractImageQuantizer\n \t+ IPaletteQuantizer => AbstractPaletteQuantizer\n \t+ PointContainer.fromNodeCanvas => PointContainer.fromHTMLCanvasElement\n \t+ PointContainer.fromArray => PointContainer.fromUint8Array\n + PointContainer.fromBuffer (Node.js, new)\n \t+ CMETRIC => CMetric\n \t+ PNGQUANT => PNGQuant\n \t+ SSIM Class => ssim function\n\n## TODO\n\n1. ~~notification about progress~~\n2. ~~riemersma dithering~~\n3. ordered dithering <-- is there anyone who needs it?\n4. readme update, more examples\n5. demo update (latest image-q npm version should be used in demo)\n\n## Changelog\n\n##### 2.1.1\n\n + Basic (Simple) API implemented\n + see breaking changes\n\n##### 2.0.5 (2018-02-23)\n\n + @types/node moved to 'dependencies'\n\n##### 2.0.4 (2018-02-23)\n\n + documentation added\n + some refactorings/renames, see breaking changes\n\n##### 2.0.3 (2018-02-22)\n\n + circular dependency removed\n\n##### 2.0.2 (2018-02-22)\n\n + readme updated\n\n##### 2.0.1 (2018-02-22)\n\n + progress tracking api (using es6 generators) added\n + strinct lint rules (+code cleanup/renames)\n + rollup (3 different versions - umd, cjs, esm + source maps + d.ts)\n + latest TypeScript\n + jest\n + snapshot tests\n + coverage (+coveralls)\n + greenkeeper\n\n##### 1.1.1 (2016-08-28)\n\n + CIEDE2000 - incorrect calculation fixed\n + CIEDE2000 - alpha channel now has only 25% impact on color distance instead of 66%\n + CIE94 - added 2 types (textiles and graphics art) according to spec\n + CIE94 - alpha support added\n + rgb2xyz, lab2xyz, xyz2rgb, xyz2lab - gamma correction\n + lab2xyz, xyz2lab - refY should be 100 (1.00000) instead of 10 (0.10000)\n + manhattan with new (Nommyde) coefficients added\n + mocha tests added\n + webpack integration\n + image-q is now UMD module\n + travis-ci integration\n + typescript 2.0\n + indentation with 4 spaces\n\n##### 0.1.4 (2015-06-24)\n\n + Refactoring\n + Riemersma dithering added (Hilbert Curve)\n + Readme.md updated\n + build.cmd updated\n\n##### 0.1.3 (2015-06-16)\n\n + NeuQuant is fixed (again) according to original Anthony Dekker source code (all values should be integer)\n + Error Diffusion Dithering is now calculates error like XNVIEW\n + Refactoring\n\n##### 0.1.2 (2015-06-16)\n\n + Documentation generation fixed\n + File name case problem fixed\n\n##### 0.1.1 (2015-06-16)\n\n + Auto-generated documentation added\n + Refactoring\n\n##### 0.1.0 (2015-06-16)\n\n + Code cleanup, removed unnecessary files\n\n##### 0.0.5 (2015-06-16)\n\n + PNGQuant color distance added, need to check its quality\n + CIEDE2000 and CIE94 fixed for use in NeuQuant\n + NeuQuant is fixed according to original Anthony Dekker source code (all values should be integer)\n + Code refactoring and cleanup\n * We have some slowdown because of red/green/blue/alpha normalization according to white point per each calculateRaw/calculateNormalized call\n\n##### 0.0.4 (2015-06-15)\n\n + CIEDE2000 color distance equation optimized (original CIEDE2000 equation is available as class `CIEDE2000_Original`)\n\n##### 0.0.3b (2015-06-11)\n\n + CMetric color distance fixed\n\n##### 0.0.3a (2015-06-11)\n\n + Cleanup\n + Draft of CMetric color distance added\n\n##### 0.0.2 (2015-06-10)\n\n + rgb2xyz & xyz2lab fixed. CIEDE2000 works much better now.\n + CIE94 distance formula added. More investigation is needed.\n\n##### 0.0.1\n\n + Initial\n\n## Credits\n\nThanks to Leon Sorokin for information share and his original RGBQuant!\n\n## References\n\n- Palette Quantization Algorithms\n\n 1. [RGBQuant (Leon Sorokin)](https://github.com/leeoniya/RgbQuant.js) `JavaScript`\n 2. [NeuQuant (Johan Nordberg)](https://github.com/jnordberg/gif.js/blob/master/src/TypedNeuQuant.js) `TypeScript`\n 3. [NeuQuant (Tim Oxley)](https://github.com/timoxley/neuquant) `JavaScript`\n 4. [NeuQuant (Devon Govett)](https://github.com/devongovett/neuquant) `JavaScript`\n 5. [NeuQuant32 (Stuart Coyle)](https://github.com/stuart/pngnq/blob/master/src/neuquant32.c) `C`\n 6. [Xiaolin Wu (Xiaolin Wu)](http://www.ece.mcmaster.ca/~xwu/cq.c) `C`\n 7. [Xiaolin Wu (Smart-K8)](http://www.codeproject.com/Articles/66341/A-Simple-Yet-Quite-Powerful-Palette-Quantizer-in-C) `C#`\n 8. Xiaolin Wu w/ Alpha (Matt Wrock) [How to add Alpha](https://code.msdn.microsoft.com/windowsdesktop/Convert-32-bit-PNGs-to-81ef8c81/view/SourceCode#content), [Source Code](https://nquant.codeplex.com) `C#`\n 9. [MedianCut (mwcz)](https://github.com/mwcz/median-cut-js) `GPLv3`\n\n- Image Quantization Algorithms\n\n 1. [All (ImageMagik doc)](http://www.imagemagick.org/Usage/quantize/#dither)\n 2. [Error Diffusion dithering (Tanner Helland)](http://www.tannerhelland.com/4660/dithering-eleven-algorithms-source-code)\n 3. [Riemersma dithering](http://www.compuphase.com/riemer.htm) `TODO: Check License`\n 4. [Ordered dithering (Joel Yliluoma)](http://bisqwit.iki.fi/story/howto/dither/jy)\n\n- Color Distance Formulas\n\n [Calculator + Info](http://colorizer.org/)\n\n 1. Euclidean Distance\n 2. Manhattan Distance\n 3. CIE94 Distance\n - [Source Code (Iulius Curt)](https://github.com/iuliux/CIE94.js)\n 4. CIEDE2000\n - [Math and Test Data Table (PDF)](http://www.ece.rochester.edu/~gsharma/ciede2000/ciede2000noteCRNA.pdf)\n - [Info](http://www.ece.rochester.edu/~gsharma/ciede2000/)\n - [Source Code (Greg Fiumara)](https://github.com/gfiumara/CIEDE2000) `C`\n - [Source Code (THEjoezack)](https://github.com/THEjoezack/ColorMine/blob/master/ColorMine/ColorSpaces/Comparisons/CieDe2000Comparison.cs) `C#`\n - [Online Calculator](http://colormine.org/delta-e-calculator/cie2000)\n 5. Euclidean Distance w/o Alpha (RGBQuant)\n 6. Euclidean Distance w/o sRGB coefficients (Xiaolin Wu Quant)\n 7. Manhattan Distance w/o sRGB coefficients (NeuQuant)\n 8. [CMetric](http://www.compuphase.com/cmetric.htm) `DRAFT!`\n\n- Color conversion formulas\n\n 1. [Pseudo-code](http://www.easyrgb.com/?X=MATH)\n\n> 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\n\n- Image Quality Assessment\n\n 1. [SSIM info](http://en.wikipedia.org/wiki/Structural_similarity)\n 2. [SSIM (Rhys-e)](https://github.com/rhys-e/structural-similarity) `Java` `License: MIT`\n 3. PSNR ? TBD\n 4. MSE ? TBD\n\n- Other\n\n 1. [HUSL (Boronine) - info](http://www.husl-colors.org)\n 2. [HUSL (Boronine) - code](https://github.com/husl-colors/husl)\n 3. [Color Image Quantization for Frame Buffer Display](https://www.cs.cmu.edu/~ph/ciq_thesis)\n 4. [K-Means](http://arxiv.org/pdf/1101.0395.pdf)\n 5. [Efficient Color Quantization by Hierarchical Clustering Algorithms](ftp://cs.joensuu.fi/pub/Theses/2005_MSc_Hautamaki_Ville.pdf)\n 6. http://www.codeproject.com/Articles/66341/A-Simple-Yet-Quite-Powerful-Palette-Quantizer-in-C\n\n## License\n\n[MIT](LICENSE)\n" | ||
"readme": "## image-q\n\nComplete Image Quantization Library in **TypeScript** _(MIT License)_\n\n[](https://ibezkrovnyi.github.io/image-quantization-demo/)\n[](https://github.com/ibezkrovnyi/image-quantization/tree/main/packages/image-q)\n[](https://www.npmjs.com/package/image-q)\n[](http://ibezkrovnyi.github.io/image-quantization/)\n[](LICENSE)\n\n\n\n## Table of Contents\n\n- [<span style=\"color: red\">API Documentation and Usage</span>](http://ibezkrovnyi.github.io/image-quantization/)\n- [Introduction](#introduction)\n- [Features](#features)\n- [Todo](#todo)\n- [Breaking changes](#breaking-changes)\n- [Changelog](#changelog)\n- [Credits](#credits)\n- [References](#references)\n- [License](#license)\n\n## Introduction\n\nImage Color Number Reduction with alpha support using RGBQuant/NeuQuant/Xiaolin Wu's algorithms and Euclidean/Manhattan/CIEDE2000 color distance formulas in TypeScript\n\n## Features\n\n1. Platforms supported\n\n - Browser (Chrome 7.0+, FireFox 4.0+, IE 10+, Opera 11.6+, Safari 5.1+)\n - Node.js 6.0+\n\n2. API\n - Basic API: sync and promise-based async\n - Advanced API: sync and generator-based\n3. Builds\n\n - `dist/cjs/image-q.js` - CommonJS\n - `dist/esm/image-q.js` - ESM (ESNext)\n - `dist/cjs/image-q.js` - UMD\n\n4. Import\n - `HTMLImageElement`\n - `HTMLCanvasElement`\n - `NodeCanvas`\n - `ImageData`\n - `Array`\n - `CanvasPixelArray`\n - `Uint8Array`\n - `Uint32Array`\n5. Color Distance\n\n - `Euclidean` - 1/1/1/1 coefficients (originally used in Xiaolin Wu's Quantizer **WuQuant**)\n - `EuclideanBT709NoAlpha` - BT.709 sRGB coefficients (originally used in **RGBQuant**)\n - `EuclideanBT709` BT.709 sRGB coefficients + alpha support\n - `Manhattan` - 1/1/1/1 coefficients (originally used in **NeuQuant**)\n - `ManhattanBT709` - BT.709 sRGB coefficients\n - `ManhattanNommyde` - see https://github.com/igor-bezkrovny/image-quantization/issues/4#issuecomment-234527620\n - `CIEDE2000` - CIEDE2000 (very slow)\n - `CIE94Textiles` - CIE94 implementation for textiles\n - `CIE94GraphicArts` - CIE94 implementation for graphic arts\n - `CMetric` - see http://www.compuphase.com/cmetric.htm\n - `PNGQuant` - used in pngQuant tool\n\n6. Palette Quantizers\n - `NeuQuant` (original code ported, integer calculations)\n - `NeuQuantFloat` (floating-point calculations)\n - `RGBQuant`\n - `WuQuant`\n7. Image Quantizers\n\n - `NearestColor`\n - `ErrorDiffusionArray` - two modes of error propagation are supported: `xnview` and `gimp`\n 1. `FloydSteinberg`\n 2. `FalseFloydSteinberg`\n 3. `Stucki`\n 4. `Atkinson`\n 5. `Jarvis`\n 6. `Burkes`\n 7. `Sierra`\n 8. `TwoSierra`\n 9. `SierraLite`\n - `ErrorDiffusionRiemersma` - Hilbert space-filling curve is used\n\n8. Output\n - `Uint32Array`\n - `Uint8Array`\n\n## Include `image-q` library into your project\n\n##### ES6 module\n\n```javascript\n// will import ESM (ESNext) or UMD version depending on your bundler/node\nimport * as iq from 'image-q';\n```\n\n##### CommonJS\n\n```javascript\nvar iq = require('image-q');\n```\n\n##### As a global variable (Browser)\n\n```html\n<script\n src=\"<path-to image-q/dist/umd/image-q.js>\"\n type=\"text/javascript\"\n charset=\"utf-8\"\n></script>\n```\n\n## How to use\n\nPlease refer to [API Documentation and Usage](http://ibezkrovnyi.github.io/image-quantization/)\n\n## Breaking changes\n\n#### 2.1.1\n\n + PaletteQuantizer#quantize => PaletteQuantizer#quantizeSync\n + ImageQuantizer#quantize => ImageQuantizer#quantizeSync\n\n#### 2.0.1 - 2.0.4 (2018-02-22)\n\n + EuclideanRgbQuantWOAlpha => EuclideanBT709NoAlpha\n + EuclideanRgbQuantWithAlpha => EuclideanBT709\n \t+ ManhattanSRGB => ManhattanBT709\n \t+ IImageDitherer => AbstractImageQuantizer\n \t+ IPaletteQuantizer => AbstractPaletteQuantizer\n \t+ PointContainer.fromNodeCanvas => PointContainer.fromHTMLCanvasElement\n \t+ PointContainer.fromArray => PointContainer.fromUint8Array\n + PointContainer.fromBuffer (Node.js, new)\n \t+ CMETRIC => CMetric\n \t+ PNGQUANT => PNGQuant\n \t+ SSIM Class => ssim function\n\n## TODO\n\n1. ~~notification about progress~~\n2. ~~riemersma dithering~~\n3. ordered dithering <-- is there anyone who needs it?\n4. readme update, more examples\n5. demo update (latest image-q npm version should be used in demo)\n\n## Changelog\n\n##### 3.0.6\n + Fixed: \"Always empty result in certain webpack / babel configs\" (#95)\n\n##### 3.0.0\n + pnpm monorepo, esbuild for faster builds, typescript upgraded\n\n##### 2.1.1\n\n + Basic (Simple) API implemented\n + see breaking changes\n\n##### 2.0.5 (2018-02-23)\n\n + @types/node moved to 'dependencies'\n\n##### 2.0.4 (2018-02-23)\n\n + documentation added\n + some refactorings/renames, see breaking changes\n\n##### 2.0.3 (2018-02-22)\n\n + circular dependency removed\n\n##### 2.0.2 (2018-02-22)\n\n + readme updated\n\n##### 2.0.1 (2018-02-22)\n\n + progress tracking api (using es6 generators) added\n + strinct lint rules (+code cleanup/renames)\n + rollup (3 different versions - umd, cjs, esm + source maps + d.ts)\n + latest TypeScript\n + jest\n + snapshot tests\n + coverage (+coveralls)\n + greenkeeper\n\n##### 1.1.1 (2016-08-28)\n\n + CIEDE2000 - incorrect calculation fixed\n + CIEDE2000 - alpha channel now has only 25% impact on color distance instead of 66%\n + CIE94 - added 2 types (textiles and graphics art) according to spec\n + CIE94 - alpha support added\n + rgb2xyz, lab2xyz, xyz2rgb, xyz2lab - gamma correction\n + lab2xyz, xyz2lab - refY should be 100 (1.00000) instead of 10 (0.10000)\n + manhattan with new (Nommyde) coefficients added\n + mocha tests added\n + webpack integration\n + image-q is now UMD module\n + travis-ci integration\n + typescript 2.0\n + indentation with 4 spaces\n\n##### 0.1.4 (2015-06-24)\n\n + Refactoring\n + Riemersma dithering added (Hilbert Curve)\n + Readme.md updated\n + build.cmd updated\n\n##### 0.1.3 (2015-06-16)\n\n + NeuQuant is fixed (again) according to original Anthony Dekker source code (all values should be integer)\n + Error Diffusion Dithering is now calculates error like XNVIEW\n + Refactoring\n\n##### 0.1.2 (2015-06-16)\n\n + Documentation generation fixed\n + File name case problem fixed\n\n##### 0.1.1 (2015-06-16)\n\n + Auto-generated documentation added\n + Refactoring\n\n##### 0.1.0 (2015-06-16)\n\n + Code cleanup, removed unnecessary files\n\n##### 0.0.5 (2015-06-16)\n\n + PNGQuant color distance added, need to check its quality\n + CIEDE2000 and CIE94 fixed for use in NeuQuant\n + NeuQuant is fixed according to original Anthony Dekker source code (all values should be integer)\n + Code refactoring and cleanup\n * We have some slowdown because of red/green/blue/alpha normalization according to white point per each calculateRaw/calculateNormalized call\n\n##### 0.0.4 (2015-06-15)\n\n + CIEDE2000 color distance equation optimized (original CIEDE2000 equation is available as class `CIEDE2000_Original`)\n\n##### 0.0.3b (2015-06-11)\n\n + CMetric color distance fixed\n\n##### 0.0.3a (2015-06-11)\n\n + Cleanup\n + Draft of CMetric color distance added\n\n##### 0.0.2 (2015-06-10)\n\n + rgb2xyz & xyz2lab fixed. CIEDE2000 works much better now.\n + CIE94 distance formula added. More investigation is needed.\n\n##### 0.0.1\n\n + Initial\n\n## Credits\n\nThanks to Leon Sorokin for information share and his original RGBQuant!\n\n## References\n\n- Palette Quantization Algorithms\n\n 1. [RGBQuant (Leon Sorokin)](https://github.com/leeoniya/RgbQuant.js) `JavaScript`\n 2. [NeuQuant (Johan Nordberg)](https://github.com/jnordberg/gif.js/blob/master/src/TypedNeuQuant.js) `TypeScript`\n 3. [NeuQuant (Tim Oxley)](https://github.com/timoxley/neuquant) `JavaScript`\n 4. [NeuQuant (Devon Govett)](https://github.com/devongovett/neuquant) `JavaScript`\n 5. [NeuQuant32 (Stuart Coyle)](https://github.com/stuart/pngnq/blob/master/src/neuquant32.c) `C`\n 6. [Xiaolin Wu (Xiaolin Wu)](http://www.ece.mcmaster.ca/~xwu/cq.c) `C`\n 7. [Xiaolin Wu (Smart-K8)](http://www.codeproject.com/Articles/66341/A-Simple-Yet-Quite-Powerful-Palette-Quantizer-in-C) `C#`\n 8. Xiaolin Wu w/ Alpha (Matt Wrock) [How to add Alpha](https://code.msdn.microsoft.com/windowsdesktop/Convert-32-bit-PNGs-to-81ef8c81/view/SourceCode#content), [Source Code](https://nquant.codeplex.com) `C#`\n 9. [MedianCut (mwcz)](https://github.com/mwcz/median-cut-js) `GPLv3`\n\n- Image Quantization Algorithms\n\n 1. [All (ImageMagik doc)](http://www.imagemagick.org/Usage/quantize/#dither)\n 2. [Error Diffusion dithering (Tanner Helland)](http://www.tannerhelland.com/4660/dithering-eleven-algorithms-source-code)\n 3. [Riemersma dithering](http://www.compuphase.com/riemer.htm) `TODO: Check License`\n 4. [Ordered dithering (Joel Yliluoma)](http://bisqwit.iki.fi/story/howto/dither/jy)\n\n- Color Distance Formulas\n\n [Calculator + Info](http://colorizer.org/)\n\n 1. Euclidean Distance\n 2. Manhattan Distance\n 3. CIE94 Distance\n - [Source Code (Iulius Curt)](https://github.com/iuliux/CIE94.js)\n 4. CIEDE2000\n - [Math and Test Data Table (PDF)](http://www.ece.rochester.edu/~gsharma/ciede2000/ciede2000noteCRNA.pdf)\n - [Info](http://www.ece.rochester.edu/~gsharma/ciede2000/)\n - [Source Code (Greg Fiumara)](https://github.com/gfiumara/CIEDE2000) `C`\n - [Source Code (THEjoezack)](https://github.com/THEjoezack/ColorMine/blob/master/ColorMine/ColorSpaces/Comparisons/CieDe2000Comparison.cs) `C#`\n - [Online Calculator](http://colormine.org/delta-e-calculator/cie2000)\n 5. Euclidean Distance w/o Alpha (RGBQuant)\n 6. Euclidean Distance w/o sRGB coefficients (Xiaolin Wu Quant)\n 7. Manhattan Distance w/o sRGB coefficients (NeuQuant)\n 8. [CMetric](http://www.compuphase.com/cmetric.htm) `DRAFT!`\n\n- Color conversion formulas\n\n 1. [Pseudo-code](http://www.easyrgb.com/?X=MATH)\n\n> 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\n\n- Image Quality Assessment\n\n 1. [SSIM info](http://en.wikipedia.org/wiki/Structural_similarity)\n 2. [SSIM (Rhys-e)](https://github.com/rhys-e/structural-similarity) `Java` `License: MIT`\n 3. PSNR ? TBD\n 4. MSE ? TBD\n\n- Other\n\n 1. [HUSL (Boronine) - info](http://www.husl-colors.org)\n 2. [HUSL (Boronine) - code](https://github.com/husl-colors/husl)\n 3. [Color Image Quantization for Frame Buffer Display](https://www.cs.cmu.edu/~ph/ciq_thesis)\n 4. [K-Means](http://arxiv.org/pdf/1101.0395.pdf)\n 5. [Efficient Color Quantization by Hierarchical Clustering Algorithms](ftp://cs.joensuu.fi/pub/Theses/2005_MSc_Hautamaki_Ville.pdf)\n 6. http://www.codeproject.com/Articles/66341/A-Simple-Yet-Quite-Powerful-Palette-Quantizer-in-C\n\n## License\n\n[MIT](LICENSE)\n" | ||
} |
@@ -152,2 +152,8 @@ ## image-q | ||
##### 3.0.6 | ||
+ Fixed: "Always empty result in certain webpack / babel configs" (#95) | ||
##### 3.0.0 | ||
+ pnpm monorepo, esbuild for faster builds, typescript upgraded | ||
##### 2.1.1 | ||
@@ -154,0 +160,0 @@ |
@@ -20,3 +20,2 @@ /** | ||
// tslint:disable-next-line:naming-convention | ||
export enum x { | ||
@@ -29,3 +28,2 @@ RED = 0.64, | ||
// tslint:disable-next-line:naming-convention | ||
export enum y { | ||
@@ -32,0 +30,0 @@ RED = 0.33, |
@@ -11,3 +11,2 @@ /** | ||
// tslint:disable-next-line:naming-convention | ||
export function lab2rgb(L: number, a: number, b: number) { | ||
@@ -14,0 +13,0 @@ const xyz = lab2xyz(L, a, b); |
@@ -16,3 +16,2 @@ /** | ||
// tslint:disable-next-line:naming-convention | ||
export function lab2xyz(L: number, a: number, b: number) { | ||
@@ -19,0 +18,0 @@ const y = (L + 16) / 116; |
@@ -22,6 +22,6 @@ /** | ||
*/ | ||
protected _kA!: number; | ||
protected _Kl!: number; // tslint:disable-line:naming-convention | ||
protected _K1!: number; // tslint:disable-line:naming-convention | ||
protected _K2!: number; // tslint:disable-line:naming-convention | ||
declare protected _kA: number; | ||
declare protected _Kl: number; | ||
declare protected _K1: number; | ||
declare protected _K2: number; | ||
@@ -28,0 +28,0 @@ calculateRaw( |
@@ -12,5 +12,2 @@ /** | ||
// tslint:disable:variable-name | ||
// tslint:disable:naming-convention | ||
/** | ||
@@ -27,3 +24,3 @@ * CIEDE2000 algorithm - Adapted from Sharma et al's MATLAB implementation at | ||
private static readonly _kA = (0.25 * 100) / 255; | ||
private static readonly _pow25to7 = 25 ** 7; // 1Math.pow(25, 7); | ||
private static readonly _pow25to7 = 25 ** 7; | ||
private static readonly _deg360InRad = degrees2radians(360); | ||
@@ -30,0 +27,0 @@ private static readonly _deg180InRad = degrees2radians(180); |
@@ -15,6 +15,6 @@ /** | ||
export abstract class AbstractEuclidean extends AbstractDistanceCalculator { | ||
protected _kR!: number; | ||
protected _kG!: number; | ||
protected _kB!: number; | ||
protected _kA!: number; | ||
declare protected _kR: number; | ||
declare protected _kG: number; | ||
declare protected _kB: number; | ||
declare protected _kA: number; | ||
@@ -21,0 +21,0 @@ calculateRaw( |
@@ -15,6 +15,6 @@ /** | ||
export abstract class AbstractManhattan extends AbstractDistanceCalculator { | ||
protected _kR!: number; | ||
protected _kG!: number; | ||
protected _kB!: number; | ||
protected _kA!: number; | ||
declare protected _kR: number; | ||
declare protected _kG: number; | ||
declare protected _kB: number; | ||
declare protected _kA: number; | ||
@@ -21,0 +21,0 @@ calculateRaw( |
@@ -112,3 +112,2 @@ import { ProgressTracker } from '../../utils/progressTracker'; | ||
} | ||
// eslint-disable-next-line default-case | ||
switch (direction) { | ||
@@ -115,0 +114,0 @@ case Direction.LEFT: |
@@ -61,7 +61,6 @@ /* | ||
this._histogram = Object.create(null); // tslint:disable-line:no-null-keyword | ||
this._histogram = Object.create(null); | ||
} | ||
sample(pointContainer: PointContainer) { | ||
// eslint-disable-next-line default-case | ||
switch (this._method) { | ||
@@ -68,0 +67,0 @@ case 1: |
@@ -109,3 +109,3 @@ /* | ||
const colorArray = palette.getPointContainer().getPointArray(); | ||
const usageArray = new Array(idxi32.length); // tslint:disable-line:prefer-array-literal | ||
const usageArray = new Array(idxi32.length); | ||
@@ -112,0 +112,0 @@ for (let i = 0; i < idxi32.length; i++) { |
@@ -1002,3 +1002,2 @@ /** | ||
// cuts in a certain direction | ||
// eslint-disable-next-line default-case | ||
switch (direction) { | ||
@@ -1005,0 +1004,0 @@ case WuQuant._red: |
@@ -13,4 +13,4 @@ /** | ||
// http://en.wikipedia.org/wiki/Structural_similarity | ||
const K1 = 0.01; // tslint:disable-line:naming-convention | ||
const K2 = 0.03; // tslint:disable-line:naming-convention | ||
const K1 = 0.01; | ||
const K2 = 0.03; | ||
@@ -26,3 +26,3 @@ export function ssim(image1: PointContainer, image2: PointContainer) { | ||
const bitsPerComponent = 8; | ||
const L = (1 << bitsPerComponent) - 1; // tslint:disable-line:naming-convention | ||
const L = (1 << bitsPerComponent) - 1; | ||
const c1 = (K1 * L) ** 2; | ||
@@ -29,0 +29,0 @@ const c2 = (K2 * L) ** 2; |
@@ -46,3 +46,3 @@ export function degrees2radians(n: number) { | ||
if (type === 'number' || type === 'string') { | ||
const ord = Object.create(null); // tslint:disable-line:no-null-keyword | ||
const ord = Object.create(null); | ||
for (let i = 0, l = arrayToSort.length; i < l; i++) { | ||
@@ -49,0 +49,0 @@ const val = arrayToSort[i] as unknown as string; |
@@ -105,3 +105,3 @@ /** | ||
) { | ||
let idx = this._nearestPointFromCache('' + point.uint32); // eslint-disable-line prefer-template | ||
let idx = this._nearestPointFromCache('' + point.uint32); | ||
if (idx >= 0) return idx; | ||
@@ -108,0 +108,0 @@ |
@@ -78,3 +78,2 @@ /** | ||
// eslint-disable-next-line no-undef | ||
const canvas = document.createElement('canvas'); | ||
@@ -84,4 +83,3 @@ canvas.width = width; | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
const ctx = canvas.getContext('2d')!; // tslint:disable-line:no-non-null-assertion | ||
const ctx = canvas.getContext('2d')!; | ||
ctx.drawImage(img, 0, 0, width, height, 0, 0, width, height); | ||
@@ -96,4 +94,3 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
const ctx = canvas.getContext('2d')!; // tslint:disable-line:no-non-null-assertion | ||
const ctx = canvas.getContext('2d')!; | ||
const imgData = ctx.getImageData(0, 0, width, height); | ||
@@ -100,0 +97,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
333
1.83%1010141
-0.45%12859
-0.32%