This commit is contained in:
Brooke Vibber 2023-03-18 20:37:58 -07:00
parent 11325a16d8
commit a8bbcb21cd

View file

@ -489,6 +489,8 @@ function decimate(input, palette, n, inputError) {
let reserved = [0]; // black
//let reserved = [0, 15]; // black, white
//let reserved = [0, 5, 10, 15]; // grayscale
//let reserved = [0, 0x48, 0x78, 15]; // vaporwave
//let reserved = [0, 0x3c, 0x78, 15]; // red/blue/white
let keepers = new Uint8Array(256);
for (let i of reserved) {
@ -508,18 +510,7 @@ function decimate(input, palette, n, inputError) {
}
//let coolFactor = popularity[i];
let coolFactor = 0;
if (popularity[i]) {
for (let x = 0; x < width; x++) {
if (output[x] == i) {
// Scale up the scoring for close matches to prioritize
// color accuracy over raw linear usage.
//coolFactor += (fitness[x] ** 2);
coolFactor += (fitness[x] ** 4);
}
}
}
let coolFactor = (fitness[i] ** 2) * popularity[i];
if (coolFactor < least) {
pick = i;