Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image palette reduction

I am playing with computer graphics programming for the first time. I want to convert RGB (24-bit) images to indexed-palette (8-bit) images (like GIF). My initial thought is to use k-means (with k=256).

How would one go about picking the optimal palette for a given image? This is a learning experience for me, so I would prefer an overview-type answer to source code.

Edit: Dithering is currently off-topic. I am only referring to "simple" color conversion, psycho-visual/perceptual models aside; color-space is also currently off-topic, though moving between color-spaces is what got me thinking about this in the first place :)

like image 972
Trevor Avatar asked Oct 03 '10 08:10

Trevor


People also ask

What is color reduction?

The method of color reduction is very simple: every color of the original picture is replaced by an appropriate color from the limited palette that is accessible. Unfortunately, the resulting image can become discolored and less attractive.

What is an image palette?

An image palette is a collection of colors that an image uses — similar to a painter's palette. An image palette is a subset of all the colors your monitor can display. Not all images have image palettes — only images with color depths between 16 and 256 colors have palettes that you can fine-tune and edit.

How do I limit the number of colors in a photo?

You can use "posterize" option on the Image menu and define the number of colors. In the case you mention, its bases on grayscale, so converting your (color) image to grayscale and then posterize it to the selectable amount of colors will do it.


1 Answers

  • http://en.wikipedia.org/wiki/Color_quantization
  • Octree
  • Median-cut
  • K-means
  • Gamut subdivision
  • http://www.cs.berkeley.edu/~dcoetzee/downloads/scolorq/
like image 139
rwong Avatar answered Sep 28 '22 21:09

rwong