Do you want to learn retro computer graphics? Are you also interested in machine learning or numerical programming? I’m writing a book just for you.
This textbook explains how to represent images using small color palettes. It’s an old computer graphics problem, and we apply lessons from statistics, computer science, and human biology to solve it.
For the first time, both the classic 90’s techniques and later developments are discussed and logically connected in the same book. Python code for all algorithms are included and published online for free.
The subjects include the median cut algorithm, k-means clustering and its variants, dithering, perceptual color spaces, plus derivations for some formulas not explained anywhere else. There’s also a guide to the NumPy library.
The book will be published in 2026 first as a digital edition PDF (including a smaller version for e-readers) followed by a self-published print edition.
| Release date | 2026 (planned) |
| Format |
200 pages, full-color, ring-bound softcover, PDF, e-reader PDF. |
| Level | Intermediate |
| Supplements | Online code examples |
Introduction
Part 1: Setting the Baseline
Part 2: Practical Improvements
Part 3: Theoretical Advances
This textbook is written in an accessible style (see the sample chapter) that grounds all theory in practical examples. While I assume a couple of years of programming experience and a reader brave enough to face an equation every once in a while, this is not aimed at experts. Instead, I try to serve readers who want to try out the methods themselves in practice.
The first third of the book is a step-by-step guide to writing a “baseline” algorithm that’s both simple and effective. I think it’s great project for anyone interested in developing their skill as a programmer. The rest of the book introduces both practical tricks and theoretical concepts to improve the results, but don’t culminate in a single program like in the beginning.

First of all, I enjoy studying technical subjects in detail and explaining them as clearly as I can. I’ve been publishing such writing on my website at 30fps.net. My interests tend to gravitate towards retro computing so that’s what I’ve been writing about.
Back in 2013 I participated in Andrew Ng’s popular Machine Learning online course, and been playing with numerical programming ever since. That’s why the code in the book is in Python: it’s the standard machine learning tool. So in a way I’m writing a textbook on how to use modern tools to do retro graphics. It also happens to be my hobby.
But why should anyone study this old stuff? Didn’t we evolve beyond 256-color MS-DOS times for a reason? Sure, display technology has improved, but I sincerely believe we should use old computers for longer before they get declared e-waste and shipped to the other side of the globe for dismantling.
Real progress involves learning new ways to do old things better; not just relying on hardware advances for new capabilities. And when it comes color quantization, reconstructing images with limited palettes, there have been new developments that nobody talks about. I’ll be first to admit that the new techniques don’t always result better visual quality but they are simpler, either technically or conceptually. This makes them easier to apply, which I hope will lead to better art tooling for retro platforms, and thus to higher appreciation of aging hardware.
Pekka R. H. Väänänen is a software engineer and a writer. He has worked on 3D geometry optimization and robot simulations at Umbra Software, and with 3D reconstruction and VR headset tracking at Varjo. He also hacked on 2D graphics drivers when he was an intern at NVIDIA, a long time ago.
You can also find me on my website, Mastodon, Bluesky, and YouTube.