tsao@helios.tcad.ee.ufl.edu ( Tsao) (04/21/91)
I am writing a graphics program for shading, would somebody tell me how to change the intensity of the same color like 'setgray' in postscript ? or the only way to do that is using different colors (blue, light blue, etc). thanks. -- --- Qing
ssn@modulex.dk (Svend Skafte Nielsen) (04/23/91)
tsao@helios.tcad.ee.ufl.edu ( Tsao) writes: > I am writing a graphics program for shading, would somebody tell me how to >change the intensity of the same color like 'setgray' in postscript ? or the >only way to do that is using different colors (blue, light blue, etc). > thanks. >-- >--- Qing Intensity (also called lightness or luminance) is usually calculated as I = (R+G+B)/3 where R, G and B are the resp. red, green and blue components of the color (e.g. from the XColor structure). One way of changing the intensity of a color then is to increase or decrease each RGB component with an equal ammount. A better way is to use a conversion of RGB to IHS values ( Intesity, Hue and Saturation), change I and transform back to RGB. There are several books and articles on the subject e.g. Durrett: "Color and Computers", John Rankin (I don't remember the title), Wayne Niblack: "Digital Image Processing". Good luck Svend. --------------------------------------------------- Svend Skafte Nielsen | Email: ssn@modulex.dk A/S MODULEX | Phone: +45 44 53 30 11 Lyskaer 15 | Telefax: +45 44 53 30 74 DK-2730 Herlev | Denmark |
hue@island.COM (Jon "Beer - It's not just for breakfast anymore" Hue) (04/26/91)
In article <728@modulex.dk> ssn@modulex.dk (Svend Skafte Nielsen) writes: > Intensity (also called lightness or luminance) is usually calculated > as > > I = (R+G+B)/3 Oh really? I've never done it like that. Say, does anybody else do it like that? When I know the chromaticity coordinates and white point of the RGB device, I plug them into a program which spits out the RGB->XYZ matrix coefficients and use the 'Y' line. [284]coney:hue: ./calc Enter red x and y: 0.625 0.340 Enter green x and y: 0.280 0.595 Enter blue x and y: 0.155 0.070 Enter white x and y: 0.283 0.298 X = 0.38106154R + 0.32025711G + 0.24834578B Y = 0.20729748R + 0.68054637G + 0.11215616B Z = 0.02133945R + 0.14297193G + 1.24172890B When I don't, I cheat and use Y = .30R + .59G + .11B, even though it doesn't correspond to any device you'll likely run across. -Jonathan hue@island.COM
dan@kfw.COM (Dan Mick) (04/26/91)
In article <728@modulex.dk> ssn@modulex.dk (Svend Skafte Nielsen) writes: > > Intensity (also called lightness or luminance) is usually calculated > as > > I = (R+G+B)/3 > > where R, G and B are the resp. red, green and blue components of the > color (e.g. from the XColor structure). I'd take exception to the "usually". Most RGB-to-grayscale convertors I've seen use a formula much more like the one in ppmtopgm, part of the PBMPLUS package: (From the manpage): "The quantization formula used is .299 r + .587 g + .114 b."