Reducing the Palette
Color quantization reduces a full-color image (up to 16,777,216 colors) to a small palette — typically 2 to 256 colors. The challenge lies in choosing which colors to keep and how to map every original color to its nearest palette entry.
Algorithms
// Median-cut quantization (simplified)
function medianCut(colors: RGB[], depth: number): RGB[] {
if (depth === 0) return [average(colors)];
const axis = longestAxis(colors); // R, G, or B
colors.sort((a, b) => a[axis] - b[axis]);
const mid = Math.floor(colors.length / 2);
return [
...medianCut(colors.slice(0, mid), depth - 1),
...medianCut(colors.slice(mid), depth - 1),
];
}The Aesthetic Power of Constraint
Combined with dithering, quantization becomes a powerful aesthetic tool. The restricted palette creates a distinctive retro look — evoking CGA, EGA, and Game Boy eras — while dithering recovers the illusion of smooth gradients. The tension between limited means and rich results is central to the BVDART aesthetic.
