gpt4 book ai didi

php - 按颜色对照片进行分组

转载 作者:可可西里 更新时间:2023-11-01 12:39:01 25 4
gpt4 key购买 nike

我有相当多的照片和 RGB 颜色图(假设大约有 100 种颜色)。如何按颜色对图片进行分组并获得如下内容:http://labs.ideeinc.com/multicolr

我目前的想法是:使用 ImageMagick,对每张照片执行此操作:

  1. 将其调整为较小的尺寸,以便可以更快地处理它。
  2. Quantize它没有使用我选择的颜色图进行抖动。
  3. 获取照片的 histogram获取每种颜色出现的次数。
  4. 将颜色存储在数据库中,但我还没有想出什么是快速检索的最佳方法。

你知道更好更有效的方法吗?我选择的语言是 PHP,因为所有繁重的处理都将由 ImageMagick 完成,数据库是 PostgreSQL。提前致谢!

最佳答案

我注意到您已经知道如何从图像中获取最相关的颜色。不要过度调整图像大小,因为直方图可能看起来不同。

数据库可能看起来像这样:

图像表:

image_id | image_file

颜色表:

color_id | color_rgb

图像颜色表:

image_id | color_id | color_percent

color_percent 列将用于分组/where 子句

获取图片:

select
image_id
sum(color_percent)/count(color_percent) as relevance
from
image_color
where
color_id IN (175, 243) # the colors you want to involve in this search
and color_percent > 10 # this will drop results with lower significance
group by
image_id
order by
relevance

关于php - 按颜色对照片进行分组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3279501/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com