新的iTunes 11有一个非常好的查看专辑歌曲列表的视图,在专辑封面的功能中为字体和背景选择颜色。有人知道算法是怎么运作的吗?


当前回答

根据@Seth-thompson的回答和@bluedog的评论,我建立了一个小的Objective-C (Cocoa-Touch)项目来生成图像功能的配色方案。

你可以在以下网址查看项目:

https://github.com/luisespinoza/LEColorPicker

目前,LEColorPicker正在做:

Image is scaled to 36x36 px (this reduce the compute time). It generates a pixel array from the image. Converts the pixel array to YUV space. Gather colors as Seth Thompson's code does it. The color's sets are sorted by count. The algorithm select the three most dominant colors. The most dominant is asigned as Background. The second and third most dominants are tested using the w3c color contrast formula, to check if the colors has enought contrast with the background. If one of the text colors don't pass the test, then is asigned to white or black, depending of the Y component.

现在,我将检查ColorTunes项目(https://github.com/Dannvix/ColorTunes)和Wade Cosgrove项目的新功能。对于提高配色效果,我也有一些新的想法。

其他回答

根据@Seth的回答,我使用PHP和Imagick实现了在图片的两个横向边界中获得主色调的算法。

https://gist.github.com/philix/5688064#file-simpleimage-php-L81

它被用来填充http://festea.com.br封面照片的背景

我在不同的上下文中问了同样的问题,并被指向http://charlesleifer.com/blog/using-python-and-k-means-to-find-the-dominant-colors-in-images/的一个学习算法(k Means),它使用图像中的随机起点大致做同样的事情。这样,算法就能自己找到主色调。

根据@Seth-thompson的回答和@bluedog的评论,我建立了一个小的Objective-C (Cocoa-Touch)项目来生成图像功能的配色方案。

你可以在以下网址查看项目:

https://github.com/luisespinoza/LEColorPicker

目前,LEColorPicker正在做:

Image is scaled to 36x36 px (this reduce the compute time). It generates a pixel array from the image. Converts the pixel array to YUV space. Gather colors as Seth Thompson's code does it. The color's sets are sorted by count. The algorithm select the three most dominant colors. The most dominant is asigned as Background. The second and third most dominants are tested using the w3c color contrast formula, to check if the colors has enought contrast with the background. If one of the text colors don't pass the test, then is asigned to white or black, depending of the Y component.

现在,我将检查ColorTunes项目(https://github.com/Dannvix/ColorTunes)和Wade Cosgrove项目的新功能。对于提高配色效果,我也有一些新的想法。

Panic的韦德·科斯格罗夫写了一篇不错的博客文章,描述了他的算法实现,类似于iTunes中的算法。它包括Objective-C中的一个示例实现。

你也可以签出ColorTunes,它是Itunes相册视图的HTML实现,它使用MMCQ(中值剪切颜色量化)算法。