PHOTOSHOP - How do I paint accurate grey levels between 0-254 in an alpha or a greyscale image?

  • 1
  • Question
  • Updated 3 years ago
  • Answered
  • (Edited)
Summary ... how do I set the grey value of an alpha channel or greyscale image to a particular value between 0-254?

Details:
So here's the thing . I need to be able to assign accurate shades of grey in an alpha channel as our code takes the value (between 0-244) and uses it to do its thing. I assumed this would be easy .. just choose your colour and paint .. but not so.

In an alpha channel, or even in a greyscale image, make a selection and fill it with RGB 6,6,6. Since there doesn't seem to be a way to get a greyscale pallette or input the value for Alpha this is th eonly way I can see to do it.

Now, using the info panel, check that it is indeed RGB 6,6,6. It is.

Now, make another selection and fill it with RGB 7,7,7. Check this with the info panel and ... its 6,6,6. What?

OK so now try to use levels or brightness to shift that 6,6,6 upto 7,7,7 ... check it with the eyedropper color sampler tool .

What you'll find is that the RGB value will go from 6,6,6 .. to 8,8,8 to 10,10,10 it's impossible to make it 7,7,7 or 9,9,9. Theres a whole bunch of other values that are also impossible.

If you do the above in any of the RGB channels themselves it will work fine .. its just the Alpha and in a greyscale image.

On a similar vein, on a regular layer, fill an area with your RGB 7,7,7, copy it and paste it into your alpha. Looks fine .. until you use levels to increase the contrast and you'll find that what was 7,7,7 is now a noise filled mixture of, I assume, 6,6,6 and 8,8,8. So its changing the grey value when you paste it into the alpha channel.

( NB. As a note the above also happened in CS5 but in an old version of Photoshop 5.5 it works perfectly .. I can give the RGB 7,7,7 and the value thats painted is 7,7,7. Bring it into CC and its fine. So its just the creation of tones in CC and CS5 that is wrong.

Also, it works fine if you edit the individual RGB channels .. you can get 6,6,6 AND 7,7,7 .. but as soon as you copy and paste it into the alpha . .the 7,7,7 reverts to 6,6,6 )

Somebody elsewhere helpfully suggested that when printing I shouldn't have to worry about such low values .. so can I reiterate this is not for print. Our game uses the precise value in the alpha channel so a 6,6,6 gives a different result to 7,7,7.

I've now had other people confirm the same issue.

So

Q1 .. what am I doing wrong? Could something in my color setting panel be affecting it?

Q2 .. if 8bit alphas and greyscale images can have values ranging from 0-254 .. then how do I define the value I actually want? I can't use the K value as that's only a percentage so has fewer increments and there isn't a separate input for alpha value in the color picker.

Q3 .. or put it more simply .. how do I set the grey value to a particular number, eg. 7

Thanks.

Pat
Photo of Patrick Ward

Patrick Ward

  • 8 Posts
  • 0 Reply Likes

Posted 3 years ago

  • 1
Photo of Patrick Ward

Patrick Ward

  • 8 Posts
  • 0 Reply Likes
As an additional note, the value changes are not in any way cosmetic or UI related, even our code confirms that both values are 6,6,6 and 6,6,6 when I waited 6,6,6 and 7,7,7
Photo of Chris Cox

Chris Cox

  • 20280 Posts
  • 813 Reply Likes
You are reading values in two different colorspaces: grayscale and RGB. How the values convert between those colorspaces depends on your color settings and the current document profile.

Most likely you used to have grayscale and RGB colorspaces set to something with the same tone response/gamma curve (like sRGB and sGray, or generic gamma 2.2 gray), and in Photoshop CC you don't have the same color settings.
Photo of Patrick Ward

Patrick Ward

  • 8 Posts
  • 0 Reply Likes
Thanks for the reply Chris. I'm not entirely sure I know what that means in this context as CC and CS5 don't have any way of changing the gamma for the alpha or greyscale.

I don't know if these shed light on it ..

