Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Color Image Quantization in .NET

I want to reduce the number of unique colors of a bitmap in c#.

The reason I want to do this is that an image which is initially created with three color but due to many factors (including compression) has now more than three colors (i.e neighbour pixels has affected each other)

Any idea of how to do that?

The solution maybe something to convert the whole bitmap from RGB to Indexed color system or some function that can be applied to a single pixel.

Any GDI+ or Emgu (opencv) solutions are good for me.

like image 418
Mo Valipour Avatar asked Jul 08 '11 10:07

Mo Valipour


People also ask

What are the categories of Colour image quantization?

The color image quantization consists of two major phases:(i)design a better colormap with a reduced number of colors (typically 8–256);(ii)create the mapping relationship between the color image and the colormap by which a quantized image is obtained.

How does color quantization work?

In computer graphics, color quantization or color image quantization is quantization applied to color spaces; it is a process that reduces the number of distinct colors used in an image, usually with the intention that the new image should be as visually similar as possible to the original image.


1 Answers

Check out nQuant at http://nquant.codeplex.com. This yields much higher quality than the code in the MSDN article that Magnus references. It also takes the Alpha layer into consideration while the msdn article only evaluates RGB. Source code is available and there is an accompanying blog post that discusses the code and algorithm in detail.

like image 128
Matt Wrock Avatar answered Sep 20 '22 02:09

Matt Wrock