Simple Colorizing Questions

Started by
4 comments, last by Jiia 20 years, 2 months ago
Hey, You can move this to the beginners forum if so desired. In my game, I''m trying to allow colorizing of character features by rendering them using primary colors, then doing a color -> grey -> custom color conversion in my editor. Unfortunately, I''m not sure how to get the grey value OR colorize them :\ doh! Someone once told me that the greyscale value is just the average of red, green and blue. But Paint Shop Pro converts 200,70,30 into 104, not 100. Close, but I must be missing something. And then the colorizing. My first guess is that I just use the percentage of the grey value. Like if grey is 60, and sense 60 is 23% of 255, then the new pixel would be 23% of the red, green, and blue of the custom color. Is that right? Thanks for any help, Jiia
Advertisement
There are no hard and fast rules, you can just invent your own that looks ok.

RGB->greyscale (in PSP) probably depends on converting to a different colour space and using, say, intensity rather than directly operating on the RGB. A simple average will probably work for what you want to do, but check the Forum FAQ for some links to more in-depth colour theory info.

As for greyscale->RGB, what you suggest will work ok but why don't you just try it and see whether it is what you want?

[edited by - JuNC on February 7, 2004 7:53:13 PM]
I appreciate your help, Junc
A simple way to do it in arb_tex_env (or nv_rc) is something like this: first use dot3 on texture(or just primary color) & constant (read FAQ to get exact RGB->gray conversion values) then just multipy this value with your desired color. This works on any card supporting multitexturing.

out = (texture DOT3 (0.3, 0.5, 0.2))*color


You should never let your fears become the boundaries of your dreams.

[edited by - _DarkWIng_ on February 8, 2004 8:25:51 AM]
You should never let your fears become the boundaries of your dreams.
I calculate grayscale values by calculating the average of the minimum and maximum intensities; for instance:

Lets say we have 100,120, and 199. The shade of gray will be 149.
If those intensities were 199, 120, and 100 we would still get 149 for the shade of gray.
A semi-standard rgb to grayscale conversion is given by:

Y = 0.3R + 0.59G + 0.11B

where Y is the luminance. This formula tries to take into account the human eye''s relative sensitivity to different colors. There is no real "standard" for converting to grayscale, however, since it depends on the detectors response to the light.

Magius

This topic is closed to new replies.

Advertisement