Hello there! In this post, as promised, I’ll explain a little about vector quantization. I’ll try to explain more how it works and not focus in the math, ok?
So, what’s the main idea behind vector quantization? The idea is pretty simple. Imagine that each pixel actually is a 3D vector (since each pixel has three colors – RGB), we could then separate then into 64 groups and for each group, find the average vector, which will represent the whole group. I said 64 vectors since in the previous post, we used 2 bits for each color, so 6 bits in total, which give us up to 64 colors.
So, for a group of vectors, we will represent the average of all vectors of that group by a single vector, or, by a single color! In the left I show an example of a group of only 10 vectors as example. Ok, but how do we do that in practice?
Now we enter in the obscure world of mathematics! =D For the beginners I’ll try to explain the easiest way possible, ok?
First as discussed, we take our image and transform then in a group of vectors. Then we calculate the covariance and we use it to calculate the eigenvector. Then we project each vector on eigenvector and also the mean vector of the group.
Then we split the group in two groups. One with vectors whose projection is greater than the mean projection and another with vectors whose projection is smaller. We do that until we can split into 64 groups. In the end, we take the mean of each group to get the 64 possible colors (or set the entire group with this value).
When transform back vectors to image, we’ll have the final image with only 64 colors but the result is much better as we can see in the image above.
That’s all!
Marcelo
Leave a Reply