A quick log about color quantisation
Hello everyone! Today I was looking into an unusual(for me) concept, Color Quantisation. As I discussed in my previous blog, I was planning to do a hobby project. This hobby project involved the concept of Color Quantisation. I started researching about the topic and I guess I have some ample knowledge to discuss about it here.
What it is
Color Quantisation is the process of reducing the disntict number of colors used in a image to a lesser number, in such a way that the reduced image still best represents the original image.
How to do that
It requires us to basically have an array of rgba values for every pixel in the image. Then from the rgba array, we need to cluster the values in the set of 4 (R,G,B,A). This way we can reduce the number of colors from the original image.
Algorithms to use
As far as I researched I came across a good number of resources discussing about various algorithms to implement. Out of these many algorithms, I guess the top three are,
- Median cut algorithm
- Octree based quantisation algorithm
- K means clustering algorithm
My findings
Since K-means depends on the user based/randomized value for “K”, It doesn’t yeild consistent color reduction. So an somewhat ideal algorithm’s computation should depend on the target image for consistent color reduction.
I could’nt wrap my head around Octree based quantisation, so I’m gonna skip that as of now. Finally I’m going to settle with Median cut Algorithm
My plan
I’m still learning about Median cut algorithm, and planning to write my own implementation from scratch. Currently I’m learning from some already existing implementations in other languages, as well as from the official median cut wiki
Will log about my progress with the algorithm and also about the project.
Until the signing off,
~/CR08