wip aslfkjlfjsdlkjd
This commit is contained in:
parent
89db2f3d1d
commit
fdb20b47ec
1 changed files with 34 additions and 20 deletions
|
@ -566,31 +566,45 @@ function decimate(input, palette, n, inputError, y) {
|
||||||
console.log('end', decimated);
|
console.log('end', decimated);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// fitness
|
// popularity? not really working right
|
||||||
// first, dither to the total atari palette
|
// first, dither to the total atari palette
|
||||||
while (decimated.length > n) {
|
while (decimated.length > n) {
|
||||||
console.log(`y ${y}`);
|
//console.log(y);
|
||||||
let worstFitness = Infinity;
|
|
||||||
let nextPalette = null;
|
|
||||||
for (let i = 0; i < decimated.length; i++) {
|
|
||||||
if (keepers[i]) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
let without = decimated.slice();
|
|
||||||
without.splice(i, 1);
|
|
||||||
let {popularity, fitness} = dither(decimated);
|
|
||||||
|
|
||||||
let total = 0;
|
let {popularity, fitness, output} = dither(decimated);
|
||||||
for (let n of fitness) {
|
let pops = [];
|
||||||
total += n;
|
let fits = [];
|
||||||
}
|
pops.fill(0, 0, 256);
|
||||||
let avg = total / fitness.length;
|
fits.fill(0, 0, 256);
|
||||||
if (avg < worstFitness) {
|
for (let i = 0; i < decimated.length; i++) {
|
||||||
worstFitness = avg;
|
let c = decimated[i];
|
||||||
nextPalette = without;
|
pops[c] = popularity[i];
|
||||||
|
for (let x = 0; x < fitness.length; x++) {
|
||||||
|
if (output[x] === i) {
|
||||||
|
fits[c] += fitness[x];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
decimated = nextPalette;
|
let metric = (c) => {
|
||||||
|
let rgb = atariRGB[c];
|
||||||
|
let max = Math.max(rgb.r, rgb.g, rgb.b);
|
||||||
|
let fit = fits[c];
|
||||||
|
let pop = pops[c];
|
||||||
|
return pop;
|
||||||
|
}
|
||||||
|
|
||||||
|
let a = decimated.slice();
|
||||||
|
// temporarily strip the reserved items
|
||||||
|
a = a.filter((color) => !keepers[color]);
|
||||||
|
a = a.filter((color) => popularity[color]);
|
||||||
|
a.sort((a, b) => {
|
||||||
|
return metric(b) - metric(a);
|
||||||
|
});
|
||||||
|
console.log(a);
|
||||||
|
a = reserved.concat(a);
|
||||||
|
decimated = a.slice(0, n);
|
||||||
|
//decimated = a.slice(0, decimated.length - 1);
|
||||||
|
//console.log(decimated);
|
||||||
}
|
}
|
||||||
//console.log('end', decimated);
|
//console.log('end', decimated);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue