颜色检测算法 - 我应该怎么办呢? [英] Color detection algorithm - How should I do this?

查看:160
本文介绍了颜色检测算法 - 我应该怎么办呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有点停留在设计一个颜色检测系统 - 我不能完全弄清楚一个方法可以轻松地做到这一点。

I'm a bit stuck on designing a color detection system - I can't quite figure out a way to do it easily.

-

基本上,我有图像库,我想通过颜色来排序。因此,如果用户指定排序由蓝色',那么最蓝的图像将出现在结果的顶部,用最少的蓝色在底部出现。

Basically, I have a library of images, that I want to sort by color. So if the user specifies 'sort by blue', then the most blue images will appear at the top of the results, with the least blue appearing at the bottom.

的问题是,图像是不是所有的一种颜色,所以它是做两件事情在同一时间:

The problem is that the images aren't all one color, so it is doing two things at the same time:

1 - 寻找图像
的蓝的部分 2 - 排名这个蓝色的颜色(根据色调和这种颜色的量)

1 - finding the bluest part of the image
2 - ranking this blue color (based on color hue and amount of this color).

我已经试过约3或4个不同的方法,用不同的结果 - 没有工作做好,虽然,其中2个是相当的数学算法(其中所有的工作要好得多在纸面上比实际哈哈)

I've tried about 3 or 4 different approaches, with varying results - none work well though, and 2 of these were quite mathematical algorithms (which all work much better on paper than in practice haha).

-

我能去,整个过程有什么不同的方法?我可能错过了一些真正明显的方式它可以工作 - 任何帮助或想法会大大AP preciated:)

What different ways could I go about the whole process? I'm probably missing some really obvious ways it could work - any help or ideas would be much appreciated :)

-

编辑:感谢所有的答复 - 这是我到目前为止已经试过:

Thanks for all the responses - here's what I've tried so far:

  • 让整个图像的平均RGB值,并将其与蓝色。做比较使用标准化的RGB 3空间矢量并发现它们之间的距离。这工作最不好的,没有蓝色的图像可以很容易出现偏很强的蓝色的图像上。

  • getting the average rgb value for the whole image and comparing it to blue. Comparing was done using normalised rgb 3 space vectors and finding distances between them. This works the least well, an image with no blue could easily appear above an image with partial very strong blue.

找到主色,这(再次使用3空间矢量距离)比较蓝色。这并不能正常工作可能有过,这是不是最(或前几个)主色部分图像的大的蓝色部分。

finding the dominant color and comparing it to blue (again using 3 space vector distances). This didn't work as there might have been a large blue section of the image that wasn't the most (or in the top couple) of dominant color sections.

发现,接近蓝色像素,平均所有这些,答案比较实际的蓝色。

finding pixels that are close to blue, averaging all of these and comparing the answer to actual blue.

查找所有是接近的蓝色像素,增加计和寻找基于数/总像素的百分比。

finding all the pixels that are close to blue, incrementing a count and finding a percentage based on count/total pixels.

推荐答案

两个想法浮现在脑海中:

Two thoughts come to mind:

廉价版:图像转换到HSV空间,并为每个像素计算 COS(H - target_hue)或合理的近似(蓝色, target_hue 将是240度),通过饱和相乘,并平均该数量在所有图像中的像素。高值是最好的。需要注意的是颜色更接近黄色,而不是蓝色的有负青,而黑,白,灰纯有同样的零青。需要注意的是你真正想要的单纯疱疹病毒,不HSL,在这种情况下,因为在HSL的S没有很好地映射到感性的饱和度。例如,颜色#f8f8ff(RGB 248,248,255)具有100%的在HSL饱和(即一纯蓝色),但看起来近白色。相同颜色的HSV具有一S的只有3%,这是合理的坐标

Cheap version: convert images to HSV color space, and for each pixel compute cos(H - target_hue) or a reasonable approximation (for blue, target_hue would be 240 degrees), multiply by saturation, and average that quantity over all of the pixels in the image. High values are best. Note that colors that are closer to yellow than to blue have "negative blueness", and that black, white, and pure gray have equally "zero blueness". Note that you really want HSV, not HSL, in this situation, because the "S" in HSL doesn't map well to perceptual saturation. For example, the color #f8f8ff (RGB 248, 248, 255) has a saturation of 100% in HSL (i.e. a pure blue), but it looks nearly white. The same color in HSV has an "S" coordinate of only 3%, which is reasonable.

减廉价版:图像转换成CIELAB色彩空间,抛却L,并计算距离在每个像素的每个像素和目标颜色,然后平均值或有效值的A * B *空间。低值是最好的。

Less cheap version: convert images to CIELAB color space, discard L, and compute the distance in a*b* space between each pixel and the target color, then average or RMS over each pixel. Low values are best.

这篇关于颜色检测算法 - 我应该怎么办呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