尝试将 rgb 从 .net Color 转换为字符串,例如“red";或“蓝色" [英] trying to convert rgb from a .net Color to a string such as "red" or "blue"
问题描述
我所有的方法都以各种方式让我失望.不同的照明也会把一切搞砸.
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.
推荐答案
如果您有一个带有名称的已知颜色列表,您可以使用 'closeness' 函数(F# 代码):
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 Color 转换为字符串,例如“red";或“蓝色"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!