iq.js.map 268 KB
{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap cc12c561526565ac4570","webpack:///./src/iq.ts","webpack:///./src/constants/index.ts","webpack:///./src/constants/bt709.ts","webpack:///./src/conversion/index.ts","webpack:///./src/conversion/rgb2xyz.ts","webpack:///./src/conversion/rgb2hsl.ts","webpack:///./src/utils/arithmetic.ts","webpack:///./src/conversion/rgb2lab.ts","webpack:///./src/conversion/xyz2lab.ts","webpack:///./src/conversion/lab2xyz.ts","webpack:///./src/conversion/lab2rgb.ts","webpack:///./src/conversion/xyz2rgb.ts","webpack:///./src/distance/index.ts","webpack:///./src/distance/abstractDistanceCalculator.ts","webpack:///./src/distance/cie94.ts","webpack:///./src/distance/ciede2000.ts","webpack:///./src/distance/cmetric.ts","webpack:///./src/distance/euclidean.ts","webpack:///./src/distance/manhattan.ts","webpack:///./src/distance/pngQuant.ts","webpack:///./src/palette/index.ts","webpack:///./src/palette/neuquant/neuquant.ts","webpack:///./src/utils/palette.ts","webpack:///./src/utils/pointContainer.ts","webpack:///./src/utils/point.ts","webpack:///./src/palette/neuquant/neuquantFloat.ts","webpack:///./src/palette/rgbquant/rgbquant.ts","webpack:///./src/palette/rgbquant/colorHistogram.ts","webpack:///./src/utils/hueStatistics.ts","webpack:///./src/palette/wu/wuQuant.ts","webpack:///./src/image/index.ts","webpack:///./src/image/nearestColor.ts","webpack:///./src/image/array.ts","webpack:///./src/image/riemersma.ts","webpack:///./src/image/spaceFillingCurves/hilbertCurve.ts","webpack:///./src/quality/index.ts","webpack:///./src/quality/ssim.ts","webpack:///./src/utils/index.ts"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;ACVA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uBAAe;AACf;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AAC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iBACjC,IAAM,KAAK,GAAa,UAAU,CAAE,MAAM,GAAG,CAAC,CAAE,CAAC;iBACjD,UAAU,CAAE,OAAO,CAAE,GAAG,KAAK,CAAC,CAAC,GAAG,SAAC,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC,GAAG,SAAC,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,GAAG,SAAC,CAAC,IAAI,CAAC;iBAC/E,OAAO,EAAE,CAAC;aACd,CAAC;SACL,CAAC;SAED,MAAM,CAAC,UAAU,CAAC;KACtB,CAAC;KAEO,oCAAqB,GAA7B,UAA8B,UAAqB;SAC/C,IAAI,OAAO,GAAG,GAAG,CAAC;SAClB,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;aACzC,OAAO,IAAI,UAAU,CAAE,CAAC,CAAE,CAAC;SAC/B,CAAC;SAED,MAAM,CAAC,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC;KACvC,CAAC;KAEL,WAAC;AAAD,EAAC;AA7FY,aAAI,OA6FhB;;;;;;;;AC5GD;;;;;;IAMG;AACH,KAAY,UAAU,uBAAM,CAC5B,CAAC,CADyC;AAWtC,mBAAU;AAVd,2CAA8B,EAC9B,CAAC,CAD8C;AAS3C,sBAAa;AARjB,qCAAwB,EACxB,CAAC,CADkC;AAO/B,gBAAO;AANX,mCAAsB,EACtB,CAAC,CAD8B;AAI3B,cAAK;AAHT,4CAA+B,EAE/B,CAAC,CAFgD;AAI7C,uBAAc","file":"D:\\projects\\my\\github\\image-quantization\\src/../dist/iq.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"iq\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"iq\"] = factory();\n\telse\n\t\troot[\"iq\"] = factory();\n})(this, function() {\nreturn \n\n\n/** WEBPACK FOOTER **\n ** webpack/universalModuleDefinition\n **/"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap cc12c561526565ac4570\n **/","/**\r\n * @preserve\r\n * Copyright 2015-2016 Igor Bezkrovnyi\r\n * All rights reserved. (MIT Licensed)\r\n *\r\n * iq.ts - Image Quantization Library\r\n */\r\nimport * as constants from \"./constants\"\r\nimport * as conversion from \"./conversion\"\r\nimport * as distance from \"./distance\"\r\nimport * as palette from \"./palette\"\r\nimport * as image from \"./image\"\r\nimport * as quality from \"./quality\"\r\nimport * as utils from \"./utils\"\r\n\r\nexport {\r\n    constants,\r\n    conversion,\r\n    distance,\r\n    palette,\r\n    image,\r\n    quality,\r\n    utils\r\n}\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/iq.ts\n **/","/**\r\n * @preserve\r\n * Copyright 2015-2016 Igor Bezkrovnyi\r\n * All rights reserved. (MIT Licensed)\r\n *\r\n * constants.ts - part of Image Quantization Library\r\n */\r\nimport * as bt709 from \"./bt709\"\r\n\r\nexport {\r\n    bt709\r\n}\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/constants/index.ts\n **/","/**\r\n * @preserve\r\n * Copyright 2015-2016 Igor Bezkrovnyi\r\n * All rights reserved. (MIT Licensed)\r\n *\r\n * constants.ts - part of Image Quantization Library\r\n */\r\n\r\n/**\r\n * sRGB (based on ITU-R Recommendation BT.709)\r\n * http://en.wikipedia.org/wiki/SRGB\r\n */\r\nenum Y {\r\n    RED = .2126, GREEN = .7152, BLUE = .0722, WHITE = 1\r\n}\r\n\r\nenum x {\r\n    RED = .6400, GREEN = .3000, BLUE = .1500, WHITE = .3127\r\n}\r\n\r\nenum y {\r\n    RED = .3300, GREEN = .6000, BLUE = .0600, WHITE = .3290\r\n}\r\n\r\nexport {\r\n    Y,\r\n    x,\r\n    y\r\n}\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/constants/bt709.ts\n **/","/**\r\n * @preserve\r\n * Copyright 2015-2016 Igor Bezkrovnyi\r\n * All rights reserved. (MIT Licensed)\r\n *\r\n * iq.ts - Image Quantization Library\r\n */\r\nimport { rgb2xyz } from \"./rgb2xyz\"\r\nimport { rgb2hsl } from \"./rgb2hsl\"\r\nimport { rgb2lab } from \"./rgb2lab\"\r\nimport { lab2xyz } from \"./lab2xyz\"\r\nimport { lab2rgb } from \"./lab2rgb\"\r\nimport { xyz2lab } from \"./xyz2lab\"\r\nimport { xyz2rgb } from \"./xyz2rgb\"\r\n\r\nexport {\r\n    rgb2xyz,\r\n    rgb2hsl,\r\n    rgb2lab,\r\n    lab2xyz,\r\n    lab2rgb,\r\n    xyz2lab,\r\n    xyz2rgb,\r\n}\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/conversion/index.ts\n **/","/**\r\n * @preserve\r\n * Copyright 2015-2016 Igor Bezkrovnyi\r\n * All rights reserved. (MIT Licensed)\r\n *\r\n * rgb2xyz.ts - part of Image Quantization Library\r\n */\r\nfunction correctGamma(n : number) {\r\n    return n > 0.04045 ? Math.pow((n + 0.055) / 1.055, 2.4) : n / 12.92;\r\n}\r\n\r\nexport function rgb2xyz(r : number, g : number, b : number) : { x : number; y : number; z : number } {\r\n    // gamma correction, see https://en.wikipedia.org/wiki/SRGB#The_reverse_transformation\r\n    r = correctGamma(r / 255);\r\n    g = correctGamma(g / 255);\r\n    b = correctGamma(b / 255);\r\n\r\n    // Observer. = 2°, Illuminant = D65\r\n    return {\r\n        x : r * 0.4124 + g * 0.3576 + b * 0.1805,\r\n        y : r * 0.2126 + g * 0.7152 + b * 0.0722,\r\n        z : r * 0.0193 + g * 0.1192 + b * 0.9505\r\n    }\r\n}\r\n\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/conversion/rgb2xyz.ts\n **/","/**\r\n * @preserve\r\n * Copyright 2015-2016 Igor Bezkrovnyi\r\n * All rights reserved. (MIT Licensed)\r\n *\r\n * rgb2hsl.ts - part of Image Quantization Library\r\n */\r\nimport { min3, max3 } from \"../utils/arithmetic\"\r\n\r\n/**\r\n * Calculate HSL from RGB\r\n * Hue is in degrees [0..360]\r\n * Lightness: [0..1]\r\n * Saturation: [0..1]\r\n * http://web.archive.org/web/20060914040436/http://local.wasp.uwa.edu.au/~pbourke/colour/hsl/\r\n */\r\nexport function rgb2hsl(r : number, g : number, b : number) : {h : number; s : number; l : number} {\r\n    const min   = min3(r, g, b),\r\n          max   = max3(r, g, b),\r\n          delta = max - min,\r\n          l     = (min + max) / 510;\r\n\r\n    let s = 0;\r\n    if (l > 0 && l < 1) s = delta / (l < 0.5 ? (max + min) : (510 - max - min));\r\n\r\n    let h = 0;\r\n    if (delta > 0) {\r\n        if (max === r) {\r\n            h = (g - b) / delta;\r\n        } else if (max === g) {\r\n            h = (2 + (b - r) / delta);\r\n        } else {\r\n            h = (4 + (r - g) / delta);\r\n        }\r\n\r\n        h *= 60;\r\n        if (h < 0) h += 360;\r\n    }\r\n    return { h, s, l };\r\n}\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/conversion/rgb2hsl.ts\n **/","export function degrees2radians(n : number) : number {\r\n    return n * (Math.PI / 180);\r\n}\r\n\r\nexport function max3(a : number, b : number, c : number) {\r\n    let m = a;\r\n    (m < b) && (m = b);\r\n    (m < c) && (m = c);\r\n    return m;\r\n}\r\n\r\nexport function min3(a : number, b : number, c : number) {\r\n    let m = a;\r\n    (m > b) && (m = b);\r\n    (m > c) && (m = c);\r\n    return m;\r\n}\r\n\r\nexport function intInRange(value : number, low : number, high : number) {\r\n    if (value > high) value = high;\r\n    if (value < low) value = low;\r\n    return value | 0;\r\n}\r\n\r\nexport function inRange0to255Rounded(n : number) {\r\n    n = Math.round(n);\r\n    if (n > 255) n = 255;\r\n    else if (n < 0) n = 0;\r\n    return n;\r\n}\r\n\r\nexport function inRange0to255(n : number) {\r\n    if (n > 255) n = 255;\r\n    else if (n < 0) n = 0;\r\n    return n;\r\n}\r\n\r\nexport function stableSort<T>(arrayToSort : T[], callback : (a : T, b : T) => number) : T[] {\r\n    const type = typeof arrayToSort[ 0 ];\r\n    let sorted : T[];\r\n\r\n    if (type === \"number\" || type === \"string\") {\r\n        const ord = Object.create(null);\r\n        for (let i = 0, l = arrayToSort.length; i < l; i++) {\r\n            const val : string = <any>arrayToSort[ i ];\r\n            if (ord[ val ] || ord[ val ] === 0) continue;\r\n            ord[ val ] = i;\r\n        }\r\n\r\n        sorted = arrayToSort.sort(function (a, b) {\r\n            return callback(a, b) || ord[ <any>a ] - ord[ <any>b ];\r\n        });\r\n    } else {\r\n        const ord2 : T[] = arrayToSort.slice(0);\r\n        sorted           = arrayToSort.sort(function (a, b) {\r\n            return callback(a, b) || ord2.indexOf(a) - ord2.indexOf(b);\r\n        });\r\n    }\r\n\r\n    return sorted;\r\n}\r\n\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/utils/arithmetic.ts\n **/","/**\r\n * @preserve\r\n * Copyright 2015-2016 Igor Bezkrovnyi\r\n * All rights reserved. (MIT Licensed)\r\n *\r\n * rgb2lab.ts - part of Image Quantization Library\r\n */\r\nimport { rgb2xyz } from \"./rgb2xyz\"\r\nimport { xyz2lab } from \"./xyz2lab\"\r\n\r\nexport function rgb2lab(r : number, g : number, b : number) : { L : number; a : number; b : number } {\r\n    const xyz = rgb2xyz(r, g, b);\r\n    return xyz2lab(xyz.x, xyz.y, xyz.z);\r\n}\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/conversion/rgb2lab.ts\n **/","/**\r\n * @preserve\r\n * Copyright 2015-2016 Igor Bezkrovnyi\r\n * All rights reserved. (MIT Licensed)\r\n *\r\n * xyz2lab.ts - part of Image Quantization Library\r\n */\r\nconst refX : number = 0.95047, //ref_X =  95.047   Observer= 2°, Illuminant= D65\r\n      refY : number = 1.00000, //ref_Y = 100.000\r\n      refZ : number = 1.08883; //ref_Z = 108.883\r\n\r\nfunction pivot(n : number) : number {\r\n    return n > 0.008856 ? Math.pow(n, 1 / 3) : ( 7.787 * n + 16 / 116);\r\n}\r\n\r\nexport function xyz2lab(x : number, y : number, z : number) : {L : number; a : number; b : number} {\r\n    x = pivot(x / refX);\r\n    y = pivot(y / refY);\r\n    z = pivot(z / refZ);\r\n\r\n    if (( 116 * y ) - 16 < 0) throw new Error(\"xxx\")\r\n    return {\r\n        L : Math.max(0, ( 116 * y ) - 16),\r\n        a : 500 * ( x - y ),\r\n        b : 200 * ( y - z )\r\n    }\r\n}\r\n\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/conversion/xyz2lab.ts\n **/","/**\r\n * @preserve\r\n * Copyright 2015-2016 Igor Bezkrovnyi\r\n * All rights reserved. (MIT Licensed)\r\n *\r\n * lab2xyz.ts - part of Image Quantization Library\r\n */\r\nconst refX : number = 0.95047, //ref_X =  95.047   Observer= 2°, Illuminant = D65\r\n      refY : number = 1.00000, //ref_Y = 100.000\r\n      refZ : number = 1.08883; //ref_Z = 108.883\r\n\r\nfunction pivot(n : number) {\r\n    return n > 0.206893034 ? Math.pow(n, 3) : ( n - 16 / 116 ) / 7.787\r\n}\r\n\r\nexport function lab2xyz(L : number, a : number, b : number) : {x : number; y : number; z : number} {\r\n    const y = ( L + 16 ) / 116,\r\n          x = a / 500 + y,\r\n          z = y - b / 200;\r\n\r\n    return {\r\n        x : refX * pivot(x),\r\n        y : refY * pivot(y),\r\n        z : refZ * pivot(z)\r\n    }\r\n}\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/conversion/lab2xyz.ts\n **/","/**\r\n * @preserve\r\n * Copyright 2015-2016 Igor Bezkrovnyi\r\n * All rights reserved. (MIT Licensed)\r\n *\r\n * lab2rgb.ts - part of Image Quantization Library\r\n */\r\nimport { lab2xyz } from \"./lab2xyz\"\r\nimport { xyz2rgb } from \"./xyz2rgb\"\r\n\r\nexport function lab2rgb(L : number, a : number, b : number) : { r : number; g : number; b : number } {\r\n    const xyz = lab2xyz(L, a, b);\r\n    return xyz2rgb(xyz.x, xyz.y, xyz.z);\r\n}\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/conversion/lab2rgb.ts\n **/","/**\r\n * @preserve\r\n * Copyright 2015-2016 Igor Bezkrovnyi\r\n * All rights reserved. (MIT Licensed)\r\n *\r\n * xyz2rgb.ts - part of Image Quantization Library\r\n */\r\nimport { inRange0to255Rounded } from \"../utils/arithmetic\"\r\n\r\n// gamma correction, see https://en.wikipedia.org/wiki/SRGB#The_reverse_transformation\r\nfunction correctGamma(n : number) {\r\n    return n > 0.0031308 ? 1.055 * Math.pow(n, 1 / 2.4) - 0.055 : 12.92 * n;\r\n}\r\n\r\nexport function xyz2rgb(x : number, y : number, z : number) : { r : number; g : number; b : number } {\r\n    // Observer. = 2°, Illuminant = D65\r\n    const r = correctGamma(x * 3.2406 + y * -1.5372 + z * -0.4986),\r\n          g = correctGamma(x * -0.9689 + y * 1.8758 + z * 0.0415),\r\n          b = correctGamma(x * 0.0557 + y * -0.2040 + z * 1.0570);\r\n\r\n    return {\r\n        r : inRange0to255Rounded(r * 255),\r\n        g : inRange0to255Rounded(g * 255),\r\n        b : inRange0to255Rounded(b * 255)\r\n    }\r\n}\r\n\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/conversion/xyz2rgb.ts\n **/","/**\r\n * @preserve\r\n * Copyright 2015-2016 Igor Bezkrovnyi\r\n * All rights reserved. (MIT Licensed)\r\n *\r\n * iq.ts - Image Quantization Library\r\n */\r\nimport { AbstractDistanceCalculator } from \"./abstractDistanceCalculator\"\r\nimport { CIE94Textiles, CIE94GraphicArts } from \"./cie94\"\r\nimport { CIEDE2000 } from \"./ciede2000\"\r\nimport { CMETRIC } from \"./cmetric\"\r\nimport { AbstractEuclidean, Euclidean, EuclideanRgbQuantWOAlpha, EuclideanRgbQuantWithAlpha } from \"./euclidean\"\r\nimport { AbstractManhattan, Manhattan, ManhattanSRGB, ManhattanNommyde } from \"./manhattan\"\r\nimport { PNGQUANT } from \"./pngQuant\"\r\n\r\nexport {\r\n    AbstractDistanceCalculator,\r\n    CIE94Textiles,\r\n    CIE94GraphicArts,\r\n    CIEDE2000,\r\n    CMETRIC,\r\n    PNGQUANT,\r\n\r\n    AbstractEuclidean,\r\n    Euclidean,\r\n    EuclideanRgbQuantWithAlpha,\r\n    EuclideanRgbQuantWOAlpha,\r\n\r\n    AbstractManhattan,\r\n    Manhattan,\r\n    ManhattanSRGB,\r\n    ManhattanNommyde\r\n}\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/distance/index.ts\n **/","/**\r\n * @preserve\r\n * Copyright 2015-2016 Igor Bezkrovnyi\r\n * All rights reserved. (MIT Licensed)\r\n *\r\n * common.ts - part of Image Quantization Library\r\n */\r\nimport { Point } from \"../utils/point\"\r\n\r\nexport abstract class AbstractDistanceCalculator {\r\n    protected _maxDistance : number;\r\n    protected _whitePoint : { r : number; g : number; b : number; a : number };\r\n\r\n    constructor() {\r\n        this._setDefaults();\r\n\r\n        // set default maximal color component deltas (255 - 0 = 255)\r\n        this.setWhitePoint(255, 255, 255, 255);\r\n    }\r\n\r\n    setWhitePoint(r : number, g : number, b : number, a : number) : void {\r\n        this._whitePoint  = {\r\n            r : (r > 0) ? 255 / r : 0,\r\n            g : (g > 0) ? 255 / g : 0,\r\n            b : (b > 0) ? 255 / b : 0,\r\n            a : (a > 0) ? 255 / a : 0\r\n        };\r\n        this._maxDistance = this.calculateRaw(r, g, b, a, 0, 0, 0, 0);\r\n    }\r\n\r\n    calculateNormalized(colorA : Point, colorB : Point) : number {\r\n        return this.calculateRaw(colorA.r, colorA.g, colorA.b, colorA.a, colorB.r, colorB.g, colorB.b, colorB.a) / this._maxDistance;\r\n    }\r\n\r\n    protected _setDefaults() : void {\r\n    }\r\n\r\n    /**\r\n     * Calculate raw distance (non-normalized)\r\n     */\r\n    abstract calculateRaw(r1 : number, g1 : number, b1 : number, a1 : number, r2 : number, g2 : number, b2 : number, a2 : number) : number;\r\n}\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/distance/abstractDistanceCalculator.ts\n **/","/**\r\n * @preserve\r\n * Copyright 2015-2016 Igor Bezkrovnyi\r\n * All rights reserved. (MIT Licensed)\r\n *\r\n * cie94.ts - part of Image Quantization Library\r\n */\r\nimport { AbstractDistanceCalculator } from \"./abstractDistanceCalculator\"\r\nimport { rgb2lab } from \"../conversion/rgb2lab\"\r\nimport { inRange0to255 } from \"../utils/arithmetic\"\r\n\r\n/**\r\n * CIE94 method of delta-e\r\n * http://en.wikipedia.org/wiki/Color_difference#CIE94\r\n */\r\nexport abstract class AbstractCIE94 extends AbstractDistanceCalculator {\r\n    /**\r\n     * Weight in distance: 0.25\r\n     * Max DeltaE: 100\r\n     * Max DeltaA: 255\r\n     */\r\n    protected _kA : number;\r\n    protected _Kl : number;\r\n    protected _K1 : number;\r\n    protected _K2 : number;\r\n\r\n    calculateRaw(r1 : number, g1 : number, b1 : number, a1 : number, r2 : number, g2 : number, b2 : number, a2 : number) : number {\r\n        const lab1 = rgb2lab(inRange0to255(r1 * this._whitePoint.r), inRange0to255(g1 * this._whitePoint.g), inRange0to255(b1 * this._whitePoint.b)),\r\n              lab2 = rgb2lab(inRange0to255(r2 * this._whitePoint.r), inRange0to255(g2 * this._whitePoint.g), inRange0to255(b2 * this._whitePoint.b));\r\n\r\n        const dL = lab1.L - lab2.L,\r\n              dA = lab1.a - lab2.a,\r\n              dB = lab1.b - lab2.b,\r\n              c1 = Math.sqrt(lab1.a * lab1.a + lab1.b * lab1.b),\r\n              c2 = Math.sqrt(lab2.a * lab2.a + lab2.b * lab2.b),\r\n              dC = c1 - c2;\r\n\r\n        let deltaH = dA * dA + dB * dB - dC * dC;\r\n        deltaH     = deltaH < 0 ? 0 : Math.sqrt(deltaH);\r\n\r\n        const dAlpha = (a2 - a1) * this._whitePoint.a * this._kA;\r\n\r\n        // TODO: add alpha channel support\r\n        return Math.sqrt(\r\n            Math.pow(dL / this._Kl, 2) +\r\n            Math.pow(dC / (1.0 + this._K1 * c1), 2) +\r\n            Math.pow(deltaH / (1.0 + this._K2 * c1), 2) +\r\n            Math.pow(dAlpha, 2)\r\n        );\r\n    }\r\n}\r\n\r\nexport class CIE94Textiles extends AbstractCIE94 {\r\n    protected _setDefaults() {\r\n        this._Kl = 2.0;\r\n        this._K1 = 0.048;\r\n        this._K2 = 0.014;\r\n        this._kA = 0.25 * 50 / 255;\r\n    }\r\n}\r\n\r\nexport class CIE94GraphicArts extends AbstractCIE94 {\r\n    protected _setDefaults() {\r\n        this._Kl = 1.0;\r\n        this._K1 = 0.045;\r\n        this._K2 = 0.015;\r\n        this._kA = 0.25 * 100 / 255;\r\n    }\r\n}\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/distance/cie94.ts\n **/","/**\r\n * @preserve\r\n * Copyright 2015-2016 Igor Bezkrovnyi\r\n * All rights reserved. (MIT Licensed)\r\n *\r\n * ciede2000.ts - part of Image Quantization Library\r\n */\r\nimport { AbstractDistanceCalculator } from \"./abstractDistanceCalculator\";\r\nimport { rgb2lab } from \"../conversion/rgb2lab\";\r\nimport { degrees2radians, inRange0to255 } from \"../utils/arithmetic\";\r\n\r\n/**\r\n * CIEDE2000 algorithm - Adapted from Sharma et al's MATLAB implementation at\r\n * http://www.ece.rochester.edu/~gsharma/ciede2000/\r\n */\r\nexport class CIEDE2000 extends AbstractDistanceCalculator {\r\n    /**\r\n     * Weight in distance: 0.25\r\n     * Max DeltaE: 100\r\n     * Max DeltaA: 255\r\n     */\r\n    private static readonly _kA                   = 0.25 * 100 / 255;\r\n    private static readonly _pow25to7 : number    = Math.pow(25, 7);\r\n    private static readonly _deg360InRad : number = degrees2radians(360);\r\n    private static readonly _deg180InRad : number = degrees2radians(180);\r\n    private static readonly _deg30InRad : number  = degrees2radians(30);\r\n    private static readonly _deg6InRad : number   = degrees2radians(6);\r\n    private static readonly _deg63InRad : number  = degrees2radians(63);\r\n    private static readonly _deg275InRad : number = degrees2radians(275);\r\n    private static readonly _deg25InRad : number  = degrees2radians(25);\r\n\r\n    calculateRaw(r1 : number, g1 : number, b1 : number, a1 : number, r2 : number, g2 : number, b2 : number, a2 : number) : number {\r\n        const lab1 = rgb2lab(inRange0to255(r1 * this._whitePoint.r), inRange0to255(g1 * this._whitePoint.g), inRange0to255(b1 * this._whitePoint.b)),\r\n              lab2 = rgb2lab(inRange0to255(r2 * this._whitePoint.r), inRange0to255(g2 * this._whitePoint.g), inRange0to255(b2 * this._whitePoint.b)),\r\n              dA   = (a2 - a1) * this._whitePoint.a * CIEDE2000._kA,\r\n              dE2  = this.calculateRawInLab(lab1, lab2);\r\n\r\n        return Math.sqrt(dE2 + dA * dA);\r\n    }\r\n\r\n    calculateRawInLab(Lab1 : {L : number; a : number; b : number}, Lab2 : {L : number; a : number; b : number}) : number {\r\n        // Get L,a,b values for color 1\r\n        const L1 = Lab1.L,\r\n              a1 = Lab1.a,\r\n              b1 = Lab1.b;\r\n\r\n        // Get L,a,b values for color 2\r\n        const L2 = Lab2.L,\r\n              a2 = Lab2.a,\r\n              b2 = Lab2.b;\r\n\r\n        // Calculate Cprime1, Cprime2, Cabbar\r\n        const C1                  = Math.sqrt(a1 * a1 + b1 * b1),\r\n              C2                  = Math.sqrt(a2 * a2 + b2 * b2),\r\n              pow_a_C1_C2_to_7    = Math.pow((C1 + C2) / 2.0, 7.0),\r\n\r\n              G                   = 0.5 * (1.0 - Math.sqrt(pow_a_C1_C2_to_7 / (pow_a_C1_C2_to_7 + CIEDE2000._pow25to7))), //25^7\r\n              a1p                 = (1.0 + G) * a1,\r\n              a2p                 = (1.0 + G) * a2,\r\n\r\n              C1p                 = Math.sqrt(a1p * a1p + b1 * b1),\r\n              C2p                 = Math.sqrt(a2p * a2p + b2 * b2),\r\n              C1pC2p              = C1p * C2p,\r\n\r\n              // Angles in Degree.\r\n              h1p                 = CIEDE2000._calculatehp(b1, a1p),\r\n              h2p                 = CIEDE2000._calculatehp(b2, a2p),\r\n              h_bar               = Math.abs(h1p - h2p),\r\n              dLp                 = L2 - L1,\r\n              dCp                 = C2p - C1p,\r\n              dHp                 = CIEDE2000._calculate_dHp(C1pC2p, h_bar, h2p, h1p),\r\n              ahp                 = CIEDE2000._calculate_ahp(C1pC2p, h_bar, h1p, h2p),\r\n\r\n              T                   = CIEDE2000._calculateT(ahp),\r\n\r\n              aCp                 = (C1p + C2p) / 2.0,\r\n              aLp_minus_50_square = Math.pow((L1 + L2) / 2.0 - 50.0, 2.0),\r\n              S_L                 = 1.0 + (.015 * aLp_minus_50_square) / Math.sqrt(20.0 + aLp_minus_50_square),\r\n              S_C                 = 1.0 + .045 * aCp,\r\n              S_H                 = 1.0 + .015 * T * aCp,\r\n\r\n              R_T                 = CIEDE2000._calculateRT(ahp, aCp),\r\n\r\n              dLpSL               = dLp / S_L, // S_L * kL, where kL is 1.0\r\n              dCpSC               = dCp / S_C, // S_C * kC, where kC is 1.0\r\n              dHpSH               = dHp / S_H; // S_H * kH, where kH is 1.0\r\n\r\n        return Math.pow(dLpSL, 2) + Math.pow(dCpSC, 2) + Math.pow(dHpSH, 2) + R_T * dCpSC * dHpSH;\r\n    }\r\n\r\n    private static _calculatehp(b : number, ap : number) {\r\n        const hp = Math.atan2(b, ap);\r\n        if (hp >= 0) return hp;\r\n        return hp + CIEDE2000._deg360InRad;\r\n    }\r\n\r\n    private static _calculateRT(ahp : number, aCp : number) {\r\n        const aCp_to_7    = Math.pow(aCp, 7.0),\r\n              R_C         = 2.0 * Math.sqrt(aCp_to_7 / (aCp_to_7 + CIEDE2000._pow25to7)), // 25^7\r\n              delta_theta = CIEDE2000._deg30InRad * Math.exp(-Math.pow((ahp - CIEDE2000._deg275InRad) / CIEDE2000._deg25InRad, 2.0));\r\n        return -Math.sin(2.0 * delta_theta) * R_C;\r\n    }\r\n\r\n    private static _calculateT(ahp : number) {\r\n        return 1.0 - .17 * Math.cos(ahp - CIEDE2000._deg30InRad) + .24 * Math.cos(ahp * 2.0) + .32 * Math.cos(ahp * 3.0 + CIEDE2000._deg6InRad) - .2 * Math.cos(ahp * 4.0 - CIEDE2000._deg63InRad);\r\n    }\r\n\r\n    private static _calculate_ahp(C1pC2p : number, h_bar : number, h1p : number, h2p : number) {\r\n        const hpSum = h1p + h2p;\r\n        if (C1pC2p == 0) return hpSum;\r\n        if (h_bar <= CIEDE2000._deg180InRad) return hpSum / 2.0;\r\n        if (hpSum < CIEDE2000._deg360InRad) return (hpSum + CIEDE2000._deg360InRad) / 2.0;\r\n        return (hpSum - CIEDE2000._deg360InRad) / 2.0;\r\n    }\r\n\r\n    private static _calculate_dHp(C1pC2p : number, h_bar : number, h2p : number, h1p : number) {\r\n        let dhp : number;\r\n        if (C1pC2p == 0) {\r\n            dhp = 0;\r\n        } else if (h_bar <= CIEDE2000._deg180InRad) {\r\n            dhp = h2p - h1p;\r\n        } else if (h2p <= h1p) {\r\n            dhp = h2p - h1p + CIEDE2000._deg360InRad;\r\n        } else {\r\n            dhp = h2p - h1p - CIEDE2000._deg360InRad;\r\n        }\r\n        return 2.0 * Math.sqrt(C1pC2p) * Math.sin(dhp / 2.0);\r\n    }\r\n}\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/distance/ciede2000.ts\n **/","/**\r\n * @preserve\r\n * Copyright 2015-2016 Igor Bezkrovnyi\r\n * All rights reserved. (MIT Licensed)\r\n *\r\n * cmetric.ts - part of Image Quantization Library\r\n */\r\nimport { AbstractDistanceCalculator } from \"./abstractDistanceCalculator\"\r\n\r\n/**\r\n * TODO: Name it: http://www.compuphase.com/cmetric.htm\r\n */\r\nexport class CMETRIC extends AbstractDistanceCalculator {\r\n    calculateRaw(r1 : number, g1 : number, b1 : number, a1 : number, r2 : number, g2 : number, b2 : number, a2 : number) : number {\r\n        const rmean = (r1 + r2) / 2 * this._whitePoint.r,\r\n              r     = (r1 - r2) * this._whitePoint.r,\r\n              g     = (g1 - g2) * this._whitePoint.g,\r\n              b     = (b1 - b2) * this._whitePoint.b,\r\n              dE    = ((((512 + rmean) * r * r) >> 8) + 4 * g * g + (((767 - rmean) * b * b) >> 8)),\r\n              dA    = (a2 - a1) * this._whitePoint.a;\r\n\r\n        return Math.sqrt(dE + dA * dA);\r\n    }\r\n}\r\n\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/distance/cmetric.ts\n **/","/**\r\n * @preserve\r\n * Copyright 2015-2016 Igor Bezkrovnyi\r\n * All rights reserved. (MIT Licensed)\r\n *\r\n * euclidean.ts - part of Image Quantization Library\r\n */\r\nimport { AbstractDistanceCalculator } from \"./abstractDistanceCalculator\"\r\nimport { Y } from \"../constants/bt709\"\r\n\r\n/**\r\n * Euclidean color distance\r\n */\r\nexport class AbstractEuclidean extends AbstractDistanceCalculator {\r\n    protected _kR : number;\r\n    protected _kG : number;\r\n    protected _kB : number;\r\n    protected _kA : number;\r\n\r\n    calculateRaw(r1 : number, g1 : number, b1 : number, a1 : number, r2 : number, g2 : number, b2 : number, a2 : number) : number {\r\n        const dR = r2 - r1, dG = g2 - g1, dB = b2 - b1, dA = a2 - a1;\r\n        return Math.sqrt(this._kR * dR * dR + this._kG * dG * dG + this._kB * dB * dB + this._kA * dA * dA);\r\n    }\r\n}\r\n\r\nexport class Euclidean extends AbstractEuclidean {\r\n    protected _setDefaults() {\r\n        this._kR = 1;\r\n        this._kG = 1;\r\n        this._kB = 1;\r\n        this._kA = 1;\r\n    }\r\n}\r\n\r\n/**\r\n * Euclidean color distance (RgbQuant modification w Alpha)\r\n */\r\nexport class EuclideanRgbQuantWithAlpha extends AbstractEuclidean {\r\n    protected _setDefaults() {\r\n        this._kR = Y.RED;\r\n        this._kG = Y.GREEN;\r\n        this._kB = Y.BLUE;\r\n        // TODO: what is the best coefficient below?\r\n        this._kA = 1;\r\n    }\r\n}\r\n\r\n/**\r\n * Euclidean color distance (RgbQuant modification w/o Alpha)\r\n */\r\nexport class EuclideanRgbQuantWOAlpha extends AbstractEuclidean {\r\n    protected _setDefaults() {\r\n        this._kR = Y.RED;\r\n        this._kG = Y.GREEN;\r\n        this._kB = Y.BLUE;\r\n        this._kA = 0;\r\n    }\r\n}\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/distance/euclidean.ts\n **/","/**\r\n * @preserve\r\n * Copyright 2015-2016 Igor Bezkrovnyi\r\n * All rights reserved. (MIT Licensed)\r\n *\r\n * manhattanNeuQuant.ts - part of Image Quantization Library\r\n */\r\nimport { AbstractDistanceCalculator } from \"./abstractDistanceCalculator\"\r\nimport { Y } from \"../constants/bt709\"\r\n\r\n/**\r\n * Manhattan distance (NeuQuant modification) - w/o sRGB coefficients\r\n */\r\nexport abstract class AbstractManhattan extends AbstractDistanceCalculator {\r\n    protected _kR : number;\r\n    protected _kG : number;\r\n    protected _kB : number;\r\n    protected _kA : number;\r\n\r\n    calculateRaw(r1 : number, g1 : number, b1 : number, a1 : number, r2 : number, g2 : number, b2 : number, a2 : number) : number {\r\n        let dR = r2 - r1, dG = g2 - g1, dB = b2 - b1, dA = a2 - a1;\r\n        if (dR < 0) dR = 0 - dR;\r\n        if (dG < 0) dG = 0 - dG;\r\n        if (dB < 0) dB = 0 - dB;\r\n        if (dA < 0) dA = 0 - dA;\r\n\r\n        return this._kR * dR + this._kG * dG + this._kB * dB + this._kA * dA;\r\n    }\r\n}\r\n\r\nexport class Manhattan extends AbstractManhattan {\r\n    protected _setDefaults() {\r\n        this._kR = 1;\r\n        this._kG = 1;\r\n        this._kB = 1;\r\n        this._kA = 1;\r\n    }\r\n}\r\n\r\n/**\r\n * Manhattan distance (Nommyde modification)\r\n * https://github.com/igor-bezkrovny/image-quantization/issues/4#issuecomment-235155320\r\n */\r\nexport class ManhattanNommyde extends AbstractManhattan {\r\n    protected _setDefaults() {\r\n        this._kR = 0.4984;\r\n        this._kG = 0.8625;\r\n        this._kB = 0.2979;\r\n        // TODO: what is the best coefficient below?\r\n        this._kA = 1;\r\n    }\r\n}\r\n\r\n/**\r\n * Manhattan distance (sRGB coefficients)\r\n */\r\nexport class ManhattanSRGB extends AbstractManhattan {\r\n    protected _setDefaults() {\r\n        this._kR = Y.RED;\r\n        this._kG = Y.GREEN;\r\n        this._kB = Y.BLUE;\r\n        // TODO: what is the best coefficient below?\r\n        this._kA = 1;\r\n    }\r\n}\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/distance/manhattan.ts\n **/","/**\r\n * @preserve\r\n * Copyright 2015-2016 Igor Bezkrovnyi\r\n * All rights reserved. (MIT Licensed)\r\n *\r\n * pngQuant.ts - part of Image Quantization Library\r\n */\r\nimport { AbstractDistanceCalculator } from \"./abstractDistanceCalculator\"\r\n\r\n/**\r\n * TODO: check quality of this distance equation\r\n * TODO: ask author for usage rights\r\n * taken from:\r\n * {@link http://stackoverflow.com/questions/4754506/color-similarity-distance-in-rgba-color-space/8796867#8796867}\r\n * {@link https://github.com/pornel/pngquant/blob/cc39b47799a7ff2ef17b529f9415ff6e6b213b8f/lib/pam.h#L148}\r\n */\r\nexport class PNGQUANT extends AbstractDistanceCalculator {\r\n    /**\r\n     * Author's comments\r\n     * px_b.rgb = px.rgb + 0*(1-px.a) // blend px on black\r\n     * px_b.a   = px.a   + 1*(1-px.a)\r\n     * px_w.rgb = px.rgb + 1*(1-px.a) // blend px on white\r\n     * px_w.a   = px.a   + 1*(1-px.a)\r\n\r\n     * px_b.rgb = px.rgb              // difference same as in opaque RGB\r\n     * px_b.a   = 1\r\n     * px_w.rgb = px.rgb - px.a       // difference simplifies to formula below\r\n     * px_w.a   = 1\r\n\r\n     * (px.rgb - px.a) - (py.rgb - py.a)\r\n     * (px.rgb - py.rgb) + (py.a - px.a)\r\n     *\r\n     */\r\n    calculateRaw(r1 : number, g1 : number, b1 : number, a1 : number, r2 : number, g2 : number, b2 : number, a2 : number) : number {\r\n        const alphas = (a2 - a1) * this._whitePoint.a;\r\n        return this._colordifference_ch(r1 * this._whitePoint.r, r2 * this._whitePoint.r, alphas) +\r\n            this._colordifference_ch(g1 * this._whitePoint.g, g2 * this._whitePoint.g, alphas) +\r\n            this._colordifference_ch(b1 * this._whitePoint.b, b2 * this._whitePoint.b, alphas);\r\n    }\r\n\r\n    private _colordifference_ch(x : number, y : number, alphas : number) {\r\n        // maximum of channel blended on white, and blended on black\r\n        // premultiplied alpha and backgrounds 0/1 shorten the formula\r\n        const black = x - y,\r\n              white = black + alphas;\r\n\r\n        return black * black + white * white;\r\n    }\r\n}\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/distance/pngQuant.ts\n **/","/**\r\n * @preserve\r\n * Copyright 2015-2016 Igor Bezkrovnyi\r\n * All rights reserved. (MIT Licensed)\r\n *\r\n * iq.ts - Image Quantization Library\r\n */\r\nimport { IPaletteQuantizer } from \"./common\"\r\nimport { NeuQuant } from \"./neuquant/neuquant\"\r\nimport { NeuQuantFloat } from \"./neuquant/neuquantFloat\"\r\nimport { RGBQuant } from \"./rgbquant/rgbquant\"\r\nimport { ColorHistogram } from \"./rgbquant/colorHistogram\"\r\nimport { WuQuant, WuColorCube } from \"./wu/wuQuant\"\r\n\r\nexport {\r\n    IPaletteQuantizer,\r\n\r\n    NeuQuant,\r\n    NeuQuantFloat,\r\n    RGBQuant,\r\n    WuQuant,\r\n\r\n    ColorHistogram,\r\n    WuColorCube\r\n}\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/palette/index.ts\n **/","/*\r\n * NeuQuant Neural-Net Quantization Algorithm\r\n * ------------------------------------------\r\n *\r\n * Copyright (c) 1994 Anthony Dekker\r\n *\r\n * NEUQUANT Neural-Net quantization algorithm by Anthony Dekker, 1994. See\r\n * \"Kohonen neural networks for optimal colour quantization\" in \"Network:\r\n * Computation in Neural Systems\" Vol. 5 (1994) pp 351-367. for a discussion of\r\n * the algorithm.\r\n *\r\n * Any party obtaining a copy of these files from the author, directly or\r\n * indirectly, is granted, free of charge, a full and unrestricted irrevocable,\r\n * world-wide, paid up, royalty-free, nonexclusive right and license to deal in\r\n * this software and documentation files (the \"Software\"), including without\r\n * limitation the rights to use, copy, modify, merge, publish, distribute,\r\n * sublicense, and/or sell copies of the Software, and to permit persons who\r\n * receive copies from any such party to do so, with the only requirement being\r\n * that this copyright notice remain intact.\r\n */\r\n\r\n/**\r\n * @preserve TypeScript port:\r\n * Copyright 2015-2016 Igor Bezkrovnyi\r\n * All rights reserved. (MIT Licensed)\r\n *\r\n * neuquant.ts - part of Image Quantization Library\r\n */\r\n\r\nimport { Palette } from \"../../utils/palette\"\r\nimport { Point } from \"../../utils/point\"\r\nimport { PointContainer } from \"../../utils/pointContainer\"\r\nimport { AbstractDistanceCalculator } from \"../../distance/abstractDistanceCalculator\"\r\nimport { IPaletteQuantizer } from \"../common\"\r\n\r\n// bias for colour values\r\nconst networkBiasShift = 3;\r\n\r\nclass Neuron {\r\n    r : number;\r\n    g : number;\r\n    b : number;\r\n    a : number;\r\n\r\n    constructor(defaultValue : number) {\r\n        this.r = this.g = this.b = this.a = defaultValue;\r\n    }\r\n\r\n    /**\r\n     * There is a fix in original NEUQUANT by Anthony Dekker (http://members.ozemail.com.au/~dekker/NEUQUANT.HTML)\r\n     * @example\r\n     * r = Math.min(255, (neuron.r + (1 << (networkBiasShift - 1))) >> networkBiasShift);\r\n     */\r\n    toPoint() : Point {\r\n        return Point.createByRGBA(this.r >> networkBiasShift, this.g >> networkBiasShift, this.b >> networkBiasShift, this.a >> networkBiasShift);\r\n    }\r\n\r\n    subtract(r : number, g : number, b : number, a : number) : void {\r\n        this.r -= r | 0;\r\n        this.g -= g | 0;\r\n        this.b -= b | 0;\r\n        this.a -= a | 0;\r\n    }\r\n\r\n    /*\r\n     public subtract(r : number, g : number, b : number, a : number) : void {\r\n     this.r = (-r + this.r) | 0;\r\n     this.g = (-g + this.g) | 0;\r\n     this.b = (-b + this.b) | 0;\r\n     this.a = (-a + this.a) | 0;\r\n\r\n     this.r -= r;\r\n     this.g -= g;\r\n     this.b -= b;\r\n     this.a -= a;\r\n\r\n     this.r -= r | 0;\r\n     this.g -= g | 0;\r\n     this.b -= b | 0;\r\n     this.a -= a | 0;\r\n     }\r\n     */\r\n}\r\n\r\nexport class NeuQuant implements IPaletteQuantizer {\r\n    /*\r\n     four primes near 500 - assume no image has a length so large\r\n     that it is divisible by all four primes\r\n     */\r\n    private static readonly _prime1 : number          = 499;\r\n    private static readonly _prime2 : number          = 491;\r\n    private static readonly _prime3 : number          = 487;\r\n    private static readonly _prime4 : number          = 503;\r\n    private static readonly _minpicturebytes : number = NeuQuant._prime4;\r\n\r\n    // no. of learning cycles\r\n    private static readonly _nCycles : number = 100;\r\n\r\n    // defs for freq and bias\r\n    private static readonly _initialBiasShift : number = 16;\r\n\r\n    // bias for fractions\r\n    private static readonly _initialBias : number = (1 << NeuQuant._initialBiasShift);\r\n    private static readonly _gammaShift : number  = 10;\r\n\r\n    // gamma = 1024\r\n    // TODO: why gamma is never used?\r\n    //private static _gamma : number     = (1 << NeuQuant._gammaShift);\r\n    private static readonly _betaShift : number = 10;\r\n    private static readonly _beta : number      = (NeuQuant._initialBias >> NeuQuant._betaShift);\r\n\r\n    // beta = 1/1024\r\n    private static readonly _betaGamma : number = (NeuQuant._initialBias << (NeuQuant._gammaShift - NeuQuant._betaShift));\r\n\r\n    /*\r\n     * for 256 cols, radius starts\r\n     */\r\n    private static readonly _radiusBiasShift : number = 6;\r\n\r\n    // at 32.0 biased by 6 bits\r\n    private static readonly _radiusBias : number = 1 << NeuQuant._radiusBiasShift;\r\n\r\n    // and decreases by a factor of 1/30 each cycle\r\n    private static readonly _radiusDecrease : number = 30;\r\n\r\n    /* defs for decreasing alpha factor */\r\n\r\n    // alpha starts at 1.0\r\n    private static readonly _alphaBiasShift : number = 10;\r\n\r\n    // biased by 10 bits\r\n    private static readonly _initAlpha : number = (1 << NeuQuant._alphaBiasShift);\r\n\r\n    /* radBias and alphaRadBias used for radpower calculation */\r\n    private static readonly _radBiasShift : number      = 8;\r\n    private static readonly _radBias : number           = 1 << NeuQuant._radBiasShift;\r\n    private static readonly _alphaRadBiasShift : number = NeuQuant._alphaBiasShift + NeuQuant._radBiasShift;\r\n    private static readonly _alphaRadBias : number      = 1 << NeuQuant._alphaRadBiasShift;\r\n\r\n    private _pointArray : Point[];\r\n    private readonly _networkSize : number;\r\n    private _network : Neuron[];\r\n\r\n    /** sampling factor 1..30 */\r\n    private readonly _sampleFactor : number;\r\n    private _radPower : number[];\r\n\r\n    // bias and freq arrays for learning\r\n    private _freq : number[];\r\n\r\n    /* for network lookup - really 256 */\r\n    private _bias : number[];\r\n    private readonly _distance : AbstractDistanceCalculator;\r\n\r\n    constructor(colorDistanceCalculator : AbstractDistanceCalculator, colors : number = 256) {\r\n        this._distance     = colorDistanceCalculator;\r\n        this._pointArray   = [];\r\n        this._sampleFactor = 1;\r\n        this._networkSize  = colors;\r\n\r\n        this._distance.setWhitePoint(255 << networkBiasShift, 255 << networkBiasShift, 255 << networkBiasShift, 255 << networkBiasShift);\r\n    }\r\n\r\n    sample(pointBuffer : PointContainer) : void {\r\n        this._pointArray = this._pointArray.concat(pointBuffer.getPointArray());\r\n    }\r\n\r\n    quantize() : Palette {\r\n        this._init();\r\n        this._learn();\r\n\r\n        return this._buildPalette();\r\n    }\r\n\r\n    private _init() : void {\r\n        this._freq     = [];\r\n        this._bias     = [];\r\n        this._radPower = [];\r\n        this._network  = [];\r\n        for (let i = 0; i < this._networkSize; i++) {\r\n            this._network[ i ] = new Neuron((i << (networkBiasShift + 8)) / this._networkSize | 0);\r\n\r\n            // 1/this._networkSize\r\n            this._freq[ i ] = NeuQuant._initialBias / this._networkSize | 0;\r\n            this._bias[ i ] = 0;\r\n        }\r\n    }\r\n\r\n    /**\r\n     * Main Learning Loop\r\n     */\r\n    private _learn() : void {\r\n        let sampleFactor   = this._sampleFactor;\r\n        const pointsNumber = this._pointArray.length;\r\n        if (pointsNumber < NeuQuant._minpicturebytes) sampleFactor = 1;\r\n\r\n        const alphadec       = 30 + (sampleFactor - 1) / 3 | 0,\r\n              pointsToSample = pointsNumber / sampleFactor | 0;\r\n\r\n        let delta  = pointsToSample / NeuQuant._nCycles | 0,\r\n            alpha  = NeuQuant._initAlpha,\r\n            radius = (this._networkSize >> 3) * NeuQuant._radiusBias;\r\n\r\n        let rad = radius >> NeuQuant._radiusBiasShift;\r\n        if (rad <= 1) rad = 0;\r\n\r\n        for (let i = 0; i < rad; i++) {\r\n            this._radPower[ i ] = alpha * (((rad * rad - i * i) * NeuQuant._radBias) / (rad * rad)) >>> 0;\r\n        }\r\n\r\n        let step : number;\r\n        if (pointsNumber < NeuQuant._minpicturebytes) {\r\n            step = 1;\r\n        } else if (pointsNumber % NeuQuant._prime1 != 0) {\r\n            step = NeuQuant._prime1;\r\n        } else if ((pointsNumber % NeuQuant._prime2) != 0) {\r\n            step = NeuQuant._prime2;\r\n        } else if ((pointsNumber % NeuQuant._prime3) != 0) {\r\n            step = NeuQuant._prime3;\r\n        } else {\r\n            step = NeuQuant._prime4;\r\n        }\r\n\r\n        for (let i = 0, pointIndex = 0; i < pointsToSample;) {\r\n            const point       = this._pointArray[ pointIndex ],\r\n                  b           = point.b << networkBiasShift,\r\n                  g           = point.g << networkBiasShift,\r\n                  r           = point.r << networkBiasShift,\r\n                  a           = point.a << networkBiasShift,\r\n                  neuronIndex = this._contest(b, g, r, a);\r\n\r\n            this._alterSingle(alpha, neuronIndex, b, g, r, a);\r\n            if (rad !== 0) this._alterNeighbour(rad, neuronIndex, b, g, r, a);\r\n\r\n            /* alter neighbours */\r\n            pointIndex += step;\r\n            if (pointIndex >= pointsNumber) pointIndex -= pointsNumber;\r\n            i++;\r\n\r\n            if (delta === 0) delta = 1;\r\n\r\n            if (i % delta === 0) {\r\n                alpha -= (alpha / alphadec) | 0;\r\n                radius -= (radius / NeuQuant._radiusDecrease) | 0;\r\n                rad = radius >> NeuQuant._radiusBiasShift;\r\n\r\n                if (rad <= 1) rad = 0;\r\n                for (let j = 0; j < rad; j++) this._radPower[ j ] = alpha * (((rad * rad - j * j) * NeuQuant._radBias) / (rad * rad)) >>> 0;\r\n            }\r\n        }\r\n    }\r\n\r\n    private _buildPalette() : Palette {\r\n        const palette = new Palette();\r\n\r\n        this._network.forEach(neuron => {\r\n            palette.add(neuron.toPoint());\r\n        });\r\n\r\n        palette.sort();\r\n        return palette;\r\n    }\r\n\r\n    /**\r\n     * Move adjacent neurons by precomputed alpha*(1-((i-j)^2/[r]^2)) in radpower[|i-j|]\r\n     */\r\n    private _alterNeighbour(rad : number, i : number, b : number, g : number, r : number, al : number) : void {\r\n        let lo = i - rad;\r\n        if (lo < -1) lo = -1;\r\n\r\n        let hi = i + rad;\r\n        if (hi > this._networkSize) hi = this._networkSize;\r\n\r\n        let j = i + 1,\r\n            k = i - 1,\r\n            m = 1;\r\n\r\n        while (j < hi || k > lo) {\r\n            const a = this._radPower[ m++ ] / NeuQuant._alphaRadBias;\r\n            if (j < hi) {\r\n                const p = this._network[ j++ ];\r\n                p.subtract(\r\n                    a * (p.r - r),\r\n                    a * (p.g - g),\r\n                    a * (p.b - b),\r\n                    a * (p.a - al)\r\n                );\r\n            }\r\n\r\n            if (k > lo) {\r\n                const p = this._network[ k-- ];\r\n                p.subtract(\r\n                    a * (p.r - r),\r\n                    a * (p.g - g),\r\n                    a * (p.b - b),\r\n                    a * (p.a - al)\r\n                );\r\n            }\r\n        }\r\n    }\r\n\r\n    /**\r\n     * Move neuron i towards biased (b,g,r) by factor alpha\r\n     */\r\n    private _alterSingle(alpha : number, i : number, b : number, g : number, r : number, a : number) : void {\r\n        alpha /= NeuQuant._initAlpha;\r\n\r\n        /* alter hit neuron */\r\n        const n = this._network[ i ];\r\n        n.subtract(\r\n            alpha * (n.r - r),\r\n            alpha * (n.g - g),\r\n            alpha * (n.b - b),\r\n            alpha * (n.a - a)\r\n        );\r\n    }\r\n\r\n    /**\r\n     * Search for biased BGR values\r\n     * description:\r\n     *    finds closest neuron (min dist) and updates freq\r\n     *    finds best neuron (min dist-bias) and returns position\r\n     *    for frequently chosen neurons, freq[i] is high and bias[i] is negative\r\n     *    bias[i] = _gamma*((1/this._networkSize)-freq[i])\r\n     *\r\n     * Original distance equation:\r\n     *        dist = abs(dR) + abs(dG) + abs(dB)\r\n     */\r\n    private _contest(b : number, g : number, r : number, a : number) : number {\r\n        const multiplier = (255 * 4) << networkBiasShift;\r\n\r\n        let bestd       = ~(1 << 31),\r\n            bestbiasd   = bestd,\r\n            bestpos     = -1,\r\n            bestbiaspos = bestpos;\r\n\r\n        for (let i = 0; i < this._networkSize; i++) {\r\n            const n    = this._network[ i ],\r\n                  dist = this._distance.calculateNormalized(<any>n, <any>{ r, g, b, a }) * multiplier | 0;\r\n\r\n            if (dist < bestd) {\r\n                bestd   = dist;\r\n                bestpos = i;\r\n            }\r\n\r\n            const biasdist = dist - ((this._bias[ i ]) >> (NeuQuant._initialBiasShift - networkBiasShift));\r\n            if (biasdist < bestbiasd) {\r\n                bestbiasd   = biasdist;\r\n                bestbiaspos = i;\r\n            }\r\n            const betafreq = (this._freq[ i ] >> NeuQuant._betaShift);\r\n            this._freq[ i ] -= betafreq;\r\n            this._bias[ i ] += (betafreq << NeuQuant._gammaShift);\r\n        }\r\n        this._freq[ bestpos ] += NeuQuant._beta;\r\n        this._bias[ bestpos ] -= NeuQuant._betaGamma;\r\n        return bestbiaspos;\r\n    }\r\n}\r\n\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/palette/neuquant/neuquant.ts\n **/","/**\r\n * @preserve\r\n * Copyright 2015-2016 Igor Bezkrovnyi\r\n * All rights reserved. (MIT Licensed)\r\n *\r\n * palette.ts - part of Image Quantization Library\r\n */\r\n\r\nimport { Point } from \"./point\"\r\nimport { PointContainer } from \"./pointContainer\"\r\nimport { AbstractDistanceCalculator } from \"../distance/abstractDistanceCalculator\"\r\nimport { rgb2hsl } from \"../conversion/rgb2hsl\"\r\n\r\n// TODO: make paletteArray via pointBuffer, so, export will be available via pointBuffer.exportXXX\r\n\r\nconst hueGroups : number = 10;\r\n\r\nexport function hueGroup(hue : number, segmentsNumber : number) {\r\n    const maxHue = 360,\r\n          seg    = maxHue / segmentsNumber,\r\n          half   = seg / 2;\r\n\r\n    for (let i = 1, mid = seg - half; i < segmentsNumber; i++, mid += seg) {\r\n        if (hue >= mid && hue < mid + seg) return i;\r\n    }\r\n    return 0;\r\n}\r\n\r\nexport class Palette {\r\n    private readonly _pointContainer : PointContainer;\r\n    private readonly _pointArray : Point[]          = [];\r\n    private _i32idx : { [ key : string ] : number } = {};\r\n\r\n    constructor() {\r\n        this._pointContainer = new PointContainer();\r\n        this._pointContainer.setHeight(1);\r\n        this._pointArray = this._pointContainer.getPointArray();\r\n    }\r\n\r\n    add(color : Point) {\r\n        this._pointArray.push(color);\r\n        this._pointContainer.setWidth(this._pointArray.length);\r\n    }\r\n\r\n    has(color : Point) {\r\n        for (let i = this._pointArray.length - 1; i >= 0; i--) {\r\n            if (color.uint32 === this._pointArray[ i ].uint32) return true;\r\n        }\r\n\r\n        return false;\r\n    }\r\n\r\n    // TOTRY: use HUSL - http://boronine.com/husl/ http://www.husl-colors.org/ https://github.com/husl-colors/husl\r\n    getNearestColor(colorDistanceCalculator : AbstractDistanceCalculator, color : Point) : Point {\r\n        return this._pointArray[ this.getNearestIndex(colorDistanceCalculator, color) | 0 ];\r\n    }\r\n\r\n    getPointContainer() : PointContainer {\r\n        return this._pointContainer;\r\n    }\r\n\r\n    // TOTRY: use HUSL - http://boronine.com/husl/\r\n    /*\r\n     public nearestIndexByUint32(i32) {\r\n     var idx : number = this._nearestPointFromCache(\"\" + i32);\r\n     if (idx >= 0) return idx;\r\n\r\n     var min = 1000,\r\n     rgb = [\r\n     (i32 & 0xff),\r\n     (i32 >>> 8) & 0xff,\r\n     (i32 >>> 16) & 0xff,\r\n     (i32 >>> 24) & 0xff\r\n     ],\r\n     len = this._pointArray.length;\r\n\r\n     idx = 0;\r\n     for (var i = 0; i < len; i++) {\r\n     var dist = Utils.distEuclidean(rgb, this._pointArray[i].rgba);\r\n\r\n     if (dist < min) {\r\n     min = dist;\r\n     idx = i;\r\n     }\r\n     }\r\n\r\n     this._i32idx[i32] = idx;\r\n     return idx;\r\n     }\r\n     */\r\n\r\n    private _nearestPointFromCache(key : string) {\r\n        return typeof this._i32idx[ key ] === \"number\" ? this._i32idx[ key ] : -1;\r\n    }\r\n\r\n    private getNearestIndex(colorDistanceCalculator : AbstractDistanceCalculator, point : Point) : number {\r\n        let idx : number = this._nearestPointFromCache(\"\" + point.uint32);\r\n        if (idx >= 0) return idx;\r\n\r\n        let minimalDistance : number = Number.MAX_VALUE;\r\n\r\n        idx = 0;\r\n        for (let i = 0, l = this._pointArray.length; i < l; i++) {\r\n            const p        = this._pointArray[ i ],\r\n                  distance = colorDistanceCalculator.calculateRaw(point.r, point.g, point.b, point.a, p.r, p.g, p.b, p.a);\r\n\r\n            if (distance < minimalDistance) {\r\n                minimalDistance = distance;\r\n                idx             = i;\r\n            }\r\n        }\r\n\r\n        this._i32idx[ point.uint32 ] = idx;\r\n        return idx;\r\n    }\r\n\r\n    /*\r\n     public reduce(histogram : ColorHistogram, colors : number) {\r\n     if (this._pointArray.length > colors) {\r\n     var idxi32 = histogram.getImportanceSortedColorsIDXI32();\r\n\r\n     // quantize histogram to existing palette\r\n     var keep = [], uniqueColors = 0, idx, pruned = false;\r\n\r\n     for (var i = 0, len = idxi32.length; i < len; i++) {\r\n     // palette length reached, unset all remaining colors (sparse palette)\r\n     if (uniqueColors >= colors) {\r\n     this.prunePal(keep);\r\n     pruned = true;\r\n     break;\r\n     } else {\r\n     idx = this.nearestIndexByUint32(idxi32[i]);\r\n     if (keep.indexOf(idx) < 0) {\r\n     keep.push(idx);\r\n     uniqueColors++;\r\n     }\r\n     }\r\n     }\r\n\r\n     if (!pruned) {\r\n     this.prunePal(keep);\r\n     }\r\n     }\r\n     }\r\n\r\n     // TODO: check usage, not tested!\r\n     public prunePal(keep : number[]) {\r\n     var colors = this._pointArray.length;\r\n     for (var colorIndex = colors - 1; colorIndex >= 0; colorIndex--) {\r\n     if (keep.indexOf(colorIndex) < 0) {\r\n\r\n     if(colorIndex + 1 < colors) {\r\n     this._pointArray[ colorIndex ] = this._pointArray [ colors - 1 ];\r\n     }\r\n     --colors;\r\n     //this._pointArray[colorIndex] = null;\r\n     }\r\n     }\r\n     console.log(\"colors pruned: \" + (this._pointArray.length - colors));\r\n     this._pointArray.length = colors;\r\n     this._i32idx = {};\r\n     }\r\n     */\r\n\r\n    // TODO: group very low lum and very high lum colors\r\n    // TODO: pass custom sort order\r\n    // TODO: sort criteria function should be placed to HueStats class\r\n    sort() {\r\n        this._i32idx = {};\r\n        this._pointArray.sort((a : Point, b : Point) => {\r\n            const hslA = rgb2hsl(a.r, a.g, a.b),\r\n                  hslB = rgb2hsl(b.r, b.g, b.b);\r\n\r\n            // sort all grays + whites together\r\n            const hueA = (a.r === a.g && a.g === a.b) ? 0 : 1 + hueGroup(hslA.h, hueGroups),\r\n                  hueB = (b.r === b.g && b.g === b.b) ? 0 : 1 + hueGroup(hslB.h, hueGroups);\r\n            /*\r\n             var hueA = (a.r === a.g && a.g === a.b) ? 0 : 1 + Utils.hueGroup(hslA.h, hueGroups);\r\n             var hueB = (b.r === b.g && b.g === b.b) ? 0 : 1 + Utils.hueGroup(hslB.h, hueGroups);\r\n             */\r\n\r\n            const hueDiff = hueB - hueA;\r\n            if (hueDiff) return -hueDiff;\r\n\r\n            /*\r\n             var lumDiff = Utils.lumGroup(+hslB.l.toFixed(2)) - Utils.lumGroup(+hslA.l.toFixed(2));\r\n             if (lumDiff) return -lumDiff;\r\n             */\r\n            const lA = a.getLuminosity(true),\r\n                  lB = b.getLuminosity(true);\r\n\r\n            if (lB - lA !== 0) return lB - lA;\r\n\r\n            const satDiff = ((hslB.s * 100) | 0) - ((hslA.s * 100) | 0);\r\n            if (satDiff) return -satDiff;\r\n\r\n            return 0;\r\n        });\r\n    }\r\n}\r\n\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/utils/palette.ts\n **/","/**\r\n * @preserve\r\n * Copyright 2015-2016 Igor Bezkrovnyi\r\n * All rights reserved. (MIT Licensed)\r\n *\r\n * pointContainer.ts - part of Image Quantization Library\r\n */\r\nimport { Point } from \"./point\"\r\n\r\n/**\r\n * v8 optimizations done.\r\n * fromXXX methods are static to move out polymorphic code from class instance itself.\r\n */\r\nexport class PointContainer {\r\n    private readonly _pointArray : Point[];\r\n    private _width : number;\r\n    private _height : number;\r\n\r\n    constructor() {\r\n        this._width      = 0;\r\n        this._height     = 0;\r\n        this._pointArray = [];\r\n    }\r\n\r\n    getWidth() : number {\r\n        return this._width;\r\n    }\r\n\r\n    getHeight() : number {\r\n        return this._height;\r\n    }\r\n\r\n    setWidth(width : number) : void {\r\n        this._width = width;\r\n    }\r\n\r\n    setHeight(height : number) : void {\r\n        this._height = height;\r\n    }\r\n\r\n    getPointArray() : Point[] {\r\n        return this._pointArray;\r\n    }\r\n\r\n    clone() : PointContainer {\r\n        const clone   = new PointContainer();\r\n        clone._width  = this._width;\r\n        clone._height = this._height;\r\n\r\n        for (let i = 0, l = this._pointArray.length; i < l; i++) {\r\n            clone._pointArray[ i ] = Point.createByUint32(this._pointArray[ i ].uint32 | 0); // \"| 0\" is added for v8 optimization\r\n        }\r\n\r\n        return clone;\r\n    }\r\n\r\n    toUint32Array() : Uint32Array {\r\n        const l           = this._pointArray.length,\r\n              uint32Array = new Uint32Array(l);\r\n\r\n        for (let i = 0; i < l; i++) {\r\n            uint32Array[ i ] = this._pointArray[ i ].uint32;\r\n        }\r\n\r\n        return uint32Array;\r\n    }\r\n\r\n    toUint8Array() : Uint8Array {\r\n        return new Uint8Array(this.toUint32Array().buffer);\r\n    }\r\n\r\n    static fromHTMLImageElement(img : HTMLImageElement) : PointContainer {\r\n        const width  = img.naturalWidth,\r\n              height = img.naturalHeight;\r\n\r\n        const canvas  = document.createElement(\"canvas\");\r\n        canvas.width  = width;\r\n        canvas.height = height;\r\n\r\n        const ctx = <CanvasRenderingContext2D>canvas.getContext(\"2d\");\r\n        ctx.drawImage(img, 0, 0, width, height, 0, 0, width, height);\r\n\r\n        return PointContainer.fromHTMLCanvasElement(canvas);\r\n    }\r\n\r\n    static fromHTMLCanvasElement(canvas : HTMLCanvasElement) : PointContainer {\r\n        const width  = canvas.width,\r\n              height = canvas.height;\r\n\r\n        const ctx     = <CanvasRenderingContext2D>canvas.getContext(\"2d\"),\r\n              imgData = ctx.getImageData(0, 0, width, height);\r\n\r\n        return PointContainer.fromImageData(imgData);\r\n    }\r\n\r\n    static fromNodeCanvas(canvas : any) : PointContainer {\r\n        return PointContainer.fromHTMLCanvasElement(canvas);\r\n    }\r\n\r\n    static fromImageData(imageData : ImageData) : PointContainer {\r\n        const width  = imageData.width,\r\n              height = imageData.height;\r\n\r\n        return PointContainer.fromCanvasPixelArray(imageData.data, width, height);\r\n        /*\r\n         var buf8;\r\n         if (Utils.typeOf(imageData.data) == \"CanvasPixelArray\")\r\n         buf8 = new Uint8Array(imageData.data);\r\n         else\r\n         buf8 = imageData.data;\r\n\r\n         this.fromUint32Array(new Uint32Array(buf8.buffer), width, height);\r\n         */\r\n    }\r\n\r\n    static fromArray(byteArray : number[], width : number, height : number) : PointContainer {\r\n        const uint8array = new Uint8Array(byteArray);\r\n        return PointContainer.fromUint8Array(uint8array, width, height);\r\n    }\r\n\r\n    static fromCanvasPixelArray(data : any, width : number, height : number) : PointContainer {\r\n        return PointContainer.fromArray(data, width, height);\r\n    }\r\n\r\n    static fromUint8Array(uint8array : Uint8Array, width : number, height : number) : PointContainer {\r\n        return PointContainer.fromUint32Array(new Uint32Array(uint8array.buffer), width, height);\r\n    }\r\n\r\n    static fromUint32Array(uint32array : Uint32Array, width : number, height : number) : PointContainer {\r\n        const container = new PointContainer();\r\n\r\n        container._width  = width;\r\n        container._height = height;\r\n\r\n        for (let i = 0, l = uint32array.length; i < l; i++) {\r\n            container._pointArray[ i ] = Point.createByUint32(uint32array[ i ] | 0); // \"| 0\" is added for v8 optimization\r\n        }\r\n\r\n        return container;\r\n    }\r\n}\r\n\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/utils/pointContainer.ts\n **/","/**\r\n * @preserve\r\n * Copyright 2015-2016 Igor Bezkrovnyi\r\n * All rights reserved. (MIT Licensed)\r\n *\r\n * point.ts - part of Image Quantization Library\r\n */\r\nimport { Y } from \"../constants/bt709\"\r\n\r\n/**\r\n * v8 optimized class\r\n * 1) \"constructor\" should have initialization with worst types\r\n * 2) \"set\" should have |0 / >>> 0\r\n */\r\nexport class Point {\r\n    r : number;\r\n    g : number;\r\n    b : number;\r\n    a : number;\r\n    uint32 : number;\r\n    rgba : number[]; // TODO: better name is quadruplet or quad may be?\r\n    Lab : { L : number; a : number; b : number };\r\n\r\n    static createByQuadruplet(quadruplet : number[]) : Point {\r\n        const point : Point = new Point();\r\n\r\n        point.r = quadruplet[ 0 ] | 0;\r\n        point.g = quadruplet[ 1 ] | 0;\r\n        point.b = quadruplet[ 2 ] | 0;\r\n        point.a = quadruplet[ 3 ] | 0;\r\n        point._loadUINT32();\r\n        point._loadQuadruplet();\r\n        //point._loadLab();\r\n        return point;\r\n    }\r\n\r\n    static createByRGBA(red : number, green : number, blue : number, alpha : number) : Point {\r\n        const point : Point = new Point();\r\n\r\n        point.r = red | 0;\r\n        point.g = green | 0;\r\n        point.b = blue | 0;\r\n        point.a = alpha | 0;\r\n        point._loadUINT32();\r\n        point._loadQuadruplet();\r\n        //point._loadLab();\r\n        return point;\r\n    }\r\n\r\n    static createByUint32(uint32 : number) : Point {\r\n        const point : Point = new Point();\r\n\r\n        point.uint32 = uint32 >>> 0;\r\n        point._loadRGBA();\r\n        point._loadQuadruplet();\r\n        //point._loadLab();\r\n        return point;\r\n    }\r\n\r\n    constructor() {\r\n        this.uint32 = -1 >>> 0;\r\n        this.r      = this.g = this.b = this.a = 0;\r\n        this.rgba = new Array(4);\r\n        /*[ this.r , this.g , this.b , this.a ]*/\r\n        this.rgba[ 0 ] = 0;\r\n        this.rgba[ 1 ] = 0;\r\n        this.rgba[ 2 ] = 0;\r\n        this.rgba[ 3 ] = 0;\r\n        /*\r\n         this.Lab = {\r\n         L : 0.0,\r\n         a : 0.0,\r\n         b : 0.0\r\n         };\r\n         */\r\n    }\r\n\r\n    from(point : Point) {\r\n        this.r         = point.r;\r\n        this.g         = point.g;\r\n        this.b         = point.b;\r\n        this.a         = point.a;\r\n        this.uint32    = point.uint32;\r\n        this.rgba[ 0 ] = point.r;\r\n        this.rgba[ 1 ] = point.g;\r\n        this.rgba[ 2 ] = point.b;\r\n        this.rgba[ 3 ] = point.a;\r\n\r\n        /*\r\n         this.Lab.L = point.Lab.L;\r\n         this.Lab.a = point.Lab.a;\r\n         this.Lab.b = point.Lab.b;\r\n         */\r\n    }\r\n\r\n    /*\r\n     * TODO:\r\n     Luminance from RGB:\r\n\r\n     Luminance (standard for certain colour spaces): (0.2126*R + 0.7152*G + 0.0722*B) [1]\r\n     Luminance (perceived option 1): (0.299*R + 0.587*G + 0.114*B) [2]\r\n     Luminance (perceived option 2, slower to calculate):  sqrt( 0.241*R^2 + 0.691*G^2 + 0.068*B^2 ) ? sqrt( 0.299*R^2 + 0.587*G^2 + 0.114*B^2 ) (thanks to @MatthewHerbst) [http://alienryderflex.com/hsp.html]\r\n     */\r\n    getLuminosity(useAlphaChannel : boolean) : number {\r\n        let r = this.r,\r\n            g = this.g,\r\n            b = this.b;\r\n\r\n        if (useAlphaChannel) {\r\n            r = Math.min(255, 255 - this.a + this.a * r / 255);\r\n            g = Math.min(255, 255 - this.a + this.a * g / 255);\r\n            b = Math.min(255, 255 - this.a + this.a * b / 255);\r\n        }\r\n\r\n        //var luma = this.r * Point._RED_COEFFICIENT + this.g * Point._GREEN_COEFFICIENT + this.b * Point._BLUE_COEFFICIENT;\r\n\r\n        /*\r\n         if(useAlphaChannel) {\r\n         luma = (luma * (255 - this.a)) / 255;\r\n         }\r\n         */\r\n\r\n        return r * Y.RED + g * Y.GREEN + b * Y.BLUE;\r\n    }\r\n\r\n    private _loadUINT32() {\r\n        this.uint32 = (this.a << 24 | this.b << 16 | this.g << 8 | this.r) >>> 0;\r\n    }\r\n\r\n    private _loadRGBA() {\r\n        this.r = this.uint32 & 0xff;\r\n        this.g = (this.uint32 >>> 8) & 0xff;\r\n        this.b = (this.uint32 >>> 16) & 0xff;\r\n        this.a = (this.uint32 >>> 24) & 0xff;\r\n    }\r\n\r\n    private _loadQuadruplet() {\r\n        this.rgba[ 0 ] = this.r;\r\n        this.rgba[ 1 ] = this.g;\r\n        this.rgba[ 2 ] = this.b;\r\n        this.rgba[ 3 ] = this.a;\r\n\r\n        /*\r\n         var xyz = rgb2xyz(this.r, this.g, this.b);\r\n         var lab = xyz2lab(xyz.x, xyz.y, xyz.z);\r\n         this.lab.l = lab.l;\r\n         this.lab.a = lab.a;\r\n         this.lab.b = lab.b;\r\n         */\r\n    }\r\n\r\n    /*\r\n     private _loadLab() : void {\r\n     var Lab = Color.Conversion.rgb2lab(this.r, this.g, this.b);\r\n     this.Lab.L = Lab.L;\r\n     this.Lab.a = Lab.a;\r\n     this.Lab.b = Lab.b;\r\n     }\r\n     */\r\n}\r\n\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/utils/point.ts\n **/","/*\r\n * NeuQuantFloat Neural-Net Quantization Algorithm\r\n * ------------------------------------------\r\n *\r\n * Copyright (c) 1994 Anthony Dekker\r\n *\r\n * NEUQUANT Neural-Net quantization algorithm by Anthony Dekker, 1994. See\r\n * \"Kohonen neural networks for optimal colour quantization\" in \"Network:\r\n * Computation in Neural Systems\" Vol. 5 (1994) pp 351-367. for a discussion of\r\n * the algorithm.\r\n *\r\n * Any party obtaining a copy of these files from the author, directly or\r\n * indirectly, is granted, free of charge, a full and unrestricted irrevocable,\r\n * world-wide, paid up, royalty-free, nonexclusive right and license to deal in\r\n * this software and documentation files (the \"Software\"), including without\r\n * limitation the rights to use, copy, modify, merge, publish, distribute,\r\n * sublicense, and/or sell copies of the Software, and to permit persons who\r\n * receive copies from any such party to do so, with the only requirement being\r\n * that this copyright notice remain intact.\r\n */\r\n/**\r\n * @preserve TypeScript port:\r\n * Copyright 2015-2016 Igor Bezkrovnyi\r\n * All rights reserved. (MIT Licensed)\r\n *\r\n * neuquant.ts - part of Image Quantization Library\r\n */\r\nimport { Palette } from \"../../utils/palette\"\r\nimport { Point } from \"../../utils/point\"\r\nimport { PointContainer } from \"../../utils/pointContainer\"\r\nimport { AbstractDistanceCalculator } from \"../../distance/abstractDistanceCalculator\"\r\nimport { IPaletteQuantizer } from \"../common\"\r\n\r\n// bias for colour values\r\nconst networkBiasShift = 3;\r\n\r\nclass NeuronFloat {\r\n    r : number;\r\n    g : number;\r\n    b : number;\r\n    a : number;\r\n\r\n    constructor(defaultValue : number) {\r\n        this.r = this.g = this.b = this.a = defaultValue;\r\n    }\r\n\r\n    /**\r\n     * There is a fix in original NEUQUANT by Anthony Dekker (http://members.ozemail.com.au/~dekker/NEUQUANT.HTML)\r\n     * @example\r\n     * r = Math.min(255, (neuron.r + (1 << (networkBiasShift - 1))) >> networkBiasShift);\r\n     */\r\n    toPoint() : Point {\r\n        return Point.createByRGBA(this.r >> networkBiasShift, this.g >> networkBiasShift, this.b >> networkBiasShift, this.a >> networkBiasShift);\r\n    }\r\n\r\n    subtract(r : number, g : number, b : number, a : number) : void {\r\n        this.r -= r;\r\n        this.g -= g;\r\n        this.b -= b;\r\n        this.a -= a;\r\n    }\r\n}\r\n\r\nexport class NeuQuantFloat implements IPaletteQuantizer {\r\n    /*\r\n     four primes near 500 - assume no image has a length so large\r\n     that it is divisible by all four primes\r\n     */\r\n    private static readonly _prime1 : number          = 499;\r\n    private static readonly _prime2 : number          = 491;\r\n    private static readonly _prime3 : number          = 487;\r\n    private static readonly _prime4 : number          = 503;\r\n    private static readonly _minpicturebytes : number = NeuQuantFloat._prime4;\r\n\r\n    // no. of learning cycles\r\n    private static readonly _nCycles : number = 100;\r\n\r\n    // defs for freq and bias\r\n    private static readonly _initialBiasShift : number = 16;\r\n\r\n    // bias for fractions\r\n    private static readonly _initialBias : number = (1 << NeuQuantFloat._initialBiasShift);\r\n    private static readonly _gammaShift : number  = 10;\r\n\r\n    // gamma = 1024\r\n    // TODO: why gamma is never used?\r\n    //private static _gamma : number     = (1 << NeuQuantFloat._gammaShift);\r\n    private static readonly _betaShift : number = 10;\r\n    private static readonly _beta : number      = (NeuQuantFloat._initialBias >> NeuQuantFloat._betaShift);\r\n\r\n    // beta = 1/1024\r\n    private static readonly _betaGamma : number = (NeuQuantFloat._initialBias << (NeuQuantFloat._gammaShift - NeuQuantFloat._betaShift));\r\n\r\n    /*\r\n     * for 256 cols, radius starts\r\n     */\r\n    private static readonly _radiusBiasShift : number = 6;\r\n\r\n    // at 32.0 biased by 6 bits\r\n    private static readonly _radiusBias : number = 1 << NeuQuantFloat._radiusBiasShift;\r\n\r\n    // and decreases by a factor of 1/30 each cycle\r\n    private static readonly _radiusDecrease : number = 30;\r\n\r\n    /* defs for decreasing alpha factor */\r\n\r\n    // alpha starts at 1.0\r\n    private static readonly _alphaBiasShift : number = 10;\r\n\r\n    // biased by 10 bits\r\n    private static readonly _initAlpha : number = (1 << NeuQuantFloat._alphaBiasShift);\r\n\r\n    /* radBias and alphaRadBias used for radpower calculation */\r\n    private static readonly _radBiasShift : number      = 8;\r\n    private static readonly _radBias : number           = 1 << NeuQuantFloat._radBiasShift;\r\n    private static readonly _alphaRadBiasShift : number = NeuQuantFloat._alphaBiasShift + NeuQuantFloat._radBiasShift;\r\n    private static readonly _alphaRadBias : number      = 1 << NeuQuantFloat._alphaRadBiasShift;\r\n\r\n    private _pointArray : Point[];\r\n    private readonly _networkSize : number;\r\n    private _network : NeuronFloat[];\r\n\r\n    /** sampling factor 1..30 */\r\n    private readonly _sampleFactor : number;\r\n    private _radPower : number[];\r\n\r\n    // bias and freq arrays for learning\r\n    private _freq : number[];\r\n\r\n    /* for network lookup - really 256 */\r\n    private _bias : number[];\r\n    private readonly _distance : AbstractDistanceCalculator;\r\n\r\n    constructor(colorDistanceCalculator : AbstractDistanceCalculator, colors : number = 256) {\r\n        this._distance     = colorDistanceCalculator;\r\n        this._pointArray   = [];\r\n        this._sampleFactor = 1;\r\n        this._networkSize  = colors;\r\n\r\n        this._distance.setWhitePoint(255 << networkBiasShift, 255 << networkBiasShift, 255 << networkBiasShift, 255 << networkBiasShift);\r\n    }\r\n\r\n    sample(pointBuffer : PointContainer) : void {\r\n        this._pointArray = this._pointArray.concat(pointBuffer.getPointArray());\r\n    }\r\n\r\n    quantize() : Palette {\r\n        this._init();\r\n        this._learn();\r\n\r\n        return this._buildPalette();\r\n    }\r\n\r\n    private _init() : void {\r\n        this._freq     = [];\r\n        this._bias     = [];\r\n        this._radPower = [];\r\n        this._network  = [];\r\n        for (let i = 0; i < this._networkSize; i++) {\r\n            this._network[ i ] = new NeuronFloat((i << (networkBiasShift + 8)) / this._networkSize);\r\n\r\n            // 1/this._networkSize\r\n            this._freq[ i ] = NeuQuantFloat._initialBias / this._networkSize;\r\n            this._bias[ i ] = 0;\r\n        }\r\n    }\r\n\r\n    /**\r\n     * Main Learning Loop\r\n     */\r\n    private _learn() : void {\r\n        let sampleFactor = this._sampleFactor;\r\n\r\n        let pointsNumber = this._pointArray.length;\r\n        if (pointsNumber < NeuQuantFloat._minpicturebytes) sampleFactor = 1;\r\n\r\n        const alphadec       = 30 + (sampleFactor - 1) / 3,\r\n              pointsToSample = pointsNumber / sampleFactor;\r\n\r\n        let delta  = pointsToSample / NeuQuantFloat._nCycles | 0,\r\n            alpha  = NeuQuantFloat._initAlpha,\r\n            radius = (this._networkSize >> 3) * NeuQuantFloat._radiusBias;\r\n\r\n        let rad = radius >> NeuQuantFloat._radiusBiasShift;\r\n        if (rad <= 1) rad = 0;\r\n\r\n        for (let i = 0; i < rad; i++) {\r\n            this._radPower[ i ] = alpha * (((rad * rad - i * i) * NeuQuantFloat._radBias) / (rad * rad));\r\n        }\r\n\r\n        let step : number;\r\n        if (pointsNumber < NeuQuantFloat._minpicturebytes) {\r\n            step = 1;\r\n        } else if (pointsNumber % NeuQuantFloat._prime1 != 0) {\r\n            step = NeuQuantFloat._prime1;\r\n        } else if ((pointsNumber % NeuQuantFloat._prime2) != 0) {\r\n            step = NeuQuantFloat._prime2;\r\n        } else if ((pointsNumber % NeuQuantFloat._prime3) != 0) {\r\n            step = NeuQuantFloat._prime3;\r\n        } else {\r\n            step = NeuQuantFloat._prime4;\r\n        }\r\n\r\n        for (let i = 0, pointIndex = 0; i < pointsToSample;) {\r\n            const point       = this._pointArray[ pointIndex ],\r\n                  b           = point.b << networkBiasShift,\r\n                  g           = point.g << networkBiasShift,\r\n                  r           = point.r << networkBiasShift,\r\n                  a           = point.a << networkBiasShift,\r\n                  neuronIndex = this._contest(b, g, r, a);\r\n\r\n            this._alterSingle(alpha, neuronIndex, b, g, r, a);\r\n            if (rad != 0) this._alterNeighbour(rad, neuronIndex, b, g, r, a);\r\n\r\n            /* alter neighbours */\r\n            pointIndex += step;\r\n            if (pointIndex >= pointsNumber) pointIndex -= pointsNumber;\r\n            i++;\r\n\r\n            if (delta == 0) delta = 1;\r\n\r\n            if (i % delta == 0) {\r\n                alpha -= (alpha / alphadec);\r\n                radius -= (radius / NeuQuantFloat._radiusDecrease);\r\n                rad = radius >> NeuQuantFloat._radiusBiasShift;\r\n\r\n                if (rad <= 1) rad = 0;\r\n                for (let j = 0; j < rad; j++) this._radPower[ j ] = alpha * (((rad * rad - j * j) * NeuQuantFloat._radBias) / (rad * rad));\r\n            }\r\n        }\r\n\r\n    }\r\n\r\n    private _buildPalette() : Palette {\r\n        const palette = new Palette();\r\n\r\n        this._network.forEach(neuron => {\r\n            palette.add(neuron.toPoint());\r\n        });\r\n\r\n        palette.sort();\r\n        return palette;\r\n    }\r\n\r\n    /**\r\n     * Move adjacent neurons by precomputed alpha*(1-((i-j)^2/[r]^2)) in radpower[|i-j|]\r\n     */\r\n    private _alterNeighbour(rad : number, i : number, b : number, g : number, r : number, al : number) : void {\r\n        let lo = i - rad;\r\n        if (lo < -1) lo = -1;\r\n\r\n        let hi = i + rad;\r\n        if (hi > this._networkSize) hi = this._networkSize;\r\n\r\n        let j = i + 1,\r\n            k = i - 1,\r\n            m = 1;\r\n\r\n        while (j < hi || k > lo) {\r\n            const a = this._radPower[ m++ ] / NeuQuantFloat._alphaRadBias;\r\n            if (j < hi) {\r\n                const p = this._network[ j++ ];\r\n                p.subtract(\r\n                    a * (p.r - r),\r\n                    a * (p.g - g),\r\n                    a * (p.b - b),\r\n                    a * (p.a - al)\r\n                );\r\n            }\r\n\r\n            if (k > lo) {\r\n                const p = this._network[ k-- ];\r\n                p.subtract(\r\n                    a * (p.r - r),\r\n                    a * (p.g - g),\r\n                    a * (p.b - b),\r\n                    a * (p.a - al)\r\n                );\r\n            }\r\n        }\r\n    }\r\n\r\n    /**\r\n     * Move neuron i towards biased (b,g,r) by factor alpha\r\n     */\r\n    private _alterSingle(alpha : number, i : number, b : number, g : number, r : number, a : number) : void {\r\n        alpha /= NeuQuantFloat._initAlpha;\r\n\r\n        /* alter hit neuron */\r\n        const n = this._network[ i ];\r\n        n.subtract(\r\n            alpha * (n.r - r),\r\n            alpha * (n.g - g),\r\n            alpha * (n.b - b),\r\n            alpha * (n.a - a)\r\n        );\r\n    }\r\n\r\n    /**\r\n     * Search for biased BGR values\r\n     * description:\r\n     *    finds closest neuron (min dist) and updates freq\r\n     *    finds best neuron (min dist-bias) and returns position\r\n     *    for frequently chosen neurons, freq[i] is high and bias[i] is negative\r\n     *    bias[i] = _gamma*((1/this._networkSize)-freq[i])\r\n     *\r\n     * Original distance equation:\r\n     *        dist = abs(dR) + abs(dG) + abs(dB)\r\n     */\r\n    private _contest(b : number, g : number, r : number, al : number) : number {\r\n        const multiplier = (255 * 4) << networkBiasShift;\r\n\r\n        let bestd       = ~(1 << 31),\r\n            bestbiasd   = bestd,\r\n            bestpos     = -1,\r\n            bestbiaspos = bestpos;\r\n\r\n        for (let i = 0; i < this._networkSize; i++) {\r\n            const n    = this._network[ i ],\r\n                  dist = this._distance.calculateNormalized(<any>n, <any>{ r : r, g : g, b : b, a : al }) * multiplier;\r\n\r\n            if (dist < bestd) {\r\n                bestd   = dist;\r\n                bestpos = i;\r\n            }\r\n\r\n            const biasdist = dist - ((this._bias[ i ]) >> (NeuQuantFloat._initialBiasShift - networkBiasShift));\r\n            if (biasdist < bestbiasd) {\r\n                bestbiasd   = biasdist;\r\n                bestbiaspos = i;\r\n            }\r\n            const betafreq = (this._freq[ i ] >> NeuQuantFloat._betaShift);\r\n            this._freq[ i ] -= betafreq;\r\n            this._bias[ i ] += (betafreq << NeuQuantFloat._gammaShift);\r\n        }\r\n        this._freq[ bestpos ] += NeuQuantFloat._beta;\r\n        this._bias[ bestpos ] -= NeuQuantFloat._betaGamma;\r\n        return bestbiaspos;\r\n    }\r\n}\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/palette/neuquant/neuquantFloat.ts\n **/","/*\r\n * Copyright (c) 2015, Leon Sorokin\r\n * All rights reserved. (MIT Licensed)\r\n *\r\n * RgbQuant.js - an image quantization lib\r\n */\r\n\r\n/**\r\n * @preserve TypeScript port:\r\n * Copyright 2015-2016 Igor Bezkrovnyi\r\n * All rights reserved. (MIT Licensed)\r\n *\r\n * rgbquant.ts - part of Image Quantization Library\r\n */\r\n\r\nimport { Palette } from \"../../utils/palette\"\r\nimport { Point } from \"../../utils/point\"\r\nimport { PointContainer } from \"../../utils/pointContainer\"\r\nimport { AbstractDistanceCalculator } from \"../../distance/abstractDistanceCalculator\"\r\nimport { ColorHistogram } from \"./colorHistogram\"\r\nimport { IPaletteQuantizer } from \"../common\"\r\nimport { stableSort } from \"../../utils/arithmetic\"\r\n\r\nclass RemovedColor {\r\n    readonly index : number;\r\n    readonly color : Point;\r\n    readonly distance : number;\r\n\r\n    constructor(index : number, color : Point, distance : number) {\r\n        this.index    = index;\r\n        this.color    = color;\r\n        this.distance = distance;\r\n    }\r\n}\r\n\r\n// TODO: make input/output image and input/output palettes with instances of class Point only!\r\nexport class RGBQuant implements IPaletteQuantizer {\r\n    // desired final palette size\r\n    private readonly _colors : number;\r\n\r\n    // color-distance threshold for initial reduction pass\r\n    private readonly _initialDistance : number;\r\n\r\n    // subsequent passes threshold\r\n    private readonly _distanceIncrement : number;\r\n\r\n    // accumulated histogram\r\n    private readonly _histogram : ColorHistogram;\r\n    private readonly _distance : AbstractDistanceCalculator;\r\n\r\n    constructor(colorDistanceCalculator : AbstractDistanceCalculator, colors : number = 256, method : number = 2) {\r\n        this._distance = colorDistanceCalculator;\r\n        // desired final palette size\r\n        this._colors   = colors;\r\n\r\n        // histogram to accumulate\r\n        this._histogram = new ColorHistogram(method, colors);\r\n\r\n        this._initialDistance   = 0.01;\r\n        this._distanceIncrement = 0.005;\r\n    }\r\n\r\n    // gathers histogram info\r\n    sample(image : PointContainer) : void {\r\n        /*\r\n         var pointArray = image.getPointArray(), max = [0, 0, 0, 0], min = [255, 255, 255, 255];\r\n\r\n         for (var i = 0, l = pointArray.length; i < l; i++) {\r\n         var color = pointArray[i];\r\n         for (var componentIndex = 0; componentIndex < 4; componentIndex++) {\r\n         if (max[componentIndex] < color.rgba[componentIndex]) max[componentIndex] = color.rgba[componentIndex];\r\n         if (min[componentIndex] > color.rgba[componentIndex]) min[componentIndex] = color.rgba[componentIndex];\r\n         }\r\n         }\r\n         var rd = max[0] - min[0], gd = max[1] - min[1], bd = max[2] - min[2], ad = max[3] - min[3];\r\n         this._distance.setWhitePoint(rd, gd, bd, ad);\r\n\r\n         this._initialDistance = (Math.sqrt(rd * rd + gd * gd + bd * bd + ad * ad) / Math.sqrt(255 * 255 + 255 * 255 + 255 * 255)) * 0.01;\r\n         */\r\n\r\n        this._histogram.sample(image);\r\n    }\r\n\r\n    // reduces histogram to palette, remaps & memoizes reduced colors\r\n    quantize() : Palette {\r\n        const idxi32 = this._histogram.getImportanceSortedColorsIDXI32()\r\n        if (idxi32.length === 0) {\r\n            throw new Error(\"No colors in image\")\r\n        }\r\n\r\n        const palette = this._buildPalette(idxi32);\r\n\r\n        palette.sort();\r\n        return palette;\r\n    }\r\n\r\n    // reduces similar colors from an importance-sorted Uint32 rgba array\r\n    private _buildPalette(idxi32 : number[]) : Palette {\r\n        // reduce histogram to create initial palette\r\n        // build full rgb palette\r\n        const palette    = new Palette(),\r\n              colorArray = palette.getPointContainer().getPointArray(),\r\n              usageArray = new Array(idxi32.length);\r\n\r\n        for (let i = 0; i < idxi32.length; i++) {\r\n            colorArray.push(Point.createByUint32(idxi32[ i ]));\r\n            usageArray[ i ] = 1;\r\n        }\r\n\r\n        const len                      = colorArray.length,\r\n              memDist : RemovedColor[] = [];\r\n\r\n        let palLen = len,\r\n            thold  = this._initialDistance;\r\n\r\n        // palette already at or below desired length\r\n        while (palLen > this._colors) {\r\n            memDist.length = 0;\r\n\r\n            // iterate palette\r\n            for (let i = 0; i < len; i++) {\r\n                if (usageArray[ i ] === 0) continue;\r\n                const pxi = colorArray[ i ];\r\n                //if (!pxi) continue;\r\n\r\n                for (let j = i + 1; j < len; j++) {\r\n                    if (usageArray[ j ] === 0) continue;\r\n                    const pxj = colorArray[ j ];\r\n                    //if (!pxj) continue;\r\n\r\n                    const dist = this._distance.calculateNormalized(pxi, pxj);\r\n                    if (dist < thold) {\r\n                        // store index,rgb,dist\r\n                        memDist.push(new RemovedColor(j, pxj, dist));\r\n                        usageArray[ j ] = 0;\r\n                        palLen--;\r\n                    }\r\n                }\r\n            }\r\n            // palette reduction pass\r\n            // console.log(\"palette length: \" + palLen);\r\n\r\n            // if palette is still much larger than target, increment by larger initDist\r\n            thold += (palLen > this._colors * 3) ? this._initialDistance : this._distanceIncrement;\r\n        }\r\n\r\n        // if palette is over-reduced, re-add removed colors with largest distances from last round\r\n        if (palLen < this._colors) {\r\n            // sort descending\r\n            stableSort(memDist, function (a : RemovedColor, b : RemovedColor) {\r\n                return b.distance - a.distance;\r\n            });\r\n\r\n            let k = 0;\r\n            while (palLen < this._colors && k < memDist.length) {\r\n                const removedColor               = memDist[ k ];\r\n                // re-inject rgb into final palette\r\n                usageArray[ removedColor.index ] = 1;\r\n                palLen++;\r\n                k++;\r\n            }\r\n        }\r\n\r\n        let colors = colorArray.length;\r\n        for (let colorIndex = colors - 1; colorIndex >= 0; colorIndex--) {\r\n            if (usageArray[ colorIndex ] === 0) {\r\n                if (colorIndex !== colors - 1) {\r\n                    colorArray[ colorIndex ] = colorArray[ colors - 1 ];\r\n                }\r\n                --colors;\r\n            }\r\n        }\r\n        colorArray.length = colors;\r\n\r\n        return palette;\r\n    }\r\n\r\n}\r\n\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/palette/rgbquant/rgbquant.ts\n **/","/*\r\n * Copyright (c) 2015, Leon Sorokin\r\n * All rights reserved. (MIT Licensed)\r\n *\r\n * ColorHistogram.js - an image quantization lib\r\n */\r\n\r\n/**\r\n * @preserve TypeScript port:\r\n * Copyright 2015-2016 Igor Bezkrovnyi\r\n * All rights reserved. (MIT Licensed)\r\n *\r\n * colorHistogram.ts - part of Image Quantization Library\r\n */\r\nimport { HueStatistics } from \"../../utils/hueStatistics\"\r\nimport { PointContainer } from \"../../utils/pointContainer\"\r\nimport { stableSort } from \"../../utils/arithmetic\"\r\n\r\ninterface Box {\r\n    x : number,\r\n    y : number,\r\n    h : number,\r\n    w : number\r\n}\r\n\r\nexport class ColorHistogram {\r\n    private static _boxSize   = [ 64, 64 ];\r\n    private static _boxPixels = 2;\r\n    private static _hueGroups = 10;\r\n\r\n    // 1 = by global population, 2 = subregion population threshold\r\n    private _method : number;\r\n\r\n    // HueStatistics instance\r\n    private _hueStats : HueStatistics;\r\n\r\n    private _histogram : {[color : string] : number};\r\n\r\n    // # of highest-frequency colors to start with for palette reduction\r\n    private _initColors : number;\r\n\r\n    // if > 0, enables hues stats and min-color retention per group\r\n    private _minHueCols : number;\r\n\r\n    constructor(method : number, colors : number) {\r\n        // 1 = by global population, 2 = subregion population threshold\r\n        this._method = method;\r\n\r\n        // if > 0, enables hues stats and min-color retention per group\r\n        this._minHueCols = colors << 2;//opts.minHueCols || 0;\r\n\r\n        // # of highest-frequency colors to start with for palette reduction\r\n        this._initColors = colors << 2;\r\n\r\n        // HueStatistics instance\r\n        this._hueStats = new HueStatistics(ColorHistogram._hueGroups, this._minHueCols);\r\n\r\n        this._histogram = Object.create(null);\r\n    }\r\n\r\n    sample(pointBuffer : PointContainer) : void {\r\n        switch (this._method) {\r\n            case 1:\r\n                this._colorStats1D(pointBuffer);\r\n                break;\r\n            case 2:\r\n                this._colorStats2D(pointBuffer);\r\n                break;\r\n        }\r\n    }\r\n\r\n    getImportanceSortedColorsIDXI32() {\r\n        // TODO: fix typing issue in stableSort func\r\n        const sorted = stableSort(Object.keys(this._histogram), (a, b) => this._histogram[ b ] - this._histogram[ a ]);\r\n        if (sorted.length === 0) {\r\n            return [];\r\n        }\r\n\r\n        let idxi32 : string[];\r\n        switch (this._method) {\r\n            case 1:\r\n                const initialColorsLimit = Math.min(sorted.length, this._initColors),\r\n                      last               = sorted[ initialColorsLimit - 1 ],\r\n                      freq               = this._histogram[ last ];\r\n\r\n                idxi32 = sorted.slice(0, initialColorsLimit);\r\n\r\n                // add any cut off colors with same freq as last\r\n                let pos = initialColorsLimit, len = sorted.length;\r\n                while (pos < len && this._histogram[ sorted[ pos ] ] == freq)\r\n                    idxi32.push(sorted[ pos++ ]);\r\n\r\n                // inject min huegroup colors\r\n                this._hueStats.injectIntoArray(idxi32);\r\n                break;\r\n\r\n            case 2:\r\n                idxi32 = sorted;\r\n                break;\r\n\r\n            default:\r\n                // TODO: rethink errors\r\n                throw new Error(\"Incorrect method\")\r\n        }\r\n\r\n        // int32-ify values\r\n        return (<string[]><any>idxi32).map(function (v : string) {\r\n            return +v;\r\n        });\r\n    }\r\n\r\n    // global top-population\r\n    private _colorStats1D(pointBuffer : PointContainer) {\r\n        const histG      = this._histogram,\r\n              pointArray = pointBuffer.getPointArray(),\r\n              len        = pointArray.length;\r\n\r\n        for (let i = 0; i < len; i++) {\r\n            const col = pointArray[ i ].uint32;\r\n\r\n            // collect hue stats\r\n            this._hueStats.check(col);\r\n\r\n            if (col in histG)\r\n                histG[ col ]++;\r\n            else\r\n                histG[ col ] = 1;\r\n        }\r\n    }\r\n\r\n    // population threshold within subregions\r\n    // FIXME: this can over-reduce (few/no colors same?), need a way to keep\r\n    // important colors that dont ever reach local thresholds (gradients?)\r\n    private _colorStats2D(pointBuffer : PointContainer) {\r\n        const width      = pointBuffer.getWidth(),\r\n              height     = pointBuffer.getHeight(),\r\n              pointArray = pointBuffer.getPointArray();\r\n\r\n        const boxW  = ColorHistogram._boxSize[ 0 ],\r\n              boxH  = ColorHistogram._boxSize[ 1 ],\r\n              area  = boxW * boxH,\r\n              boxes = this._makeBoxes(width, height, boxW, boxH),\r\n              histG = this._histogram;\r\n\r\n        boxes.forEach(box => {\r\n            let effc = Math.round((box.w * box.h) / area) * ColorHistogram._boxPixels;\r\n            if (effc < 2) effc = 2;\r\n\r\n            const histL : { [key : string ] : number} = {};\r\n            this._iterateBox(box, width, (i : number) => {\r\n                const col = pointArray[ i ].uint32;\r\n\r\n                // collect hue stats\r\n                this._hueStats.check(col);\r\n\r\n                if (col in histG)\r\n                    histG[ col ]++;\r\n                else if (col in histL) {\r\n                    if (++histL[ col ] >= effc)\r\n                        histG[ col ] = histL[ col ];\r\n                }\r\n                else\r\n                    histL[ col ] = 1;\r\n            });\r\n        });\r\n\r\n        // inject min huegroup colors\r\n        this._hueStats.injectIntoDictionary(histG);\r\n\r\n    }\r\n\r\n    // iterates @bbox within a parent rect of width @wid; calls @fn, passing index within parent\r\n    private _iterateBox(bbox : Box, wid : number, fn : Function) {\r\n        const b    = bbox,\r\n              i0   = b.y * wid + b.x,\r\n              i1   = (b.y + b.h - 1) * wid + (b.x + b.w - 1),\r\n              incr = wid - b.w + 1;\r\n\r\n        let cnt = 0,\r\n            i   = i0;\r\n\r\n        do {\r\n            fn.call(this, i);\r\n            i += (++cnt % b.w == 0) ? incr : 1;\r\n        } while (i <= i1);\r\n    }\r\n\r\n    /**\r\n     *    partitions a rectangle of width x height into\r\n     *    array of boxes stepX x stepY (or less)\r\n     */\r\n    private _makeBoxes(width : number, height : number, stepX : number, stepY : number) {\r\n        const wrem               = width % stepX,\r\n              hrem               = height % stepY,\r\n              xend               = width - wrem,\r\n              yend               = height - hrem,\r\n              boxesArray : Box[] = [];\r\n\r\n        for (let y = 0; y < height; y += stepY)\r\n            for (let x = 0; x < width; x += stepX)\r\n                boxesArray.push({ x, y, w : (x == xend ? wrem : stepX), h : (y == yend ? hrem : stepY) });\r\n\r\n        return boxesArray;\r\n    }\r\n\r\n}\r\n\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/palette/rgbquant/colorHistogram.ts\n **/","/**\r\n * @preserve\r\n * Copyright 2015-2016 Igor Bezkrovnyi\r\n * All rights reserved. (MIT Licensed)\r\n *\r\n * hueStatistics.ts - part of Image Quantization Library\r\n */\r\nimport { rgb2hsl } from \"../conversion/rgb2hsl\"\r\nimport { hueGroup } from \"./palette\"\r\n\r\nclass HueGroup {\r\n    num : number    = 0;\r\n    cols : number[] = [];\r\n}\r\n\r\nexport class HueStatistics {\r\n    private _numGroups : number;\r\n    private _minCols : number;\r\n    private _stats : HueGroup[];\r\n    private _groupsFull : number;\r\n\r\n    constructor(numGroups : number, minCols : number) {\r\n        this._numGroups = numGroups;\r\n        this._minCols   = minCols;\r\n        this._stats     = [];\r\n\r\n        for (let i = 0; i <= numGroups; i++) {\r\n            this._stats[ i ] = new HueGroup();\r\n        }\r\n\r\n        this._groupsFull = 0;\r\n    }\r\n\r\n    check(i32 : number) {\r\n        if (this._groupsFull == this._numGroups + 1) {\r\n            this.check = function () {\r\n            };\r\n        }\r\n\r\n        const r   = (i32 & 0xff),\r\n              g   = (i32 >>> 8) & 0xff,\r\n              b   = (i32 >>> 16) & 0xff,\r\n              hg  = (r == g && g == b) ? 0 : 1 + hueGroup(rgb2hsl(r, g, b).h, this._numGroups),\r\n              gr  = this._stats[ hg ],\r\n              min = this._minCols;\r\n\r\n        gr.num++;\r\n\r\n        if (gr.num > min)\r\n            return;\r\n        if (gr.num == min)\r\n            this._groupsFull++;\r\n\r\n        if (gr.num <= min)\r\n            this._stats[ hg ].cols.push(i32);\r\n    }\r\n\r\n    injectIntoDictionary(histG : { [key : string ] : number}) {\r\n        for (let i = 0; i <= this._numGroups; i++) {\r\n            if (this._stats[ i ].num <= this._minCols) {\r\n                this._stats[ i ].cols.forEach((col : number) => {\r\n                    if (!histG[ col ])\r\n                        histG[ col ] = 1;\r\n                    else\r\n                        histG[ col ]++;\r\n                });\r\n            }\r\n        }\r\n    }\r\n\r\n    injectIntoArray(histG : string[]) {\r\n        for (let i = 0; i <= this._numGroups; i++) {\r\n            if (this._stats[ i ].num <= this._minCols) {\r\n                this._stats[ i ].cols.forEach((col : any) => {\r\n                    if (histG.indexOf(col) == -1)\r\n                        histG.push(col);\r\n                });\r\n            }\r\n        }\r\n    }\r\n}\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/utils/hueStatistics.ts\n **/","/**\r\n * @preserve\r\n * Copyright 2015-2016 Igor Bezkrovnyi\r\n * All rights reserved. (MIT Licensed)\r\n *\r\n * wuQuant.ts - part of Image Quantization Library\r\n */\r\nimport { Palette } from \"../../utils/palette\"\r\nimport { Point } from \"../../utils/point\"\r\nimport { PointContainer } from \"../../utils/pointContainer\"\r\nimport { AbstractDistanceCalculator } from \"../../distance/abstractDistanceCalculator\"\r\n\r\nfunction createArray1D(dimension1 : number) {\r\n    const a : number[] = [];\r\n    for (let k = 0; k < dimension1; k++) {\r\n        a[ k ] = 0;\r\n    }\r\n    return a;\r\n}\r\n\r\nfunction createArray4D(dimension1 : number, dimension2 : number, dimension3 : number, dimension4 : number) : number[][][][] {\r\n    const a = new Array(dimension1);\r\n    for (let i = 0; i < dimension1; i++) {\r\n        a[ i ] = new Array(dimension2);\r\n        for (let j = 0; j < dimension2; j++) {\r\n            a[ i ][ j ] = new Array(dimension3);\r\n            for (let k = 0; k < dimension3; k++) {\r\n                a[ i ][ j ][ k ] = new Array(dimension4);\r\n                for (let l = 0; l < dimension4; l++) {\r\n                    a[ i ][ j ][ k ][ l ] = 0;\r\n                }\r\n            }\r\n        }\r\n    }\r\n    return a;\r\n}\r\n\r\nfunction createArray3D(dimension1 : number, dimension2 : number, dimension3 : number) : number[][][] {\r\n    const a = new Array(dimension1);\r\n    for (let i = 0; i < dimension1; i++) {\r\n        a[ i ] = new Array(dimension2);\r\n        for (let j = 0; j < dimension2; j++) {\r\n            a[ i ][ j ] = new Array(dimension3);\r\n            for (let k = 0; k < dimension3; k++) {\r\n                a[ i ][ j ][ k ] = 0;\r\n            }\r\n        }\r\n    }\r\n    return a;\r\n}\r\n\r\nfunction fillArray3D<T>(a : T[][][], dimension1 : number, dimension2 : number, dimension3 : number, value : T) : void {\r\n    for (let i = 0; i < dimension1; i++) {\r\n        a[ i ] = [];\r\n        for (let j = 0; j < dimension2; j++) {\r\n            a[ i ][ j ] = [];\r\n            for (let k = 0; k < dimension3; k++) {\r\n                a[ i ][ j ][ k ] = value;\r\n            }\r\n        }\r\n    }\r\n}\r\n\r\nfunction fillArray1D<T>(a : T[], dimension1 : number, value : T) : void {\r\n    for (let i = 0; i < dimension1; i++) {\r\n        a[ i ] = value;\r\n    }\r\n}\r\n\r\nexport class WuColorCube {\r\n    redMinimum : number;\r\n    redMaximum : number;\r\n    greenMinimum : number;\r\n    greenMaximum : number;\r\n    blueMinimum : number;\r\n    blueMaximum : number;\r\n    volume : number;\r\n    alphaMinimum : number;\r\n    alphaMaximum : number;\r\n}\r\n\r\nexport class WuQuant {\r\n\r\n    private static readonly alpha = 3;\r\n    private static readonly red   = 2;\r\n    private static readonly green = 1;\r\n    private static readonly blue  = 0;\r\n\r\n    private _reds : number[];\r\n    private _greens : number[];\r\n    private _blues : number[];\r\n    private _alphas : number[];\r\n    private _sums : number[];\r\n\r\n    private _weights : number[][][][];\r\n    private _momentsRed : number[][][][];\r\n    private _momentsGreen : number[][][][];\r\n    private _momentsBlue : number[][][][];\r\n    private _momentsAlpha : number[][][][];\r\n    private _moments : number[][][][];\r\n\r\n    private _table : number[];\r\n    private _pixels : Point[];\r\n\r\n    private _cubes : WuColorCube[];\r\n    private _colors : number;\r\n\r\n    private _significantBitsPerChannel : number;\r\n    private _maxSideIndex : number;\r\n    private _alphaMaxSideIndex : number;\r\n    private _sideSize : number;\r\n    private _alphaSideSize : number;\r\n\r\n    private readonly _distance : AbstractDistanceCalculator;\r\n\r\n    constructor(colorDistanceCalculator : AbstractDistanceCalculator, colors : number = 256, significantBitsPerChannel : number = 5) {\r\n        this._distance = colorDistanceCalculator;\r\n        this._setQuality(significantBitsPerChannel);\r\n        this._initialize(colors);\r\n    }\r\n\r\n    sample(image : PointContainer) : void {\r\n        const pointArray = image.getPointArray();\r\n\r\n        for (let i = 0, l = pointArray.length; i < l; i++) {\r\n            this._addColor(pointArray[ i ]);\r\n        }\r\n\r\n        this._pixels = this._pixels.concat(pointArray);\r\n    }\r\n\r\n    quantize() : Palette {\r\n        this._preparePalette();\r\n\r\n        const palette : Palette = new Palette();\r\n\r\n        // generates palette\r\n        for (let paletteIndex = 0; paletteIndex < this._colors; paletteIndex++) {\r\n            if (this._sums[ paletteIndex ] > 0) {\r\n                const sum = this._sums[ paletteIndex ],\r\n                      r   = this._reds[ paletteIndex ] / sum,\r\n                      g   = this._greens[ paletteIndex ] / sum,\r\n                      b   = this._blues[ paletteIndex ] / sum,\r\n                      a   = this._alphas[ paletteIndex ] / sum;\r\n\r\n                const color = Point.createByRGBA(r | 0, g | 0, b | 0, a | 0);\r\n                palette.add(color);\r\n            }\r\n        }\r\n\r\n        palette.sort();\r\n        return palette;\r\n    }\r\n\r\n    private _preparePalette() : void {\r\n        // preprocess the colors\r\n        this._calculateMoments();\r\n\r\n        let next           = 0,\r\n            volumeVariance = createArray1D(this._colors);\r\n\r\n        // processes the cubes\r\n        for (let cubeIndex = 1; cubeIndex < this._colors; ++cubeIndex) {\r\n            // if cut is possible; make it\r\n            if (this._cut(this._cubes[ next ], this._cubes[ cubeIndex ])) {\r\n                volumeVariance[ next ]      = this._cubes[ next ].volume > 1 ? this._calculateVariance(this._cubes[ next ]) : 0.0;\r\n                volumeVariance[ cubeIndex ] = this._cubes[ cubeIndex ].volume > 1 ? this._calculateVariance(this._cubes[ cubeIndex ]) : 0.0;\r\n            } else {\r\n                // the cut was not possible, revert the index\r\n                volumeVariance[ next ] = 0.0;\r\n                cubeIndex--;\r\n            }\r\n\r\n            next     = 0;\r\n            let temp = volumeVariance[ 0 ];\r\n\r\n            for (let index = 1; index <= cubeIndex; ++index) {\r\n                if (volumeVariance[ index ] > temp) {\r\n                    temp = volumeVariance[ index ];\r\n                    next = index;\r\n                }\r\n            }\r\n\r\n            if (temp <= 0.0) {\r\n                this._colors = cubeIndex + 1;\r\n                break;\r\n            }\r\n        }\r\n\r\n        const lookupRed : number[]   = [],\r\n              lookupGreen : number[] = [],\r\n              lookupBlue : number[]  = [],\r\n              lookupAlpha : number[] = [];\r\n\r\n        // precalculates lookup tables\r\n        for (let k = 0; k < this._colors; ++k) {\r\n\r\n            const weight = WuQuant._volume(this._cubes[ k ], this._weights);\r\n\r\n            if (weight > 0) {\r\n                lookupRed[ k ]   = (WuQuant._volume(this._cubes[ k ], this._momentsRed) / weight) | 0;\r\n                lookupGreen[ k ] = (WuQuant._volume(this._cubes[ k ], this._momentsGreen) / weight) | 0;\r\n                lookupBlue[ k ]  = (WuQuant._volume(this._cubes[ k ], this._momentsBlue) / weight) | 0;\r\n                lookupAlpha[ k ] = (WuQuant._volume(this._cubes[ k ], this._momentsAlpha) / weight) | 0;\r\n            } else {\r\n                lookupRed[ k ]   = 0;\r\n                lookupGreen[ k ] = 0;\r\n                lookupBlue[ k ]  = 0;\r\n                lookupAlpha[ k ] = 0;\r\n            }\r\n        }\r\n\r\n        this._reds   = createArray1D(this._colors + 1);\r\n        this._greens = createArray1D(this._colors + 1);\r\n        this._blues  = createArray1D(this._colors + 1);\r\n        this._alphas = createArray1D(this._colors + 1);\r\n        this._sums   = createArray1D(this._colors + 1);\r\n\r\n        // scans and adds colors\r\n        for (let index = 0, l = this._pixels.length; index < l; index++) {\r\n            const color : Point = this._pixels[ index ];\r\n\r\n            const match = -1;\r\n\r\n            let bestMatch    = match,\r\n                bestDistance = Number.MAX_VALUE;\r\n\r\n            for (let lookup = 0; lookup < this._colors; lookup++) {\r\n                const foundRed   = lookupRed[ lookup ],\r\n                      foundGreen = lookupGreen[ lookup ],\r\n                      foundBlue  = lookupBlue[ lookup ],\r\n                      foundAlpha = lookupAlpha[ lookup ];\r\n\r\n                const distance = this._distance.calculateRaw(foundRed, foundGreen, foundBlue, foundAlpha, color.r, color.g, color.b, color.a);\r\n                //var distance = this._distance.calculateRaw(Utils.Point.createByRGBA(foundRed, foundGreen, foundBlue, foundAlpha), color);\r\n                //deltaRed   = color.r - foundRed,\r\n                //deltaGreen = color.g - foundGreen,\r\n                //deltaBlue  = color.b - foundBlue,\r\n                //deltaAlpha = color.a - foundAlpha,\r\n\r\n                //distance   = deltaRed * deltaRed + deltaGreen * deltaGreen + deltaBlue * deltaBlue + deltaAlpha * deltaAlpha;\r\n\r\n                if (distance < bestDistance) {\r\n                    bestDistance = distance;\r\n                    bestMatch    = lookup;\r\n                }\r\n            }\r\n\r\n            this._reds[ bestMatch ] += color.r;\r\n            this._greens[ bestMatch ] += color.g;\r\n            this._blues[ bestMatch ] += color.b;\r\n            this._alphas[ bestMatch ] += color.a;\r\n            this._sums[ bestMatch ]++;\r\n        }\r\n    }\r\n\r\n    private _addColor(color : Point) : void {\r\n        const bitsToRemove = 8 - this._significantBitsPerChannel,\r\n              indexRed     = (color.r >> bitsToRemove) + 1,\r\n              indexGreen   = (color.g >> bitsToRemove) + 1,\r\n              indexBlue    = (color.b >> bitsToRemove) + 1,\r\n              indexAlpha   = (color.a >> bitsToRemove) + 1;\r\n\r\n        //if(color.a > 10) {\r\n        this._weights[ indexAlpha ][ indexRed ][ indexGreen ][ indexBlue ]++;\r\n        this._momentsRed[ indexAlpha ][ indexRed ][ indexGreen ][ indexBlue ] += color.r;\r\n        this._momentsGreen[ indexAlpha ][ indexRed ][ indexGreen ][ indexBlue ] += color.g;\r\n        this._momentsBlue[ indexAlpha ][ indexRed ][ indexGreen ][ indexBlue ] += color.b;\r\n        this._momentsAlpha[ indexAlpha ][ indexRed ][ indexGreen ][ indexBlue ] += color.a;\r\n        this._moments[ indexAlpha ][ indexRed ][ indexGreen ][ indexBlue ] += this._table[ color.r ] + this._table[ color.g ] + this._table[ color.b ] + this._table[ color.a ];\r\n//\t\t\t}\r\n    }\r\n\r\n    /**\r\n     * Converts the histogram to a series of _moments.\r\n     */\r\n    private _calculateMoments() : void {\r\n        const area : number[]      = [],\r\n              areaRed : number[]   = [],\r\n              areaGreen : number[] = [],\r\n              areaBlue : number[]  = [],\r\n              areaAlpha : number[] = [],\r\n              area2 : number[]     = [];\r\n\r\n        const xarea : number[][][]      = createArray3D(this._sideSize, this._sideSize, this._sideSize),\r\n              xareaRed : number[][][]   = createArray3D(this._sideSize, this._sideSize, this._sideSize),\r\n              xareaGreen : number[][][] = createArray3D(this._sideSize, this._sideSize, this._sideSize),\r\n              xareaBlue : number[][][]  = createArray3D(this._sideSize, this._sideSize, this._sideSize),\r\n              xareaAlpha : number[][][] = createArray3D(this._sideSize, this._sideSize, this._sideSize),\r\n              xarea2 : number[][][]     = createArray3D(this._sideSize, this._sideSize, this._sideSize);\r\n\r\n        for (let alphaIndex = 1; alphaIndex <= this._alphaMaxSideIndex; ++alphaIndex) {\r\n            fillArray3D<number>(xarea, this._sideSize, this._sideSize, this._sideSize, 0);\r\n            fillArray3D<number>(xareaRed, this._sideSize, this._sideSize, this._sideSize, 0);\r\n            fillArray3D<number>(xareaGreen, this._sideSize, this._sideSize, this._sideSize, 0);\r\n            fillArray3D<number>(xareaBlue, this._sideSize, this._sideSize, this._sideSize, 0);\r\n            fillArray3D<number>(xareaAlpha, this._sideSize, this._sideSize, this._sideSize, 0);\r\n            fillArray3D<number>(xarea2, this._sideSize, this._sideSize, this._sideSize, 0);\r\n\r\n            for (let redIndex = 1; redIndex <= this._maxSideIndex; ++redIndex) {\r\n                fillArray1D<number>(area, this._sideSize, 0);\r\n                fillArray1D<number>(areaRed, this._sideSize, 0);\r\n                fillArray1D<number>(areaGreen, this._sideSize, 0);\r\n                fillArray1D<number>(areaBlue, this._sideSize, 0);\r\n                fillArray1D<number>(areaAlpha, this._sideSize, 0);\r\n                fillArray1D<number>(area2, this._sideSize, 0);\r\n\r\n                for (let greenIndex = 1; greenIndex <= this._maxSideIndex; ++greenIndex) {\r\n                    let line      = 0,\r\n                        lineRed   = 0,\r\n                        lineGreen = 0,\r\n                        lineBlue  = 0,\r\n                        lineAlpha = 0,\r\n                        line2     = 0.0;\r\n\r\n                    for (let blueIndex = 1; blueIndex <= this._maxSideIndex; ++blueIndex) {\r\n                        line += this._weights[ alphaIndex ][ redIndex ][ greenIndex ][ blueIndex ];\r\n                        lineRed += this._momentsRed[ alphaIndex ][ redIndex ][ greenIndex ][ blueIndex ];\r\n                        lineGreen += this._momentsGreen[ alphaIndex ][ redIndex ][ greenIndex ][ blueIndex ];\r\n                        lineBlue += this._momentsBlue[ alphaIndex ][ redIndex ][ greenIndex ][ blueIndex ];\r\n                        lineAlpha += this._momentsAlpha[ alphaIndex ][ redIndex ][ greenIndex ][ blueIndex ];\r\n                        line2 += this._moments[ alphaIndex ][ redIndex ][ greenIndex ][ blueIndex ];\r\n\r\n                        area[ blueIndex ] += line;\r\n                        areaRed[ blueIndex ] += lineRed;\r\n                        areaGreen[ blueIndex ] += lineGreen;\r\n                        areaBlue[ blueIndex ] += lineBlue;\r\n                        areaAlpha[ blueIndex ] += lineAlpha;\r\n                        area2[ blueIndex ] += line2;\r\n\r\n                        xarea[ redIndex ][ greenIndex ][ blueIndex ]      = xarea[ redIndex - 1 ][ greenIndex ][ blueIndex ] + area[ blueIndex ];\r\n                        xareaRed[ redIndex ][ greenIndex ][ blueIndex ]   = xareaRed[ redIndex - 1 ][ greenIndex ][ blueIndex ] + areaRed[ blueIndex ];\r\n                        xareaGreen[ redIndex ][ greenIndex ][ blueIndex ] = xareaGreen[ redIndex - 1 ][ greenIndex ][ blueIndex ] + areaGreen[ blueIndex ];\r\n                        xareaBlue[ redIndex ][ greenIndex ][ blueIndex ]  = xareaBlue[ redIndex - 1 ][ greenIndex ][ blueIndex ] + areaBlue[ blueIndex ];\r\n                        xareaAlpha[ redIndex ][ greenIndex ][ blueIndex ] = xareaAlpha[ redIndex - 1 ][ greenIndex ][ blueIndex ] + areaAlpha[ blueIndex ];\r\n                        xarea2[ redIndex ][ greenIndex ][ blueIndex ]     = xarea2[ redIndex - 1 ][ greenIndex ][ blueIndex ] + area2[ blueIndex ];\r\n\r\n                        this._weights[ alphaIndex ][ redIndex ][ greenIndex ][ blueIndex ]      = this._weights[ alphaIndex - 1 ][ redIndex ][ greenIndex ][ blueIndex ] + xarea[ redIndex ][ greenIndex ][ blueIndex ];\r\n                        this._momentsRed[ alphaIndex ][ redIndex ][ greenIndex ][ blueIndex ]   = this._momentsRed[ alphaIndex - 1 ][ redIndex ][ greenIndex ][ blueIndex ] + xareaRed[ redIndex ][ greenIndex ][ blueIndex ];\r\n                        this._momentsGreen[ alphaIndex ][ redIndex ][ greenIndex ][ blueIndex ] = this._momentsGreen[ alphaIndex - 1 ][ redIndex ][ greenIndex ][ blueIndex ] + xareaGreen[ redIndex ][ greenIndex ][ blueIndex ];\r\n                        this._momentsBlue[ alphaIndex ][ redIndex ][ greenIndex ][ blueIndex ]  = this._momentsBlue[ alphaIndex - 1 ][ redIndex ][ greenIndex ][ blueIndex ] + xareaBlue[ redIndex ][ greenIndex ][ blueIndex ];\r\n                        this._momentsAlpha[ alphaIndex ][ redIndex ][ greenIndex ][ blueIndex ] = this._momentsAlpha[ alphaIndex - 1 ][ redIndex ][ greenIndex ][ blueIndex ] + xareaAlpha[ redIndex ][ greenIndex ][ blueIndex ];\r\n                        this._moments[ alphaIndex ][ redIndex ][ greenIndex ][ blueIndex ]      = this._moments[ alphaIndex - 1 ][ redIndex ][ greenIndex ][ blueIndex ] + xarea2[ redIndex ][ greenIndex ][ blueIndex ];\r\n                    }\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    /**\r\n     * Computes the volume of the cube in a specific moment.\r\n     */\r\n    private static _volumeFloat(cube : WuColorCube, moment : number[][][][]) : number {\r\n        return (moment[ cube.alphaMaximum ][ cube.redMaximum ][ cube.greenMaximum ][ cube.blueMaximum ] -\r\n            moment[ cube.alphaMaximum ][ cube.redMaximum ][ cube.greenMinimum ][ cube.blueMaximum ] -\r\n            moment[ cube.alphaMaximum ][ cube.redMinimum ][ cube.greenMaximum ][ cube.blueMaximum ] +\r\n            moment[ cube.alphaMaximum ][ cube.redMinimum ][ cube.greenMinimum ][ cube.blueMaximum ] -\r\n            moment[ cube.alphaMinimum ][ cube.redMaximum ][ cube.greenMaximum ][ cube.blueMaximum ] +\r\n            moment[ cube.alphaMinimum ][ cube.redMaximum ][ cube.greenMinimum ][ cube.blueMaximum ] +\r\n            moment[ cube.alphaMinimum ][ cube.redMinimum ][ cube.greenMaximum ][ cube.blueMaximum ] -\r\n            moment[ cube.alphaMinimum ][ cube.redMinimum ][ cube.greenMinimum ][ cube.blueMaximum ]) -\r\n\r\n            (moment[ cube.alphaMaximum ][ cube.redMaximum ][ cube.greenMaximum ][ cube.blueMinimum ] -\r\n            moment[ cube.alphaMinimum ][ cube.redMaximum ][ cube.greenMaximum ][ cube.blueMinimum ] -\r\n            moment[ cube.alphaMaximum ][ cube.redMaximum ][ cube.greenMinimum ][ cube.blueMinimum ] +\r\n            moment[ cube.alphaMinimum ][ cube.redMaximum ][ cube.greenMinimum ][ cube.blueMinimum ] -\r\n            moment[ cube.alphaMaximum ][ cube.redMinimum ][ cube.greenMaximum ][ cube.blueMinimum ] +\r\n            moment[ cube.alphaMinimum ][ cube.redMinimum ][ cube.greenMaximum ][ cube.blueMinimum ] +\r\n            moment[ cube.alphaMaximum ][ cube.redMinimum ][ cube.greenMinimum ][ cube.blueMinimum ] -\r\n            moment[ cube.alphaMinimum ][ cube.redMinimum ][ cube.greenMinimum ][ cube.blueMinimum ]);\r\n    }\r\n\r\n    /**\r\n     * Computes the volume of the cube in a specific moment.\r\n     */\r\n    private static _volume(cube : WuColorCube, moment : number[][][][]) : number {\r\n        return WuQuant._volumeFloat(cube, moment) | 0;\r\n    }\r\n\r\n    /**\r\n     * Splits the cube in given position][and color direction.\r\n     */\r\n    private static _top(cube : WuColorCube, direction : number, position : number, moment : number[][][][]) : number {\r\n        let result : number;\r\n        switch (direction) {\r\n            case WuQuant.alpha:\r\n                result = (moment[ position ][ cube.redMaximum ][ cube.greenMaximum ][ cube.blueMaximum ] -\r\n                    moment[ position ][ cube.redMaximum ][ cube.greenMinimum ][ cube.blueMaximum ] -\r\n                    moment[ position ][ cube.redMinimum ][ cube.greenMaximum ][ cube.blueMaximum ] +\r\n                    moment[ position ][ cube.redMinimum ][ cube.greenMinimum ][ cube.blueMaximum ]) -\r\n                    (moment[ position ][ cube.redMaximum ][ cube.greenMaximum ][ cube.blueMinimum ] -\r\n                    moment[ position ][ cube.redMaximum ][ cube.greenMinimum ][ cube.blueMinimum ] -\r\n                    moment[ position ][ cube.redMinimum ][ cube.greenMaximum ][ cube.blueMinimum ] +\r\n                    moment[ position ][ cube.redMinimum ][ cube.greenMinimum ][ cube.blueMinimum ]);\r\n                break;\r\n\r\n            case WuQuant.red:\r\n                result = (moment[ cube.alphaMaximum ][ position ][ cube.greenMaximum ][ cube.blueMaximum ] -\r\n                    moment[ cube.alphaMaximum ][ position ][ cube.greenMinimum ][ cube.blueMaximum ] -\r\n                    moment[ cube.alphaMinimum ][ position ][ cube.greenMaximum ][ cube.blueMaximum ] +\r\n                    moment[ cube.alphaMinimum ][ position ][ cube.greenMinimum ][ cube.blueMaximum ]) -\r\n                    (moment[ cube.alphaMaximum ][ position ][ cube.greenMaximum ][ cube.blueMinimum ] -\r\n                    moment[ cube.alphaMaximum ][ position ][ cube.greenMinimum ][ cube.blueMinimum ] -\r\n                    moment[ cube.alphaMinimum ][ position ][ cube.greenMaximum ][ cube.blueMinimum ] +\r\n                    moment[ cube.alphaMinimum ][ position ][ cube.greenMinimum ][ cube.blueMinimum ]);\r\n                break;\r\n\r\n            case WuQuant.green:\r\n                result = (moment[ cube.alphaMaximum ][ cube.redMaximum ][ position ][ cube.blueMaximum ] -\r\n                    moment[ cube.alphaMaximum ][ cube.redMinimum ][ position ][ cube.blueMaximum ] -\r\n                    moment[ cube.alphaMinimum ][ cube.redMaximum ][ position ][ cube.blueMaximum ] +\r\n                    moment[ cube.alphaMinimum ][ cube.redMinimum ][ position ][ cube.blueMaximum ]) -\r\n                    (moment[ cube.alphaMaximum ][ cube.redMaximum ][ position ][ cube.blueMinimum ] -\r\n                    moment[ cube.alphaMaximum ][ cube.redMinimum ][ position ][ cube.blueMinimum ] -\r\n                    moment[ cube.alphaMinimum ][ cube.redMaximum ][ position ][ cube.blueMinimum ] +\r\n                    moment[ cube.alphaMinimum ][ cube.redMinimum ][ position ][ cube.blueMinimum ]);\r\n                break;\r\n\r\n            case WuQuant.blue:\r\n                result = (moment[ cube.alphaMaximum ][ cube.redMaximum ][ cube.greenMaximum ][ position ] -\r\n                    moment[ cube.alphaMaximum ][ cube.redMaximum ][ cube.greenMinimum ][ position ] -\r\n                    moment[ cube.alphaMaximum ][ cube.redMinimum ][ cube.greenMaximum ][ position ] +\r\n                    moment[ cube.alphaMaximum ][ cube.redMinimum ][ cube.greenMinimum ][ position ]) -\r\n                    (moment[ cube.alphaMinimum ][ cube.redMaximum ][ cube.greenMaximum ][ position ] -\r\n                    moment[ cube.alphaMinimum ][ cube.redMaximum ][ cube.greenMinimum ][ position ] -\r\n                    moment[ cube.alphaMinimum ][ cube.redMinimum ][ cube.greenMaximum ][ position ] +\r\n                    moment[ cube.alphaMinimum ][ cube.redMinimum ][ cube.greenMinimum ][ position ]);\r\n                break;\r\n            default:\r\n                throw new Error(\"impossible\")\r\n        }\r\n\r\n        return result | 0;\r\n    }\r\n\r\n    /**\r\n     * Splits the cube in a given color direction at its minimum.\r\n     */\r\n    private static _bottom(cube : WuColorCube, direction : number, moment : number[][][][]) : number {\r\n        switch (direction) {\r\n            case WuQuant.alpha:\r\n                return (-moment[ cube.alphaMinimum ][ cube.redMaximum ][ cube.greenMaximum ][ cube.blueMaximum ] +\r\n                    moment[ cube.alphaMinimum ][ cube.redMaximum ][ cube.greenMinimum ][ cube.blueMaximum ] +\r\n                    moment[ cube.alphaMinimum ][ cube.redMinimum ][ cube.greenMaximum ][ cube.blueMaximum ] -\r\n                    moment[ cube.alphaMinimum ][ cube.redMinimum ][ cube.greenMinimum ][ cube.blueMaximum ]) -\r\n                    (-moment[ cube.alphaMinimum ][ cube.redMaximum ][ cube.greenMaximum ][ cube.blueMinimum ] +\r\n                    moment[ cube.alphaMinimum ][ cube.redMaximum ][ cube.greenMinimum ][ cube.blueMinimum ] +\r\n                    moment[ cube.alphaMinimum ][ cube.redMinimum ][ cube.greenMaximum ][ cube.blueMinimum ] -\r\n                    moment[ cube.alphaMinimum ][ cube.redMinimum ][ cube.greenMinimum ][ cube.blueMinimum ]);\r\n\r\n            case WuQuant.red:\r\n                return (-moment[ cube.alphaMaximum ][ cube.redMinimum ][ cube.greenMaximum ][ cube.blueMaximum ] +\r\n                    moment[ cube.alphaMaximum ][ cube.redMinimum ][ cube.greenMinimum ][ cube.blueMaximum ] +\r\n                    moment[ cube.alphaMinimum ][ cube.redMinimum ][ cube.greenMaximum ][ cube.blueMaximum ] -\r\n                    moment[ cube.alphaMinimum ][ cube.redMinimum ][ cube.greenMinimum ][ cube.blueMaximum ]) -\r\n                    (-moment[ cube.alphaMaximum ][ cube.redMinimum ][ cube.greenMaximum ][ cube.blueMinimum ] +\r\n                    moment[ cube.alphaMaximum ][ cube.redMinimum ][ cube.greenMinimum ][ cube.blueMinimum ] +\r\n                    moment[ cube.alphaMinimum ][ cube.redMinimum ][ cube.greenMaximum ][ cube.blueMinimum ] -\r\n                    moment[ cube.alphaMinimum ][ cube.redMinimum ][ cube.greenMinimum ][ cube.blueMinimum ]);\r\n\r\n            case WuQuant.green:\r\n                return (-moment[ cube.alphaMaximum ][ cube.redMaximum ][ cube.greenMinimum ][ cube.blueMaximum ] +\r\n                    moment[ cube.alphaMaximum ][ cube.redMinimum ][ cube.greenMinimum ][ cube.blueMaximum ] +\r\n                    moment[ cube.alphaMinimum ][ cube.redMaximum ][ cube.greenMinimum ][ cube.blueMaximum ] -\r\n                    moment[ cube.alphaMinimum ][ cube.redMinimum ][ cube.greenMinimum ][ cube.blueMaximum ]) -\r\n                    (-moment[ cube.alphaMaximum ][ cube.redMaximum ][ cube.greenMinimum ][ cube.blueMinimum ] +\r\n                    moment[ cube.alphaMaximum ][ cube.redMinimum ][ cube.greenMinimum ][ cube.blueMinimum ] +\r\n                    moment[ cube.alphaMinimum ][ cube.redMaximum ][ cube.greenMinimum ][ cube.blueMinimum ] -\r\n                    moment[ cube.alphaMinimum ][ cube.redMinimum ][ cube.greenMinimum ][ cube.blueMinimum ]);\r\n\r\n            case WuQuant.blue:\r\n                return (-moment[ cube.alphaMaximum ][ cube.redMaximum ][ cube.greenMaximum ][ cube.blueMinimum ] +\r\n                    moment[ cube.alphaMaximum ][ cube.redMaximum ][ cube.greenMinimum ][ cube.blueMinimum ] +\r\n                    moment[ cube.alphaMaximum ][ cube.redMinimum ][ cube.greenMaximum ][ cube.blueMinimum ] -\r\n                    moment[ cube.alphaMaximum ][ cube.redMinimum ][ cube.greenMinimum ][ cube.blueMinimum ]) -\r\n                    (-moment[ cube.alphaMinimum ][ cube.redMaximum ][ cube.greenMaximum ][ cube.blueMinimum ] +\r\n                    moment[ cube.alphaMinimum ][ cube.redMaximum ][ cube.greenMinimum ][ cube.blueMinimum ] +\r\n                    moment[ cube.alphaMinimum ][ cube.redMinimum ][ cube.greenMaximum ][ cube.blueMinimum ] -\r\n                    moment[ cube.alphaMinimum ][ cube.redMinimum ][ cube.greenMinimum ][ cube.blueMinimum ]);\r\n\r\n            default:\r\n                // TODO: why here is return 0, and in this._top there is no default at all (now it is throw error)?\r\n                return 0;\r\n        }\r\n    }\r\n\r\n    /**\r\n     * Calculates statistical variance for a given cube.\r\n     */\r\n    private  _calculateVariance(cube : WuColorCube) : number {\r\n        const volumeRed    = WuQuant._volume(cube, this._momentsRed),\r\n              volumeGreen  = WuQuant._volume(cube, this._momentsGreen),\r\n              volumeBlue   = WuQuant._volume(cube, this._momentsBlue),\r\n              volumeAlpha  = WuQuant._volume(cube, this._momentsAlpha),\r\n              volumeMoment = WuQuant._volumeFloat(cube, this._moments),\r\n              volumeWeight = WuQuant._volume(cube, this._weights),\r\n              distance     = volumeRed * volumeRed + volumeGreen * volumeGreen + volumeBlue * volumeBlue + volumeAlpha * volumeAlpha;\r\n\r\n        return volumeMoment - (distance / volumeWeight);\r\n    }\r\n\r\n    /**\r\n     * Finds the optimal (maximal) position for the cut.\r\n     */\r\n    private _maximize(cube : WuColorCube, direction : number, first : number, last : number, wholeRed : number, wholeGreen : number, wholeBlue : number, wholeAlpha : number, wholeWeight : number) : {max : number; position : number} {\r\n        const bottomRed    = WuQuant._bottom(cube, direction, this._momentsRed) | 0,\r\n              bottomGreen  = WuQuant._bottom(cube, direction, this._momentsGreen) | 0,\r\n              bottomBlue   = WuQuant._bottom(cube, direction, this._momentsBlue) | 0,\r\n              bottomAlpha  = WuQuant._bottom(cube, direction, this._momentsAlpha) | 0,\r\n              bottomWeight = WuQuant._bottom(cube, direction, this._weights) | 0;\r\n\r\n        let result      = 0.0,\r\n            cutPosition = -1;\r\n\r\n        for (let position = first; position < last; ++position) {\r\n            // determines the cube cut at a certain position\r\n            let halfRed    = bottomRed + WuQuant._top(cube, direction, position, this._momentsRed),\r\n                halfGreen  = bottomGreen + WuQuant._top(cube, direction, position, this._momentsGreen),\r\n                halfBlue   = bottomBlue + WuQuant._top(cube, direction, position, this._momentsBlue),\r\n                halfAlpha  = bottomAlpha + WuQuant._top(cube, direction, position, this._momentsAlpha),\r\n                halfWeight = bottomWeight + WuQuant._top(cube, direction, position, this._weights);\r\n\r\n            // the cube cannot be cut at bottom (this would lead to empty cube)\r\n            if (halfWeight != 0) {\r\n                let halfDistance = halfRed * halfRed + halfGreen * halfGreen + halfBlue * halfBlue + halfAlpha * halfAlpha,\r\n                    temp         = halfDistance / halfWeight;\r\n\r\n                halfRed    = wholeRed - halfRed;\r\n                halfGreen  = wholeGreen - halfGreen;\r\n                halfBlue   = wholeBlue - halfBlue;\r\n                halfAlpha  = wholeAlpha - halfAlpha;\r\n                halfWeight = wholeWeight - halfWeight;\r\n\r\n                if (halfWeight != 0) {\r\n                    halfDistance = halfRed * halfRed + halfGreen * halfGreen + halfBlue * halfBlue + halfAlpha * halfAlpha;\r\n                    temp += halfDistance / halfWeight;\r\n\r\n                    if (temp > result) {\r\n                        result      = temp;\r\n                        cutPosition = position;\r\n                    }\r\n                }\r\n            }\r\n        }\r\n\r\n        return { max : result, position : cutPosition };\r\n    }\r\n\r\n    // Cuts a cube with another one.\r\n    private _cut(first : WuColorCube, second : WuColorCube) : boolean {\r\n        let direction : number;\r\n\r\n        const wholeRed    = WuQuant._volume(first, this._momentsRed),\r\n              wholeGreen  = WuQuant._volume(first, this._momentsGreen),\r\n              wholeBlue   = WuQuant._volume(first, this._momentsBlue),\r\n              wholeAlpha  = WuQuant._volume(first, this._momentsAlpha),\r\n              wholeWeight = WuQuant._volume(first, this._weights),\r\n\r\n              red         = this._maximize(first, WuQuant.red, first.redMinimum + 1, first.redMaximum, wholeRed, wholeGreen, wholeBlue, wholeAlpha, wholeWeight),\r\n              green       = this._maximize(first, WuQuant.green, first.greenMinimum + 1, first.greenMaximum, wholeRed, wholeGreen, wholeBlue, wholeAlpha, wholeWeight),\r\n              blue        = this._maximize(first, WuQuant.blue, first.blueMinimum + 1, first.blueMaximum, wholeRed, wholeGreen, wholeBlue, wholeAlpha, wholeWeight),\r\n              alpha       = this._maximize(first, WuQuant.alpha, first.alphaMinimum + 1, first.alphaMaximum, wholeRed, wholeGreen, wholeBlue, wholeAlpha, wholeWeight);\r\n\r\n        if (alpha.max >= red.max && alpha.max >= green.max && alpha.max >= blue.max) {\r\n            direction = WuQuant.alpha;\r\n\r\n            // cannot split empty cube\r\n            if (alpha.position < 0) return false;\r\n        } else {\r\n            if (red.max >= alpha.max && red.max >= green.max && red.max >= blue.max) {\r\n                direction = WuQuant.red;\r\n            } else if (green.max >= alpha.max && green.max >= red.max && green.max >= blue.max) {\r\n                direction = WuQuant.green;\r\n            } else {\r\n                direction = WuQuant.blue;\r\n            }\r\n        }\r\n\r\n        second.redMaximum   = first.redMaximum;\r\n        second.greenMaximum = first.greenMaximum;\r\n        second.blueMaximum  = first.blueMaximum;\r\n        second.alphaMaximum = first.alphaMaximum;\r\n\r\n        // cuts in a certain direction\r\n        switch (direction) {\r\n            case WuQuant.red:\r\n                second.redMinimum = first.redMaximum = red.position;\r\n                second.greenMinimum = first.greenMinimum;\r\n                second.blueMinimum  = first.blueMinimum;\r\n                second.alphaMinimum = first.alphaMinimum;\r\n                break;\r\n\r\n            case WuQuant.green:\r\n                second.greenMinimum = first.greenMaximum = green.position;\r\n                second.redMinimum   = first.redMinimum;\r\n                second.blueMinimum  = first.blueMinimum;\r\n                second.alphaMinimum = first.alphaMinimum;\r\n                break;\r\n\r\n            case WuQuant.blue:\r\n                second.blueMinimum = first.blueMaximum = blue.position;\r\n                second.redMinimum   = first.redMinimum;\r\n                second.greenMinimum = first.greenMinimum;\r\n                second.alphaMinimum = first.alphaMinimum;\r\n                break;\r\n\r\n            case WuQuant.alpha:\r\n                second.alphaMinimum = first.alphaMaximum = alpha.position;\r\n                second.blueMinimum  = first.blueMinimum;\r\n                second.redMinimum   = first.redMinimum;\r\n                second.greenMinimum = first.greenMinimum;\r\n                break;\r\n        }\r\n\r\n        // determines the volumes after cut\r\n        first.volume  = (first.redMaximum - first.redMinimum) * (first.greenMaximum - first.greenMinimum) * (first.blueMaximum - first.blueMinimum) * (first.alphaMaximum - first.alphaMinimum);\r\n        second.volume = (second.redMaximum - second.redMinimum) * (second.greenMaximum - second.greenMinimum) * (second.blueMaximum - second.blueMinimum) * (second.alphaMaximum - second.alphaMinimum);\r\n\r\n        // the cut was successful\r\n        return true;\r\n    }\r\n\r\n    private _initialize(colors : number) : void {\r\n        this._colors = colors;\r\n\r\n        // creates all the _cubes\r\n        this._cubes = [];\r\n\r\n        // initializes all the _cubes\r\n        for (let cubeIndex = 0; cubeIndex < colors; cubeIndex++) {\r\n            this._cubes[ cubeIndex ] = new WuColorCube();\r\n        }\r\n\r\n        // resets the reference minimums\r\n        this._cubes[ 0 ].redMinimum   = 0;\r\n        this._cubes[ 0 ].greenMinimum = 0;\r\n        this._cubes[ 0 ].blueMinimum  = 0;\r\n        this._cubes[ 0 ].alphaMinimum = 0;\r\n\r\n        // resets the reference maximums\r\n        this._cubes[ 0 ].redMaximum   = this._maxSideIndex;\r\n        this._cubes[ 0 ].greenMaximum = this._maxSideIndex;\r\n        this._cubes[ 0 ].blueMaximum  = this._maxSideIndex;\r\n        this._cubes[ 0 ].alphaMaximum = this._alphaMaxSideIndex;\r\n\r\n        this._weights      = createArray4D(this._alphaSideSize, this._sideSize, this._sideSize, this._sideSize);\r\n        this._momentsRed   = createArray4D(this._alphaSideSize, this._sideSize, this._sideSize, this._sideSize);\r\n        this._momentsGreen = createArray4D(this._alphaSideSize, this._sideSize, this._sideSize, this._sideSize);\r\n        this._momentsBlue  = createArray4D(this._alphaSideSize, this._sideSize, this._sideSize, this._sideSize);\r\n        this._momentsAlpha = createArray4D(this._alphaSideSize, this._sideSize, this._sideSize, this._sideSize);\r\n        this._moments      = createArray4D(this._alphaSideSize, this._sideSize, this._sideSize, this._sideSize);\r\n\r\n        this._table = [];\r\n        for (let tableIndex = 0; tableIndex < 256; ++tableIndex) {\r\n            this._table[ tableIndex ] = tableIndex * tableIndex;\r\n        }\r\n\r\n        this._pixels = [];\r\n    }\r\n\r\n    private _setQuality(significantBitsPerChannel : number = 5) : void {\r\n        this._significantBitsPerChannel = significantBitsPerChannel;\r\n        this._maxSideIndex              = 1 << this._significantBitsPerChannel;\r\n        this._alphaMaxSideIndex         = this._maxSideIndex;\r\n\r\n        this._sideSize      = this._maxSideIndex + 1;\r\n        this._alphaSideSize = this._alphaMaxSideIndex + 1;\r\n    }\r\n\r\n}\r\n\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/palette/wu/wuQuant.ts\n **/","/**\r\n * @preserve\r\n * Copyright 2015-2016 Igor Bezkrovnyi\r\n * All rights reserved. (MIT Licensed)\r\n *\r\n * iq.ts - Image Quantization Library\r\n */\r\nimport { IImageDitherer } from \"./common\"\r\nimport { NearestColor } from \"./nearestColor\"\r\nimport { ErrorDiffusionArray, ErrorDiffusionArrayKernel } from \"./array\"\r\nimport { ErrorDiffusionRiemersma } from \"./riemersma\"\r\n\r\nexport {\r\n    IImageDitherer,\r\n    NearestColor,\r\n    ErrorDiffusionArray,\r\n    ErrorDiffusionArrayKernel,\r\n    ErrorDiffusionRiemersma\r\n}\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/image/index.ts\n **/","/**\r\n * @preserve\r\n * Copyright 2015-2016 Igor Bezkrovnyi\r\n * All rights reserved. (MIT Licensed)\r\n *\r\n * nearestColor.ts - part of Image Quantization Library\r\n */\r\nimport { IImageDitherer } from \"./common\"\r\nimport { AbstractDistanceCalculator } from \"../distance/abstractDistanceCalculator\"\r\nimport { PointContainer } from \"../utils/pointContainer\"\r\nimport { Palette } from \"../utils/palette\"\r\n\r\nexport class NearestColor implements IImageDitherer {\r\n    private _distance : AbstractDistanceCalculator;\r\n\r\n    constructor(colorDistanceCalculator : AbstractDistanceCalculator) {\r\n        this._distance = colorDistanceCalculator;\r\n    }\r\n\r\n    quantize(pointBuffer : PointContainer, palette : Palette) : PointContainer {\r\n        const pointArray = pointBuffer.getPointArray(),\r\n              width      = pointBuffer.getWidth(),\r\n              height     = pointBuffer.getHeight();\r\n\r\n        for (let y = 0; y < height; y++) {\r\n            for (let x = 0, idx = y * width; x < width; x++, idx++) {\r\n                // Image pixel\r\n                const point = pointArray[ idx ];\r\n                // Reduced pixel\r\n                point.from(palette.getNearestColor(this._distance, point));\r\n            }\r\n        }\r\n        return pointBuffer;\r\n    }\r\n}\r\n\r\n\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/image/nearestColor.ts\n **/","/**\r\n * @preserve\r\n * Copyright 2015-2016 Igor Bezkrovnyi\r\n * All rights reserved. (MIT Licensed)\r\n *\r\n * ditherErrorDiffusionArray.ts - part of Image Quantization Library\r\n */\r\nimport { IImageDitherer } from \"./common\"\r\nimport { AbstractDistanceCalculator } from \"../distance/abstractDistanceCalculator\"\r\nimport { PointContainer } from \"../utils/pointContainer\"\r\nimport { Palette } from \"../utils/palette\"\r\nimport { Point } from \"../utils/point\"\r\nimport { inRange0to255Rounded } from \"../utils/arithmetic\"\r\n\r\n// TODO: is it the best name for this enum \"kernel\"?\r\nexport enum ErrorDiffusionArrayKernel {\r\n    FloydSteinberg = 0,\r\n    FalseFloydSteinberg,\r\n    Stucki,\r\n    Atkinson,\r\n    Jarvis,\r\n    Burkes,\r\n    Sierra,\r\n    TwoSierra,\r\n    SierraLite\r\n}\r\n\r\n// http://www.tannerhelland.com/4660/dithering-eleven-algorithms-source-code/\r\nexport class ErrorDiffusionArray implements IImageDitherer {\r\n    private _minColorDistance : number;\r\n    private _serpentine : boolean;\r\n    private _kernel : number[][];\r\n    /** true = GIMP, false = XNVIEW */\r\n            private _calculateErrorLikeGIMP : boolean;\r\n\r\n    private _distance : AbstractDistanceCalculator;\r\n\r\n    constructor(colorDistanceCalculator : AbstractDistanceCalculator, kernel : ErrorDiffusionArrayKernel, serpentine : boolean = true, minimumColorDistanceToDither : number = 0, calculateErrorLikeGIMP : boolean = false) {\r\n        this._setKernel(kernel);\r\n\r\n        this._distance               = colorDistanceCalculator;\r\n        this._minColorDistance       = minimumColorDistanceToDither;\r\n        this._serpentine             = serpentine;\r\n        this._calculateErrorLikeGIMP = calculateErrorLikeGIMP;\r\n    }\r\n\r\n    // adapted from http://jsbin.com/iXofIji/2/edit by PAEz\r\n    // fixed version. it doesn't use image pixels as error storage, also it doesn't have 0.3 + 0.3 + 0.3 + 0.3 = 0 error\r\n    quantize(pointBuffer : PointContainer, palette : Palette) : PointContainer {\r\n        const pointArray                = pointBuffer.getPointArray(),\r\n              originalPoint             = new Point(),\r\n              width                     = pointBuffer.getWidth(),\r\n              height                    = pointBuffer.getHeight(),\r\n              errorLines : number[][][] = [];\r\n\r\n        let dir           = 1,\r\n            maxErrorLines = 1;\r\n\r\n        // initial error lines (number is taken from dithering kernel)\r\n        for (let i = 0; i < this._kernel.length; i++) {\r\n            const kernelErrorLines = this._kernel[ i ][ 2 ] + 1;\r\n            if (maxErrorLines < kernelErrorLines) maxErrorLines = kernelErrorLines;\r\n        }\r\n        for (let i = 0; i < maxErrorLines; i++) {\r\n            this._fillErrorLine(errorLines[ i ] = [], width);\r\n        }\r\n\r\n        for (let y = 0; y < height; y++) {\r\n            // always serpentine\r\n            if (this._serpentine) dir = dir * -1;\r\n\r\n            const lni    = y * width,\r\n                  xStart = dir == 1 ? 0 : width - 1,\r\n                  xEnd   = dir == 1 ? width : -1;\r\n\r\n            // cyclic shift with erasing\r\n            this._fillErrorLine(errorLines[ 0 ], width);\r\n            // TODO: why it is needed to cast types here?\r\n            errorLines.push(<number[][]>errorLines.shift());\r\n\r\n            const errorLine = errorLines[ 0 ];\r\n            for (let x = xStart, idx = lni + xStart; x !== xEnd; x += dir, idx += dir) {\r\n                // Image pixel\r\n                const point = pointArray[ idx ],\r\n                      //originalPoint = new Utils.Point(),\r\n                      error = errorLine[ x ];\r\n\r\n                originalPoint.from(point);\r\n\r\n                const correctedPoint = Point.createByRGBA(\r\n                    inRange0to255Rounded(point.r + error[ 0 ]),\r\n                    inRange0to255Rounded(point.g + error[ 1 ]),\r\n                    inRange0to255Rounded(point.b + error[ 2 ]),\r\n                    inRange0to255Rounded(point.a + error[ 3 ])\r\n                );\r\n\r\n                // Reduced pixel\r\n                const palettePoint = palette.getNearestColor(this._distance, correctedPoint);\r\n                point.from(palettePoint);\r\n\r\n                // dithering strength\r\n                if (this._minColorDistance) {\r\n                    const dist = this._distance.calculateNormalized(point, palettePoint);\r\n                    if (dist < this._minColorDistance) continue;\r\n                }\r\n\r\n                // Component distance\r\n                let er : number, eg : number, eb : number, ea : number;\r\n                if (this._calculateErrorLikeGIMP) {\r\n                    er = correctedPoint.r - palettePoint.r;\r\n                    eg = correctedPoint.g - palettePoint.g;\r\n                    eb = correctedPoint.b - palettePoint.b;\r\n                    ea = correctedPoint.a - palettePoint.a;\r\n                } else {\r\n                    er = originalPoint.r - palettePoint.r;\r\n                    eg = originalPoint.g - palettePoint.g;\r\n                    eb = originalPoint.b - palettePoint.b;\r\n                    ea = originalPoint.a - palettePoint.a;\r\n                }\r\n\r\n                const dStart = dir == 1 ? 0 : this._kernel.length - 1,\r\n                      dEnd   = dir == 1 ? this._kernel.length : -1;\r\n\r\n                for (let i = dStart; i !== dEnd; i += dir) {\r\n                    const x1 = this._kernel[ i ][ 1 ] * dir,\r\n                          y1 = this._kernel[ i ][ 2 ];\r\n\r\n                    if (x1 + x >= 0 && x1 + x < width && y1 + y >= 0 && y1 + y < height) {\r\n                        const d = this._kernel[ i ][ 0 ],\r\n                              e = errorLines[ y1 ][ x1 + x ];\r\n\r\n                        e[ 0 ] = e[ 0 ] + er * d;\r\n                        e[ 1 ] = e[ 1 ] + eg * d;\r\n                        e[ 2 ] = e[ 2 ] + eb * d;\r\n                        e[ 3 ] = e[ 3 ] + ea * d;\r\n                    }\r\n                }\r\n            }\r\n        }\r\n\r\n        return pointBuffer;\r\n    }\r\n\r\n    private _fillErrorLine(errorLine : number[][], width : number) : void {\r\n        // shrink\r\n        if (errorLine.length > width) {\r\n            errorLine.length = width;\r\n        }\r\n\r\n        // reuse existing arrays\r\n        const l = errorLine.length;\r\n        for (let i = 0; i < l; i++) {\r\n            const error = errorLine[ i ];\r\n            error[ 0 ]  = error[ 1 ] = error[ 2 ] = error[ 3 ] = 0;\r\n        }\r\n\r\n        // create missing arrays\r\n        for (let i = l; i < width; i++) {\r\n            errorLine[ i ] = [ 0.0, 0.0, 0.0, 0.0 ];\r\n        }\r\n    }\r\n\r\n    private _setKernel(kernel : ErrorDiffusionArrayKernel) {\r\n        switch (kernel) {\r\n            case ErrorDiffusionArrayKernel.FloydSteinberg:\r\n                this._kernel = [\r\n                    [ 7 / 16, 1, 0 ],\r\n                    [ 3 / 16, -1, 1 ],\r\n                    [ 5 / 16, 0, 1 ],\r\n                    [ 1 / 16, 1, 1 ]\r\n                ];\r\n                break;\r\n\r\n            case ErrorDiffusionArrayKernel.FalseFloydSteinberg:\r\n                this._kernel = [\r\n                    [ 3 / 8, 1, 0 ],\r\n                    [ 3 / 8, 0, 1 ],\r\n                    [ 2 / 8, 1, 1 ]\r\n                ];\r\n                break;\r\n\r\n            case ErrorDiffusionArrayKernel.Stucki:\r\n                this._kernel = [\r\n                    [ 8 / 42, 1, 0 ],\r\n                    [ 4 / 42, 2, 0 ],\r\n                    [ 2 / 42, -2, 1 ],\r\n                    [ 4 / 42, -1, 1 ],\r\n                    [ 8 / 42, 0, 1 ],\r\n                    [ 4 / 42, 1, 1 ],\r\n                    [ 2 / 42, 2, 1 ],\r\n                    [ 1 / 42, -2, 2 ],\r\n                    [ 2 / 42, -1, 2 ],\r\n                    [ 4 / 42, 0, 2 ],\r\n                    [ 2 / 42, 1, 2 ],\r\n                    [ 1 / 42, 2, 2 ]\r\n                ];\r\n                break;\r\n\r\n            case ErrorDiffusionArrayKernel.Atkinson:\r\n                this._kernel = [\r\n                    [ 1 / 8, 1, 0 ],\r\n                    [ 1 / 8, 2, 0 ],\r\n                    [ 1 / 8, -1, 1 ],\r\n                    [ 1 / 8, 0, 1 ],\r\n                    [ 1 / 8, 1, 1 ],\r\n                    [ 1 / 8, 0, 2 ]\r\n                ];\r\n                break;\r\n\r\n            case ErrorDiffusionArrayKernel.Jarvis:\r\n                this._kernel = [\t\t\t// Jarvis, Judice, and Ninke / JJN?\r\n                    [ 7 / 48, 1, 0 ],\r\n                    [ 5 / 48, 2, 0 ],\r\n                    [ 3 / 48, -2, 1 ],\r\n                    [ 5 / 48, -1, 1 ],\r\n                    [ 7 / 48, 0, 1 ],\r\n                    [ 5 / 48, 1, 1 ],\r\n                    [ 3 / 48, 2, 1 ],\r\n                    [ 1 / 48, -2, 2 ],\r\n                    [ 3 / 48, -1, 2 ],\r\n                    [ 5 / 48, 0, 2 ],\r\n                    [ 3 / 48, 1, 2 ],\r\n                    [ 1 / 48, 2, 2 ]\r\n                ];\r\n                break;\r\n\r\n            case ErrorDiffusionArrayKernel.Burkes:\r\n                this._kernel = [\r\n                    [ 8 / 32, 1, 0 ],\r\n                    [ 4 / 32, 2, 0 ],\r\n                    [ 2 / 32, -2, 1 ],\r\n                    [ 4 / 32, -1, 1 ],\r\n                    [ 8 / 32, 0, 1 ],\r\n                    [ 4 / 32, 1, 1 ],\r\n                    [ 2 / 32, 2, 1 ],\r\n                ];\r\n                break;\r\n\r\n            case ErrorDiffusionArrayKernel.Sierra:\r\n                this._kernel = [\r\n                    [ 5 / 32, 1, 0 ],\r\n                    [ 3 / 32, 2, 0 ],\r\n                    [ 2 / 32, -2, 1 ],\r\n                    [ 4 / 32, -1, 1 ],\r\n                    [ 5 / 32, 0, 1 ],\r\n                    [ 4 / 32, 1, 1 ],\r\n                    [ 2 / 32, 2, 1 ],\r\n                    [ 2 / 32, -1, 2 ],\r\n                    [ 3 / 32, 0, 2 ],\r\n                    [ 2 / 32, 1, 2 ]\r\n                ];\r\n                break;\r\n\r\n            case ErrorDiffusionArrayKernel.TwoSierra:\r\n                this._kernel = [\r\n                    [ 4 / 16, 1, 0 ],\r\n                    [ 3 / 16, 2, 0 ],\r\n                    [ 1 / 16, -2, 1 ],\r\n                    [ 2 / 16, -1, 1 ],\r\n                    [ 3 / 16, 0, 1 ],\r\n                    [ 2 / 16, 1, 1 ],\r\n                    [ 1 / 16, 2, 1 ]\r\n                ];\r\n                break;\r\n\r\n            case ErrorDiffusionArrayKernel.SierraLite:\r\n                this._kernel = [\r\n                    [ 2 / 4, 1, 0 ],\r\n                    [ 1 / 4, -1, 1 ],\r\n                    [ 1 / 4, 0, 1 ]\r\n                ];\r\n                break;\r\n\r\n            default:\r\n                throw new Error(\"ErrorDiffusionArray: unknown kernel = \" + kernel);\r\n        }\r\n    }\r\n}\r\n\r\n\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/image/array.ts\n **/","/**\r\n * @preserve\r\n * MIT License\r\n *\r\n * Copyright 2015-2016 Igor Bezkrovnyi\r\n *\r\n * Permission is hereby granted, free of charge, to any person obtaining a copy\r\n * of this software and associated documentation files (the \"Software\"), to\r\n * deal in the Software without restriction, including without limitation the\r\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\r\n * sell copies of the Software, and to permit persons to whom the Software is\r\n * furnished to do so, subject to the following conditions:\r\n *\r\n * The above copyright notice and this permission notice shall be included in\r\n * all copies or substantial portions of the Software.\r\n *\r\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\r\n * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\r\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\r\n * IN THE SOFTWARE.\r\n *\r\n * nearestColor.ts - part of Image Quantization Library\r\n */\r\nimport { IImageDitherer } from \"./common\"\r\nimport { HilbertCurveBase } from \"./spaceFillingCurves/hilbertCurve\"\r\nimport { AbstractDistanceCalculator } from \"../distance/abstractDistanceCalculator\"\r\nimport { PointContainer } from \"../utils/pointContainer\"\r\nimport { Palette } from \"../utils/palette\"\r\nimport { Point } from \"../utils/point\"\r\nimport { inRange0to255Rounded } from \"../utils/arithmetic\"\r\n\r\nexport class ErrorDiffusionRiemersma implements IImageDitherer {\r\n    private _distance : AbstractDistanceCalculator;\r\n    private _weights : number[];\r\n    private _errorQueueSize : number;\r\n    private _errorPropagation : number;\r\n    private _max : number;\r\n\r\n    constructor(colorDistanceCalculator : AbstractDistanceCalculator, errorQueueSize : number = 16, errorPropagation : number = 1) {\r\n        this._distance         = colorDistanceCalculator;\r\n        this._errorPropagation = errorPropagation;\r\n        this._errorQueueSize   = errorQueueSize;\r\n        this._max              = this._errorQueueSize;\r\n        this._createWeights();\r\n    }\r\n\r\n    quantize(pointBuffer : PointContainer, palette : Palette) : PointContainer {\r\n        const curve                                                           = new HilbertCurveBase(),\r\n              pointArray                                                      = pointBuffer.getPointArray(),\r\n              width                                                           = pointBuffer.getWidth(),\r\n              height                                                          = pointBuffer.getHeight(),\r\n              errorQueue : {r : number; g : number; b : number; a : number}[] = [];\r\n\r\n        let head = 0;\r\n\r\n        for (let i = 0; i < this._errorQueueSize; i++) {\r\n            errorQueue[ i ] = { r : 0, g : 0, b : 0, a : 0 };\r\n        }\r\n\r\n        curve.walk(width, height, (x, y) => {\r\n            const p = pointArray[ x + y * width ];\r\n            let r   = p.r, g = p.g, b = p.b, a = p.a;\r\n            for (let i = 0; i < this._errorQueueSize; i++) {\r\n                const weight = this._weights[ i ],\r\n                      e      = errorQueue[ (i + head) % this._errorQueueSize ];\r\n\r\n                r += e.r * weight;\r\n                g += e.g * weight;\r\n                b += e.b * weight;\r\n                a += e.a * weight;\r\n            }\r\n\r\n            const correctedPoint = Point.createByRGBA(\r\n                inRange0to255Rounded(r),\r\n                inRange0to255Rounded(g),\r\n                inRange0to255Rounded(b),\r\n                inRange0to255Rounded(a)\r\n            );\r\n\r\n            const quantizedPoint = palette.getNearestColor(this._distance, correctedPoint);\r\n\r\n            // update head and calculate tail\r\n            head       = (head + 1) % this._errorQueueSize;\r\n            const tail = (head + this._errorQueueSize - 1) % this._errorQueueSize;\r\n\r\n            // update error with new value\r\n            errorQueue[ tail ].r = p.r - quantizedPoint.r;\r\n            errorQueue[ tail ].g = p.g - quantizedPoint.g;\r\n            errorQueue[ tail ].b = p.b - quantizedPoint.b;\r\n            errorQueue[ tail ].a = p.a - quantizedPoint.a;\r\n\r\n            // update point\r\n            p.from(quantizedPoint);\r\n        });\r\n\r\n        return pointBuffer;\r\n    }\r\n\r\n    private _createWeights() : void {\r\n        this._weights = [];\r\n\r\n        const multiplier = Math.exp(Math.log(this._max) / (this._errorQueueSize - 1));\r\n        for (let i = 0, next = 1; i < this._errorQueueSize; i++) {\r\n            this._weights[ i ] = (((next + 0.5) | 0) / this._max) * this._errorPropagation;\r\n            next *= multiplier;\r\n        }\r\n    }\r\n}\r\n\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/image/riemersma.ts\n **/","enum Direction {\r\n    NONE = 0,\r\n    UP,\r\n    LEFT,\r\n    RIGHT,\r\n    DOWN,\r\n}\r\n\r\n// Check code against double-entrance into walk (walk=> callback => walk)\r\nexport class HilbertCurveBase {\r\n    private _x : number;\r\n    private _y : number;\r\n    private _d : number;\r\n    private _width : number;\r\n    private _height : number;\r\n    private _callback : (x : number, y : number, d : number) => void;\r\n    private _level : number;\r\n\r\n    walk(width : number, height : number, visitorCallback : (x : number, y : number, d : number) => void) : void {\r\n        this._x        = 0;\r\n        this._y        = 0;\r\n        this._d        = 0;\r\n        this._width    = width;\r\n        this._height   = height;\r\n        this._callback = visitorCallback;\r\n\r\n        const maxBound = Math.max(width, height);\r\n\r\n        this._level = (Math.log(maxBound) / Math.log(2) + 1) | 0;\r\n        this._walkHilbert(Direction.UP);\r\n        this._visit(Direction.NONE);\r\n    }\r\n\r\n    private _walkHilbert(direction : Direction) {\r\n        if (this._level < 1) return;\r\n\r\n        this._level--;\r\n        switch (direction) {\r\n            case Direction.LEFT:\r\n                this._walkHilbert(Direction.UP);\r\n                this._visit(Direction.RIGHT);\r\n                this._walkHilbert(Direction.LEFT);\r\n                this._visit(Direction.DOWN);\r\n                this._walkHilbert(Direction.LEFT);\r\n                this._visit(Direction.LEFT);\r\n                this._walkHilbert(Direction.DOWN);\r\n                break;\r\n\r\n            case Direction.RIGHT:\r\n                this._walkHilbert(Direction.DOWN);\r\n                this._visit(Direction.LEFT);\r\n                this._walkHilbert(Direction.RIGHT);\r\n                this._visit(Direction.UP);\r\n                this._walkHilbert(Direction.RIGHT);\r\n                this._visit(Direction.RIGHT);\r\n                this._walkHilbert(Direction.UP);\r\n                break;\r\n\r\n            case Direction.UP:\r\n                this._walkHilbert(Direction.LEFT);\r\n                this._visit(Direction.DOWN);\r\n                this._walkHilbert(Direction.UP);\r\n                this._visit(Direction.RIGHT);\r\n                this._walkHilbert(Direction.UP);\r\n                this._visit(Direction.UP);\r\n                this._walkHilbert(Direction.RIGHT);\r\n                break;\r\n\r\n            case Direction.DOWN:\r\n                this._walkHilbert(Direction.RIGHT);\r\n                this._visit(Direction.UP);\r\n                this._walkHilbert(Direction.DOWN);\r\n                this._visit(Direction.LEFT);\r\n                this._walkHilbert(Direction.DOWN);\r\n                this._visit(Direction.DOWN);\r\n                this._walkHilbert(Direction.LEFT);\r\n                break;\r\n\r\n            default:\r\n                break;\r\n        }\r\n        this._level++;\r\n    }\r\n\r\n    private _visit(direction : Direction) : void {\r\n        if (this._x >= 0 && this._x < this._width && this._y >= 0 && this._y < this._height) {\r\n            this._callback(this._x, this._y, this._d);\r\n            this._d++;\r\n        }\r\n        switch (direction) {\r\n            case Direction.LEFT:\r\n                this._x--;\r\n                break;\r\n            case Direction.RIGHT:\r\n                this._x++;\r\n                break;\r\n            case Direction.UP:\r\n                this._y--;\r\n                break;\r\n            case Direction.DOWN:\r\n                this._y++;\r\n                break;\r\n        }\r\n    }\r\n}\r\n\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/image/spaceFillingCurves/hilbertCurve.ts\n **/","/**\r\n * @preserve\r\n * Copyright 2015-2016 Igor Bezkrovnyi\r\n * All rights reserved. (MIT Licensed)\r\n *\r\n * iq.ts - Image Quantization Library\r\n */\r\nimport { SSIM } from \"./ssim\"\r\n\r\nexport {\r\n    SSIM\r\n}\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/quality/index.ts\n **/","/**\r\n * @preserve\r\n * Copyright 2015-2016 Igor Bezkrovnyi\r\n * All rights reserved. (MIT Licensed)\r\n *\r\n * ssim.ts - part of Image Quantization Library\r\n */\r\nimport { PointContainer } from \"../utils/pointContainer\"\r\nimport { Y } from \"../constants/bt709\"\r\n\r\n// based on https://github.com/rhys-e/structural-similarity\r\n// http://en.wikipedia.org/wiki/Structural_similarity\r\nconst K1 = 0.01,\r\n      K2 = 0.03;\r\n\r\nexport class SSIM {\r\n    compare(image1 : PointContainer, image2 : PointContainer) {\r\n        if (image1.getHeight() !== image2.getHeight() || image1.getWidth() !== image2.getWidth()) {\r\n            throw new Error(\"Images have different sizes!\");\r\n        }\r\n\r\n        const bitsPerComponent = 8,\r\n              L                = (1 << bitsPerComponent) - 1,\r\n              c1               = Math.pow((K1 * L), 2),\r\n              c2               = Math.pow((K2 * L), 2);\r\n\r\n        let numWindows = 0,\r\n            mssim      = 0.0;\r\n\r\n        //calculate ssim for each window\r\n        this._iterate(image1, image2, (lumaValues1 : number[], lumaValues2 : number[], averageLumaValue1 : number, averageLumaValue2 : number) => {\r\n            //calculate variance and covariance\r\n            let sigxy  = 0.0,\r\n                sigsqx = 0.0,\r\n                sigsqy = 0.0;\r\n\r\n            for (let i = 0; i < lumaValues1.length; i++) {\r\n                sigsqx += Math.pow((lumaValues1[ i ] - averageLumaValue1), 2);\r\n                sigsqy += Math.pow((lumaValues2[ i ] - averageLumaValue2), 2);\r\n\r\n                sigxy += (lumaValues1[ i ] - averageLumaValue1) * (lumaValues2[ i ] - averageLumaValue2);\r\n            }\r\n\r\n            const numPixelsInWin = lumaValues1.length - 1;\r\n            sigsqx /= numPixelsInWin;\r\n            sigsqy /= numPixelsInWin;\r\n            sigxy /= numPixelsInWin;\r\n\r\n            //perform ssim calculation on window\r\n            const numerator   = (2 * averageLumaValue1 * averageLumaValue2 + c1) * (2 * sigxy + c2),\r\n                  denominator = (Math.pow(averageLumaValue1, 2) + Math.pow(averageLumaValue2, 2) + c1) * (sigsqx + sigsqy + c2),\r\n                  ssim        = numerator / denominator;\r\n\r\n            mssim += ssim;\r\n            numWindows++;\r\n\r\n        });\r\n        return mssim / numWindows;\r\n    }\r\n\r\n    private _iterate(image1 : PointContainer, image2 : PointContainer, callback : (lumaValues1 : number[], lumaValues2 : number[], averageLumaValue1 : number, averageLumaValue2 : number) => void) {\r\n        const windowSize = 8,\r\n              width      = image1.getWidth(),\r\n              height     = image1.getHeight();\r\n\r\n        for (let y = 0; y < height; y += windowSize) {\r\n            for (let x = 0; x < width; x += windowSize) {\r\n                // avoid out-of-width/height\r\n                const windowWidth  = Math.min(windowSize, width - x),\r\n                      windowHeight = Math.min(windowSize, height - y);\r\n\r\n                const lumaValues1  = this._calculateLumaValuesForWindow(image1, x, y, windowWidth, windowHeight),\r\n                      lumaValues2  = this._calculateLumaValuesForWindow(image2, x, y, windowWidth, windowHeight),\r\n                      averageLuma1 = this._calculateAverageLuma(lumaValues1),\r\n                      averageLuma2 = this._calculateAverageLuma(lumaValues2);\r\n\r\n                callback(lumaValues1, lumaValues2, averageLuma1, averageLuma2);\r\n            }\r\n        }\r\n    }\r\n\r\n    private _calculateLumaValuesForWindow(image : PointContainer, x : number, y : number, width : number, height : number) : number[] {\r\n        const pointArray            = image.getPointArray(),\r\n              lumaValues : number[] = [];\r\n\r\n        let counter = 0;\r\n\r\n        for (let j = y; j < y + height; j++) {\r\n            const offset = j * image.getWidth();\r\n            for (let i = x; i < x + width; i++) {\r\n                const point           = pointArray[ offset + i ];\r\n                lumaValues[ counter ] = point.r * Y.RED + point.g * Y.GREEN + point.b * Y.BLUE;\r\n                counter++;\r\n            }\r\n        }\r\n\r\n        return lumaValues;\r\n    }\r\n\r\n    private _calculateAverageLuma(lumaValues : number[]) : number {\r\n        let sumLuma = 0.0;\r\n        for (let i = 0; i < lumaValues.length; i++) {\r\n            sumLuma += lumaValues[ i ];\r\n        }\r\n\r\n        return sumLuma / lumaValues.length;\r\n    }\r\n\r\n}\r\n\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/quality/ssim.ts\n **/","/**\r\n * @preserve\r\n * Copyright 2015-2016 Igor Bezkrovnyi\r\n * All rights reserved. (MIT Licensed)\r\n *\r\n * iq.ts - Image Quantization Library\r\n */\r\nimport * as arithmetic from \"./arithmetic\"\r\nimport { HueStatistics } from \"./hueStatistics\"\r\nimport { Palette } from \"./palette\"\r\nimport { Point } from \"./point\"\r\nimport { PointContainer } from \"./pointContainer\"\r\n\r\nexport {\r\n    Point,\r\n    PointContainer,\r\n    Palette,\r\n    HueStatistics,\r\n    arithmetic\r\n}\r\n\n\n\n/** WEBPACK FOOTER **\n ** ./src/utils/index.ts\n **/"],"sourceRoot":""}