WuXiaoLing有一篇被大量引用的文章专门研究这个问题.
基本思想是把图象中的象素聚类,然后可以用较少的颜色
就可以很真实地表现原图象.这方面的具体理论很复杂.
WXL的算法是一个3D(颜色空间是3D)优化问题,其文章的
贡献在于实现了一个快速算法.
其源代码可以在他的主页上下载.很抱歉现在找不到URL了
/**********************************************************************
C Implementation of Wu's Color Quantizer (v. 2)
(see Graphics Gems vol. II, pp. 126-133)
Author: Xiaolin Wu
Dept. of Computer Science
Univ. of Western Ontario
London, Ontario N6A 5B7
wu@csd.uwo.ca
Algorithm: Greedy orthogonal bipartition of RGB space for variance
minimization aided by inclusion-exclusion tricks.
For speed no nearest neighbor search is done. Slightly
better performance can be expected by more sophisticated
but more expensive versions.
The author thanks Tom Lane at Tom_Lane@G.GP.CS.CMU.EDU for much of
additional documentation and a cure to a previous bug.
Free to distribute, comments and suggestions are appreciated.
**********************************************************************/