尝试转换RGB从.NET颜色为一个字符串,如"红"或QUOT;蓝色"字符串、颜色、蓝色、RGB

2023-09-03 03:33:23 作者:甜心猫宠女

我所有的方法都失败了我以不同的方式。 不同的灯光可以胡来了全面的总结了。

All of my methods are failing me in various ways. different lighting can mess it all up too.

有没有人每次试图返回给定RGB值的名称? 红绿蓝就足以满足今天我的需求。

has anyone every trying to return a name given a rgb value? "red" "green" "blue" would be enough to satisfy my needs for today.

我有图像的不安全字节的处理从我的网络摄像头。

i have unsafe byte processing of images from my web cam.

推荐答案

如果你已经知道的颜色与名称的列表,你可以看到它的那些已知的颜色给定的目标颜色是'最接近'来,用亲近沿线的函数(F#code):

If you have a list of known colors with names, you can see which of those known colors a given target color is 'closest' to, using a 'closeness' function along the lines of (F# code):

let Diff (c1:Color) (c2:Color) =
    let dr = (c1.R - c2.R) |> int
    let dg = (c1.G - c2.G) |> int
    let db = (c1.B - c2.B) |> int
    dr*dr + dg*dg + db*db

无论已知的颜色之一具有最小差异,以要名的目标颜色,使用该名称。

Whichever one of the known colors has the smallest diff to the target color you want to name, use that name.

 
精彩推荐
图片推荐