cubearth
cubearth

Reputation: 1153

how to perform color quantization in matlab or otherwise

I am implementing a machine learning algorithm in matlab, and was doing some reading up on the color range of the human eye, and was informed that the human eye can only perceive about 17,000 colors, where as the images I have about 256^3 colours. What is the best way to quantization my images, in matlab or otherwise. Also, as a side question in terms of machine learning, which one is better to use bitmap or jpeg?

Upvotes: 2

Views: 1615

Answers (3)

Max Plank
Max Plank

Reputation: 1

Color Reduction Using K-Means Clustering (Matlab).

Upvotes: 0

KiwiBarns
KiwiBarns

Reputation: 111

If your colour quantisation aims to somehow mimic human perception I recommend moving from the sRGB space to something more bio-inspired like LAB where L stands for overall luminance, A for the red-green colour pair and B for yellow-blue. Using LAB will allow you a first stab at "illumination invariant" colour quantisation. There is a number of RGB2Lab conversion codes on the web. Then I would discard the L channel completely unless you also want to encode black and white.

Finally, the 17000 colours number claim is meaningless. Men perceive 7 colours: red purple pink orange yellow green blue.

Upvotes: 2

ypnos
ypnos

Reputation: 52317

JPEG is a lossy format. You should not use it if your input data is not already JPEG. Even if so, you should not re-compress your data to avoid introduction of further artifacts.

A very simple, yet popular method for color quantization is the k-means algorithm. You can find it in Matlab. This is a good starting point. However, there exist a broad range of paradigms and methods in recent research.

Upvotes: 2

Related Questions