Doug Kerr
Well-known member
I had previously reported that in Photoshop, when we paint on a pixel mask (either the layer pixel mask or the Selection mask) with a color whose RGB values are all C (a gray color), the transparency coefficient of the mask, t, is made approximately:
t=(C/255)^1.25
I have since gotten some more insight into this very curious matter.
First, that exponent value (1.25) only pertains if:
• The working RGB color space is sRGB
• The working gray color space is Gray Gamma 1.8
How does that come about?
I can't really explain why Adobe chose to do it this way. But, reverse engineered, it seems to work this way:
• The relative luminance of the RGB color, Y, is determined (based on the definitions of the working RGB color space).
• The grayscale coordinate value K, that would, in the working gray color space, give that same relative luminance, Y, is determined.
• The transparency coefficient of the mask is made 1-(K/100).
Note that once the transparency coefficients are established for a mask, it does not matter of the working color spaces are changed - the transparency coefficients are absolute once determined, and do not change.
Now, where does the 1.25 come from? Well, if we go through the math, we find that:
• If the gamma of the RGB color space is gRGB
• and the gamma of the grayscale color space is gGS
then the transform becomes:
t=(C/255)^(gRGB/gGS)
For the sRGB there is not a simple gamma, but the value 2.25 is a good stand-in. The default grayscale color space is Gray gamma 1.8, and it's gamma is - well, you know. Thus the exponent on the transform is 2.25/1.8=1.25.
An interesting related matter is the working of the Info panel when examining a pixel mask.
First we will review the ordinary use of the Info panel (in examining image pixels). If we set one sub-panel to show the grayscale values of image pixels, it reports in terms of the grayscale color space coordinate K. This works just like R, G, or B, except upside down, on a scale of 0-100% (not 0-255), and of course there is only one, since this is a grayscale color space, only requiring one coordinate.
Thus, the way we "decode" a grayscale image, with coordinate K, is this way:
Y=(1-(K/100))^gGS
where Y is the relative luminance implied by the value of K and gGS is the gamma of the particular grayscale color space.
Now when we use the info panel, set up this way, to examine a mask (in black/white mode), K tells us the mask opacity coefficient (the inverse of the mask transparency coefficient) at the particular point; that is, K=0% means the mask is fully transparent, K=100% means that the mask is fully opaque, and K=30% means that the mask is 70% transparent.
This is independent of the two color spaces used when the mask was painted (the resulting transparency coefficients are "absolute"), and the two color spaces now in effect.
If the other sub-panel is set to show the RGB values of the image pixels (according to the working RGB color space)normally in normal use, now it shows what RGB values (under the current working RGB color space), and considering the current working grayscale color space, would produce the transparency coefficient we have at this point if we wanted to paint it someplace else.
By the way, if we set the working RGB color space to sRGB, and the working grayscale color space to sGray (which follows exactly the same nonlinear gamma precompensation as does sRGB), then, if we paint on the mask with a gray RGB color R,G,B=C,C,C, the transparency coefficient established is just C/255.
Honest, guys, could I make something like this up?
Ah, the mind of Adobe!
Best regards,
Doug
t=(C/255)^1.25
Actually, I had first reported this as:
t=(C/256)^1.25
but that turns out to be in error.
t=(C/256)^1.25
but that turns out to be in error.
I have since gotten some more insight into this very curious matter.
First, that exponent value (1.25) only pertains if:
• The working RGB color space is sRGB
• The working gray color space is Gray Gamma 1.8
How does that come about?
I can't really explain why Adobe chose to do it this way. But, reverse engineered, it seems to work this way:
• The relative luminance of the RGB color, Y, is determined (based on the definitions of the working RGB color space).
• The grayscale coordinate value K, that would, in the working gray color space, give that same relative luminance, Y, is determined.
(Note that K is a nonlinear coordinate, much like R, G, and B in an RGB color space, but it works upside down - greater is darker - and is on a scale of 0-100%.)
• The transparency coefficient of the mask is made 1-(K/100).
(The division by 100 is to convert from a 0-100 scale to a 0-1 scale.)
Note that once the transparency coefficients are established for a mask, it does not matter of the working color spaces are changed - the transparency coefficients are absolute once determined, and do not change.
Now, where does the 1.25 come from? Well, if we go through the math, we find that:
• If the gamma of the RGB color space is gRGB
• and the gamma of the grayscale color space is gGS
then the transform becomes:
t=(C/255)^(gRGB/gGS)
For the sRGB there is not a simple gamma, but the value 2.25 is a good stand-in. The default grayscale color space is Gray gamma 1.8, and it's gamma is - well, you know. Thus the exponent on the transform is 2.25/1.8=1.25.
An interesting related matter is the working of the Info panel when examining a pixel mask.
First we will review the ordinary use of the Info panel (in examining image pixels). If we set one sub-panel to show the grayscale values of image pixels, it reports in terms of the grayscale color space coordinate K. This works just like R, G, or B, except upside down, on a scale of 0-100% (not 0-255), and of course there is only one, since this is a grayscale color space, only requiring one coordinate.
Thus, the way we "decode" a grayscale image, with coordinate K, is this way:
Y=(1-(K/100))^gGS
where Y is the relative luminance implied by the value of K and gGS is the gamma of the particular grayscale color space.
Now when we use the info panel, set up this way, to examine a mask (in black/white mode), K tells us the mask opacity coefficient (the inverse of the mask transparency coefficient) at the particular point; that is, K=0% means the mask is fully transparent, K=100% means that the mask is fully opaque, and K=30% means that the mask is 70% transparent.
This is independent of the two color spaces used when the mask was painted (the resulting transparency coefficients are "absolute"), and the two color spaces now in effect.
If the other sub-panel is set to show the RGB values of the image pixels (according to the working RGB color space)normally in normal use, now it shows what RGB values (under the current working RGB color space), and considering the current working grayscale color space, would produce the transparency coefficient we have at this point if we wanted to paint it someplace else.
By the way, if we set the working RGB color space to sRGB, and the working grayscale color space to sGray (which follows exactly the same nonlinear gamma precompensation as does sRGB), then, if we paint on the mask with a gray RGB color R,G,B=C,C,C, the transparency coefficient established is just C/255.
Honest, guys, could I make something like this up?
Ah, the mind of Adobe!
Best regards,
Doug
Last edited: