Ede Barudo
Ede Barudo

Reputation: 5

is there a formula to convert rgb color to gray

I need to create a logo in RGB like this one and in greyscale it must look like one color.

i.e. 50AA1E, 2B94FF and D16E00 in greyscale is 808080

Is there a formula to convert rgb color to gray?

Thanks in advance.

Upvotes: 0

Views: 1229

Answers (1)

Syon
Syon

Reputation: 7391

The conversion algorithm appears to be:

Grey = NearestInteger(R*0.3 + G*.59 + B*.11)

50AA1E -> 80,  170, 30  -> 80*0.3  + 170*0.59 + 30*0.11  -> 24   + 100.3 + 3.3   = 127.6  -> hex(127.6)  = 80
2B94FF -> 43,  148, 255 -> 43*0.3  + 148*0.59 + 255*0.11 -> 12.9 + 87.32 + 28.05 = 128.27 -> hex(128.27) = 80
D16E00 -> 209, 110, 0   -> 209*0.3 + 110*0.59 + 0*0.11   -> 62.7 + 64.9  + 0     = 127.6  -> hex(127.6)  = 80

This is a form of conversion based on luminosity and is very close to (but not quite) the model used by PAL and NTSC.

I tried several other greyscale conversion formulas, but this was the only one that fit your given test data.

Upvotes: 1

Related Questions