Detect main colors in an image with PHP

前端 未结 7 2046
走了就别回头了
走了就别回头了 2020-11-27 12:05

I am trying to replicate the functionality that Dribbble.com does with detecting the predominant colors in an Image. In the image below you can see a screenshot from Dribbb

相关标签:
7条回答
  • 2020-11-27 12:30

    The page you linked to has a link to the source code on GitHub so if you want to know exactly how they are doing you could replicate their source in PHP.

    The big difference between how they are doing it and how you are doing it, is that they are using clustering to find the color. Instead of rounding the color when they store it, they are storing all of the raw colors in an array. Then they loop through this array until they find a cluster that has the highest ratio of points in the cluster to number of colors in the cluster. The center point of this is the most common color. The palette is then defined by the next highest sets of clusters, with some logic to prevent near complete overlap of the clusters.

    0 讨论(0)
提交回复
热议问题