From cecd03135269c215eebc48b3dd394f408f0792ee Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Tue, 21 Mar 2023 06:28:03 -0700 Subject: [PATCH] kinda good, highest of all chans --- dither-image.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/dither-image.js b/dither-image.js index c6f2348..080ad74 100644 --- a/dither-image.js +++ b/dither-image.js @@ -587,7 +587,15 @@ function decimate(input, palette, n, inputError, y) { //let rgb = bucket.slice().sort((a, b) => b.luma() - a.luma())[bucket.length - 1]; // Take the median color in the bucket - let rgb = bucket[bucket.length >> 1]; + //let rgb = bucket[bucket.length >> 1]; + + // Combine the brightest of each channel + // this is kinda good + let rgb = new RGB( + Math.max(...bucket.map((rgb) => rgb.r)), + Math.max(...bucket.map((rgb) => rgb.g)), + Math.max(...bucket.map((rgb) => rgb.b)) + ); // Take the luma-median color in the bucket //let rgb = bucket.slice().sort((a, b) => b.luma() - a.luma())[bucket.length >> 1];