If that sounds interesting and you are ready to take on a challenging
Python programming project, then this book is for you.
You will learn about technical subjects such as:
- the median cut algorithm,
- the k-means clustering algorithm,
- array programming in NumPy,
- error diffusion dithering,
- ordered dithering, and
- different color spaces.
Still, it’s a practical book. There is some theory, but only what you
need to understand the applications. The first part is a beginner’s
guide to median cut and its improvements. The rest goes into more
technical detail for advanced readers.
Updates on the book
Are you interested in news on Palette Programming? Then subscribe to the book
waiting list below.
Updates at most once per month. Unsubscribe any time.
The full book will be published in 2027. First as a
digital edition,
followed by a printed physical version. The digital format includes a
PDF and an ebook, though a color display is recommended.
See how it looks below↓ or check out the table of contents.
Book information
- Release date (planned)
- March 2027
Early Access: available now
- Author
- Pekka R. H. Väänänen
- Format
- Full-color, 300 pp. Perfect-bound softcover.
PDF, EPUB
- Cover design
- Janya Markevich
How it’s structured
The first third of the book is a step-by-step guide to writing a
“baseline” algorithm that’s both simple and effective. It has all the
information needed to write a fully functional color reduction tool.
Part two introduces practical tricks everyone uses but textbooks
often ignore such as palette color selection for ordered dithering.
Part three discusses advanced methods of color quantization, for
example different k-means initialization schemes and PCA-based top-down
clustering.
Table of contents
Part 1: The Baseline Method
- Introduction
- Popularity and median cut color quantization
- Palette refinement with K-means
- Variance-based median cut
- Error diffusion
dithering
- End of part one: The Baseline Method
vs Adobe Photoshop
Part 2: Dithering, Color and Vision
- Lesser-known error diffusion tricks
- Dithering solely with noise
- Introduction to ordered dithering
- Ordered dither color selection
- Alternative color spaces and their limits
- Sharpening the image structure
- How to deal with transparency
Part 3: Hi-Tech Color Quantization
- Wu’s famous 1991 technique
- The axis of greatest variation
- Going all in on k-means
- Integrated reduction and dithering
From the author
January 5th, 2026
Hello! My name is Pekka Väänänen and I’m a software engineer. This
book started when I became obsessed with the color quantization problem.
A lot of what I learned from reading open source code such as libimagequant and exoquant.c wasn’t
mentioned in any textbook. I then initiated excavations in the academic
literature, and discovered remains of even more techniques unknown to
the general public. That’s how the book concept started to form.
I love programming and started trying out different color
quantization algorithms myself, building the experimental VariQuant GUI tool in
the process. Numerical programming has been my hobby since 2013 when I
participated in Andrew Ng’s popular Machine Learning online
course. That’s why the code in the book is in Python: it’s the standard
tool in this field.
But why should anyone study this old stuff? Didn’t
we evolve beyond 256-color GIFs for a reason? Sure, display technology
has improved, but I sincerely believe we should use old computers for
longer. Producing electronics takes a lot of energy and natural
resources. Both are something we should conserve.
Real progress involves learning new ways to do old things better, and
not just relying on hardware advances for new capabilities. I hope by
popularizing the art of color quantization I’ll encourage others to work
on better tooling for retro platforms, which should lead to a higher
appreciation of aging hardware. The same techniques can also be applied
in modern software, for example to optimize image sizes on the web to
lower data transmission costs.
–Pekka
Author bio
Pekka R. H. Väänänen (M.Sc. computer science) is a software engineer
who writes about computer graphics on his website at 30fps.net.
He has worked on 3D model streaming and robot simulations at Umbra,
and with 3D reconstruction and VR headset tracking at Varjo.
He also hacked on 2D graphics drivers as an intern at NVIDIA, a long
time ago.
News
- November 24th, 2026
- Early access release is out!
- Updated sample chapter, table of contents, and book specs
- November 5th, 2026
- Updated the table of contents and early access release date
- Added a new “articles” section
- October 16th, 2026
- Updated table of contents and the release date estimate.
- Added some code to the archive.
- May 25th, 2026
- Created the archive page.
- April 23rd, 2026
- Table of contents updated with more dithering related chapters.
- Book subtitle changed to better reflect the new content.