cap rgb input before doing comparisons for error dithering
This commit is contained in:
parent
63ae0e8cff
commit
7c4b118bed
1 changed files with 10 additions and 0 deletions
|
@ -430,6 +430,7 @@ function decimate(input, palette, n, inputError) {
|
||||||
if (inputError) {
|
if (inputError) {
|
||||||
rgb.inc(inputError[x]);
|
rgb.inc(inputError[x]);
|
||||||
}
|
}
|
||||||
|
rgb.cap();
|
||||||
|
|
||||||
// find the closest possible color
|
// find the closest possible color
|
||||||
// @todo consider doing the difference scoring in luminance and hue spaces
|
// @todo consider doing the difference scoring in luminance and hue spaces
|
||||||
|
@ -476,6 +477,15 @@ function decimate(input, palette, n, inputError) {
|
||||||
|
|
||||||
let decimated = palette.slice();
|
let decimated = palette.slice();
|
||||||
|
|
||||||
|
// force to grayscale
|
||||||
|
//decimated = [0, 5, 10, 15];
|
||||||
|
|
||||||
|
// force to rgb
|
||||||
|
//decimated = [0, 0x36, 0xb6, 0x86];
|
||||||
|
|
||||||
|
// force to rWb
|
||||||
|
//decimated = [0, 0x36, 0x0f, 0x86];
|
||||||
|
|
||||||
while (decimated.length > n) {
|
while (decimated.length > n) {
|
||||||
let {popularity, fitness, output} = dither(decimated);
|
let {popularity, fitness, output} = dither(decimated);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue