新的iTunes 11有一个非常好的查看专辑歌曲列表的视图,在专辑封面的功能中为字体和背景选择颜色。有人知道算法是怎么运作的吗?
当前回答
根据@Seth的回答,我使用PHP和Imagick实现了在图片的两个横向边界中获得主色调的算法。
https://gist.github.com/philix/5688064#file-simpleimage-php-L81
它被用来填充http://festea.com.br封面照片的背景
其他回答
根据@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项目的新功能。对于提高配色效果,我也有一些新的想法。
我只是写了一个JS库,实现了@Seth所描述的大致相同的算法。可以在github.com/arcanis/colibrijs和NPM上以colibrijs的形式免费获得。
我在不同的上下文中问了同样的问题,并被指向http://charlesleifer.com/blog/using-python-and-k-means-to-find-the-dominant-colors-in-images/的一个学习算法(k Means),它使用图像中的随机起点大致做同样的事情。这样,算法就能自己找到主色调。
Panic的韦德·科斯格罗夫写了一篇不错的博客文章,描述了他的算法实现,类似于iTunes中的算法。它包括Objective-C中的一个示例实现。
你也可以签出ColorTunes,它是Itunes相册视图的HTML实现,它使用MMCQ(中值剪切颜色量化)算法。
推荐文章
- 找出质数最快的算法是什么?
- 圆线段碰撞检测算法?
- 求有向图中的所有循环
- JavaScript -从当前日期开始获取一周的第一天
- 如何比较两种颜色的相似/不同
- 应用程序加载器在上传iOS应用程序时卡住了“与iTunes商店进行身份验证”
- Java GUI框架。选择什么?Swing, SWT, AWT, SwingX, JGoodies, JavaFX, Apache Pivot?
- 有效的方法应用多个过滤器的熊猫数据框架或系列
- 如何在扑动中垂直和水平居中文本?
- 哪些是遗传算法/遗传规划解决方案的好例子?
- 如何在O(n)中找到长度为n的无序数组中的第k大元素?
- 一个用于膨胀/收缩(抵消,缓冲)多边形的算法
- linux的图形化DIFF程序
- 我如何使用Node.js Crypto创建HMAC-SHA1哈希?
- 如何用动态规划确定最长递增子序列?