dragon66 / icafe

Java library for reading, writing, converting and manipulating images and metadata
Eclipse Public License 1.0
203 stars 58 forks source link

Add better quantization algorithm #16

Closed dragon66 closed 8 years ago

dragon66 commented 8 years ago

Currently, the only quantization algorithm used is "popularity". It's quick and produces good result if combined with dither process. But sometimes, when better image quality is required, we need a better algorithm. We may not even need a dither process in this case.

dragon66 commented 8 years ago

Added Xiaolin Wu's color quantization algorithm (see Graphics Gems vol. II, pp. 126-133) and NeuQuant - neural network algorithm. The resulting image quality is excellent even without dither. The only thing left is to figure out a way to automatically deal with transparent color.

The following are the images before and after quantization: [Original] original [Quantized - Wu's algorithm] quantized [Quantized+dither] withdither [NeuQuant - neural network algorithm] neuquant

dragon66 commented 8 years ago

Added code to automatically deal with transparency.