Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

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.

webcam

colors

like image 501
w-ll Avatar asked Dec 13 '08 23:12

w-ll


People also ask

How do you convert RGB values to color names in Python?

There is a program called pynche which can change RGB to colour name in English for Python. You can try to use the method ColorDB. nearest() in ColorDB.py which can do what you want.

How do you convert RGB to hex?

First ValueTake the first number, 220, and divide by 16. 220 / 16 = 13.75, which means that the first digit of the 6-digit hex color code is 13, or D. Take the remainder of the first digit, 0.75, and multiply by 16. 0.75 (16) = 12, which means that the second digit of the 6-digit hex color code is 12, or C.

Which of the following colors is represented by RGB 0 255 255 )?

To display black, set all color parameters to 0, like this: rgb(0, 0, 0). To display white, set all color parameters to 255, like this: rgb(255, 255, 255).


1 Answers

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.

like image 196
Brian Avatar answered Sep 28 '22 18:09

Brian