The first image is from Photoshop 5.5 .. when I paint with 7,7,7 the result is 7,7,7
The second is from CS5 and the thrid from the default demo install of CC. For both of these if I paint 7,7,7 in the Alpha I get 6,6,6. Unless I'm missing something, setting RGB to 7,7,7 seems to be the only way to make that grey since the grey scale values are only ever shown in percentages and theres no separate input for Alpha in the colour picker..



Photo of Chris Cox

Chris Cox

  • 20280 Posts
  • 813 Reply Likes
Yes, they do have a way to change it - by changing the default colorspaces for RGB and Grayscale document, or changing the colorspace/profile for the current document.

Gray values follow the colorspace for grayscale, and RGB data follows the colorspace for RGB.
Photo of Patrick Ward

Patrick Ward

  • 8 Posts
  • 0 Reply Likes
OK. It looks like I had the wrong end of the stick. I thought colour spaces only affected the display of your colours until you converted to say CMYK when they are used to define the conversion. Likewise the grey and spot dot gains. Otherwise any given value of RGB would be meaningless as its entirely dependent on your colour profile...

So out of the dozens of colour profiles, other than the default sRGB, what do I have to choose or change to ensure that the alpha channel colours linearly? At the end of the day I still have to guarantee that if I paint the alpha of an RGBA file with a chosen colour then thats the exact colour I'll get. Anything else from my current perspective is useless.

SO not knowing quite what you meant I changd the RGB profile to a custom gamma of 1.0



Low and behold it worked.

Then I set it back to sRGB and again it was 'broken'.

Looks like I'll have to reread about colour profiling as I appear to of missed something vital along the way. Thanks.
Photo of Chris Cox

Chris Cox

  • 20280 Posts
  • 813 Reply Likes
Colorspaces affect any conversion of color values - including between Grayscale and RGB.

You really shouldn't need a custom RGB colorspace, and gamma 1.0 is a really bad idea in 8 and 16 bit/channel.
Photo of Patrick Ward

Patrick Ward

  • 8 Posts
  • 0 Reply Likes
But what this doesn't explain is why, when I'm using sRGB, can I go into the R channel and happily paint with 7,7,7 but go into and alpha of the same file and can't?

Is the alpha channel treated differently to other channels? Do I also need to set that Grey Space to 2.20 so its having the same effect as the 2.20 sRGB profile has on the RGB channels?

See I'm confused again. Even with sRGB colour space being used, the R, G and B channels work as I expect .. I can paint with 7,7,7 in any one channel and the result is 7,7,7. but when I switch to the alpha channel it paints 6,6,6 instead ...
Photo of Chris Cox

Chris Cox

  • 20280 Posts
  • 813 Reply Likes
Because the value in RGB may not be equal to the value in Grayscale when you are trying to preserve the appearance.

Alpha channels are Grayscale, not RGB, so your RGB value gets converted to a Grayscale value.

If the transfer curve/gamma is the same in RGB and Grayscale, then that will minimize the changes between the colorspaces.
Photo of Patrick Ward

Patrick Ward

  • 8 Posts
  • 0 Reply Likes
So are you agreeing that I need to change the Grey working space to 2.20 to match the sRGB?

Or am I missing some specific alpha channel colour picker that doesn't require you to choose RGB values? All I can see is a K value which is a percentage so of no use in this instance.
Photo of Chris Cox

Chris Cox

  • 20280 Posts
  • 813 Reply Likes
Yes, if you want the values to match across Grayscale and RGB, you need the Grayscale and RGB colorspaces used to have the same transfer curve / gamma.

No, there is no "alpha channel specific" picker.
Photo of Patrick Ward

Patrick Ward

  • 8 Posts
  • 0 Reply Likes
Gotcha and I can can confirm that works.

Thanks for the help and for being so patient.
Photo of Patrick Ward

Patrick Ward

  • 8 Posts
  • 0 Reply Likes
And rather than just choosing Gray Gamma 2.20 .. its better still to choose the more closely matching sGrey, right at the end of the list, that I blindly didn't see.
Photo of Chris Cox

Chris Cox

  • 20280 Posts
  • 813 Reply Likes
Yes, that is an even closer match.