From 23e60ae6686e29f2df2cb9c3c029b9208530f7ed Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 21 Mar 2023 18:37:22 -0700 Subject: [PATCH] wip --- dither-image.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dither-image.js b/dither-image.js index f2f7af9..7ecd29d 100644 --- a/dither-image.js +++ b/dither-image.js @@ -537,8 +537,6 @@ function decimate(input, palette, n) { // Median cut! // https://en.wikipedia.org/wiki/Median_cut let buckets = [input.slice()]; - //let initial = dither(palette); - //let buckets = [initial.output.map((i) => atariRGB[palette[i]])]; let medianCut = (bucket, range) => { if (bucket.length < 2) { console.log(bucket); @@ -582,6 +580,7 @@ function decimate(input, palette, n) { .reduce((acc, rgb) => acc.inc(rgb), new RGB(0, 0, 0)) .divide(bucket.length); + // Scale the average to the brightest let avg_luma = rgb.luma(); let lumas = bucket.map((rgb) => rgb.luma()); let brightest = Math.max(...lumas);