试图将rgb从.net颜色转换为字符串,如“红色”或“蓝色” [英] trying to convert rgb from a .net Color to a string such as "red" or "blue"
问题描述
我的所有方法都以各种方式使我失望。
有任何人都试图返回一个名称给一个rgb值? 红色,绿色,蓝色将足以满足我今天的需要。
我有来自我的网络摄像头的图像的不安全的字节处理。
如果你有一个已知的颜色名称列表,你可以看到那些已知的颜色,使用沿(F#代码)行的'closeeness'函数:
让Diff(c1:Color) :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
颜色与要命名的目标颜色的差异最小,请使用该名称。
All of my methods are failing me in various ways. different lighting can mess it all up too.
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.
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.
这篇关于试图将rgb从.net颜色转换为字符串,如“红色”或“蓝色”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!