Been playing with this a bit and have come up with a pretty ok color quantization algorithm.
Basically for each pixel in the image I find the color in the current palette which has the shortest euclidean distance to the color of the current pixel, and move this palette color and the two adjacent colors slightly towards that of the current pixel. It's similar to the NeuQuant algorithm but much simpler and doesn't give as good results. I haven't tried the oct-tree algorithm but it will probably give better results as well.
The images show some tests with the default palette of 32 grays + 6*6*6 colors compared to an adapted palette.
|