First off, I don't mean google image search!

首先,我不是指谷歌图片搜索!

I would like to give users the ability to select a hex color value and then have a search programatically return (from specified sites/directories online) images where the dominant color is the color they specified (or close to it).

我想让用户能够选择一个十六进制颜色值,然后以编程方式返回(从指定的网站/目录在线)图像,其中主色是他们指定的颜色(或接近它)。

Is there a technology that can do this? I'd prefer PHP/MySQL, but I'd be willing to use other languages if it would be simpler.

有技术可以做到这一点吗?我更喜欢PHP / MySQL,但如果它更简单,我愿意使用其他语言。


EDIT

Taking several suggestions, I managed to find this: http://www.coolphptools.com/color_extract which does a decent job at extracting the most common colors from the image.

采取了一些建议,我设法找到了这个:http://www.coolphptools.com/color_extract,它在从图像中提取最常见的颜色方面做得不错。

The next step is calculating distance from the extracted colors to the color being searched for. I have no issue implementing it except I'm unclear on the best way to calculate the color distance?

下一步是计算从提取的颜色到要搜索的颜色的距离。我没有实现它的问题,除了我不清楚计算颜色距离的最佳方法?

I've scoured this site and google for a concrete answer, but come up dry. The tool above extracts colors into hex color codes. I am currently converting this to RGB and using those.

我已经搜索了这个网站并谷歌找到了具体的答案,但是干了。上面的工具将颜色提取为十六进制颜色代码。我目前正在将其转换为RGB并使用它们。

Should I attempt to convert RGB to Y'UV? I'm attempting that by using:

我应该尝试将RGB转换为Y'UV吗?我正在尝试使用:

sqrt(((r - r1) * .299)^2 + ((g - g1) * .587)^2 + ((b - b1) * .114)^2)

sqrt(((r - r1)* .299)^ 2 +((g - g1)* .587)^ 2 +((b - b1)* .114)^ 2)

(based on an answer here: RGB to closest predefined color)

(基于这里的答案:RGB到最接近的预定义颜色)

It's not very accurate. What should I swap that color distance formula with so it calculates accurate color distance (to the human eye)?

这不是很准确。我应该用什么交换颜色距离公式,以便计算出准确的颜色距离(对人眼来说)?

2 个解决方案

#1


1

Interesting. The first problem is: "What is the dominant colour of an image?" Maybe the one most pixels have. What do you do with similar shades of the same colour? Would you cluster around similar colours?

有趣。第一个问题是:“图像的主色是什么?”也许是最像素的一个。你用相同颜色的相似色调做什么?你会聚集在相似的颜色?

I would implement it this way: Grab all images inside your search paths. Cluster the colors used in each of them and the biggest cluster is the dominant color. You will have to play around a bit with cluster sizes and number of clusters. If this color is within a certain range of hue, saturation and brightness of your searched color it is a match.

我会这样实现:抓取搜索路径中的所有图像。聚集每个颜色中使用的颜色,最大的聚类是主色。您将不得不玩一些群集大小和群集数量。如果此颜色在搜索颜色的某个色调,饱和度和亮度范围内,则匹配。

更多相关文章

  1. 如何递归将特色图像应用于Wordpress中的子页面?
  2. 如何在没有任何扩展名的php中保存图像
  3. php调整图像大小
  4. 从JSON字符串/数组中提取第一个图像
  5. PHP & GD -透明背景填充附近的颜色。
  6. 如何调整图像覆盖滑块
  7. 使用ASIHTTPRequest从iOS上传图像
  8. 在PHP中将PDF文档转换为预览图像,而无需安装Ghostscript
  9. 我需要PHP页面显示mysql数据库中的BLOB图像

随机推荐

  1. linux android 下进入android shell
  2. Android rxjava实现倒计时功能
  3. android 转屏问题
  4. 图片切换
  5. Android SetWallpaper
  6. Android 设置边距总结
  7. Android(安卓)实现沉浸式体验
  8. 初识SeekBar
  9. 手机拨号器
  10. Android介绍如何生成keystore 文件并使用