颜色量化

要想从真彩色图像所能表现的大约16M中颜色中选取最代表性或者出现频率最高的256中颜色:

主要有以下3种 :
 流行色算法(popularity algorithm)
是对彩色图像中所有颜色出现的次数所统计分析,即创建一个数组记录各种颜色和该颜色出现的频率,然后把出现次数最多(频率最大)的236中颜色作为调色板的颜色.该算法实现起来比较简单,但该算法可能丢失一些出现频率较低但是视觉效果明显的信息.

The initial idea of the popularity algorithm is to build the colormap by finding the K most frequently appearing colors in the original image.

Therefore the colors are stored in a histogram. The K most frequently occuring colors are extracted and they are made the entries in the color table. Now the true image can be quantized.

 

Popularity algorithms are another form of uniform quantization. However, instead of dividing the color space into 256 regions these algorithms break the color space into much smaller, and consequently many more, regions. One possible implementation is to divide the space into regions 4x4x4 in size (262,144 regions). The original colors are again mapped to the region they fall in. The representative color for each region is the average of the colors mapped to it. The color map is selected by taking the representative colors of the 256 most popular regions (the regions that had the most colors mapped to them). If a non-empty region is not selected for the color map its index into the color map (the index that will be assigned to colors that map to that region) is then the entry in the color map that is closest (Euclidean distance) to its representative color).

中位切分算法(median-cut algorithm)
在RGB彩色空间中,R,G,B三基色对应于空间的3个坐标轴,并将每一个坐标轴都量化到0-255.

0对应全黑,255对应全白.

这样就形成了一个边长256的彩色立方体.所有可能的颜色都对应于立方体上的一个点.将彩色立方体切分成236个小立方体(每个小立方体中都包含了相同数量的图像中出现的颜色点.求出每一个 小立方体的中心点,这些中心点所表示的颜色就是最能代表图像颜色特征的236种颜色).中位切分法被广泛引用,但该算法设计复杂的排序工作,而且内存开销较大.

Heckbert’s median-cut algorithm is an image-based, color-quantization algorithm that gives good results for many images. If properly implemented, it’s also quite fast.

  1. Create a block or box surrounding the points; it should be just large enough to contain them all.
  2. While the number of blocks is less than the desired palette size:
    1. Find the block with the longest side out of all blocks.
    2. Cut this block into two blocks along its longest side. Cut it in such a way that half of the points inside the block fall into each of the two new blocks (that is, we split it through the median, thus the name).
    3. Shrink these two new boxes so that they just barely contain their points.
  3. Average the points in each box to obtain the final set of palette colors.

八叉树颜色量化算法
将图像的R,G,B颜色值分布到层状的八叉树中.八叉树的深度最多为9层,即根节点层和分别表示8位的R,G,B值的8个节点层.较及其不重要的R,G,B值的位(R,G,B右边的位).因此,为了提高效率和节省内存,通常并不把8位R,G,B分量值都用上

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

生活在西班牙

自己动手丰衣足食

BlueAsteroid

Just another WordPress.com site

Jing's Blog

Just another WordPress.com site

Start from here......

我的心情魔方

天才遠私廚

希望能做一個分享各種資訊的好地方

语义噪声

西瓜大丸子汤的博客

笑对人生,傲立寰宇

Just another WordPress.com site

Where On Earth Is Waldo?

A Project By Melanie Coles

the Serious Computer Vision Blog

A blog about computer vision and serious stuff

Cauthy's Blog

paper review...

Cornell Computer Vision Seminar Blog

Blog for CS 7670 - Special Topics in Computer Vision

datarazzi

Life through nerd-colored glasses

Luciana Haill

Brainwaves Augmenting Consciousness

槑烎

1,2,∞

Dr Paul Tennent

and the university of nottingham

turn off the lights, please

A bunch of random, thinned and stateless thoughts around the Web

%d bloggers like this: