Skip to content

nQuantCpp includes top 6 color quantization algorithms for visual c++ producing high quality optimized images.

License

Notifications You must be signed in to change notification settings

YChuan1115/nQuantCpp

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nQuantCpp

nQuantCpp includes top 6 color quantization algorithms for visual c++ producing high quality optimized images.

Divisive hierarchical clustering algorithm, Fast pairwise nearest neighbor based algorithm, NeuQuant Neural-Net Quantization Algorithm, Xialoin Wu's fast optimal color quantizer, Efficient, Edge-Aware, Combined Color Quantization and Dithering, Spatial color quantization

Fast pairwise nearest neighbor based algorithm minimized color loss for photo having red lips and supports 256 or less colors with transparency. NeuQuant Neural-Net Quantization Algorithm produces smooth photo quantization especially for natual landscape photo and fully supports image having transparent color. Xialoin Wu's fast optimal color quantizer fully supports image having transparent color. DL3 Quantization supports 256 or less colors. Spatial color quantization supports 64 or less colors. nQuantCpp also provides a command line wrapper in case you want to use it from the command line.

Either download nQuantCpp from this site or add it to your Visual Studio project seamlessly. The main features show up to discuss would be the error diffusion and dithering.

Here some examples of output:

Original image
Reduced to 256 colors by Divisive hierarchical clustering algorithm
Reduced to 256 colors by NeuQuant Neural-Net Quantization Algorithm
Reduced to 16 colors by Fast pairwise nearest neighbor based algorithm
Reduced to 16 colors by Xialoin Wu's fast optimal color Quantization Algorithm

Original photo

Reduced to 256 colors by NeuQuant Neural-Net Quantization Algorithm
Reduced to 256 colors by Fast pairwise nearest neighbor based algorithm

Original image

Fast pairwise nearest neighbor based algorithm with CIELAB color space with 16 colors
High quality and fast
Fast pairwise nearest neighbor based algorithm with CIELAB color space with 16 colors

Efficient, Edge-Aware, Combined Color Quantization and Dithering with 16 colors
Higher quality for 32 or less colors but slower
Efficient, Edge-Aware, Combined Color Quantization and Dithering with 16 colors

Spatial color quantization with 16 colors
Higher quality for 32 or less colors but the slowest
Spatial color quantization with 16 colors

If you are using the command line. Assuming you are in the same directory as nQuantCpp.exe, you would enter: nQuantCpp yourImage.jpg /m 16

nQuantCpp will quantize yourImage.jpg and create yourImage-PNNLABquant16.png in the same directory.

The readers can see coding of the error diffusion and dithering are quite similar among the above quantization algorithms. Each algorithm has its own advantages. I share the source of color quantization to invite further discussion and improvements. Such source code are written in C++ to gain best performance. It is readable and convertible to c#, java, or javascript. Welcome for C++ experts for further improvement or provide color quantization algorithms better than the above algorithms. Please send email to miller.chan@gmail.com to report issues or give suggestions.

About

nQuantCpp includes top 6 color quantization algorithms for visual c++ producing high quality optimized images.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 99.9%
  • C 0.1%