Skip to main content
Andreas Resch
Inspiring
November 4, 2018
Answered

Relation between opacity and mask grayscale value

  • November 4, 2018
  • 3 replies
  • 3007 views

Hello.

I've recently tried to find out the relation between the opacity value of a layer and the grayscale value of a mask to get the same amount of transparency. It doesn't seem to be a linear formula that is used here. So 25% transparency isn't equal to a grayscale value of 25% in the mask - instead it's more like 33% gray.

Can anybody tell me what the relation between the two values is? I'd like to transfer an opacity value to a grayscale mask while retaining the same amount of transparency.

Cheers,

Andreas

    This topic has been closed for replies.
    Correct answer D Fosse

    sGray reproduces the tone response curve of sRGB IEC61966-2.1. This is roughly a gamma 2.2 curve, but not exactly, and with a few anomalies (such as a flat linear "toe" near black).

    Numbers are tied to specific color and tone by icc profiles. That's what defines the numbers. Without that they are just random numbers that could mean anything. Although we call this "color management", it applies to grayscale in exactly the same way. It's just a single channel instead of three.

    3 replies

    D Fosse
    Community Expert
    Community Expert
    November 4, 2018

    But try to change your working gray. The mask density should change at the same %.

    Andreas Resch
    Inspiring
    November 4, 2018

    Hello.

    I changed my Gray profile to "sGray" (whatever this is) and now it seems to work. Before the profile was set to "Dot 20% Gain", which I have used for all those years and seemed to be the default setting.

    So with "sGray" as profile a 25% gray is RGB(64, 64, 64) and with "Dot 20% Gain" a 25% Gray is RGB(85, 85, 85). This is very confusing and I don't see why this would apply to masks as well when I work in RGB mode.


    As I want to use this method in a script, there is one question. If I set the gray value in the script and fill the mask by the script, will it use the proper gray value or will it take the profile settings into account? If so, the mask will look different on different PC, where the script is used. Any ideas if this will cause problems?

    Cheeer,

    Andreas

    D Fosse
    Community Expert
    D FosseCommunity ExpertCorrect answer
    Community Expert
    November 4, 2018

    sGray reproduces the tone response curve of sRGB IEC61966-2.1. This is roughly a gamma 2.2 curve, but not exactly, and with a few anomalies (such as a flat linear "toe" near black).

    Numbers are tied to specific color and tone by icc profiles. That's what defines the numbers. Without that they are just random numbers that could mean anything. Although we call this "color management", it applies to grayscale in exactly the same way. It's just a single channel instead of three.

    D Fosse
    Community Expert
    Community Expert
    November 4, 2018

    The grayscale K percentage value - read from channels or masks - corresponds to your working gray profile. The actual number will depend on what your working gray is.

    In image data, the document embedded profile will override that, but that only applies to actual grayscale files. Otherwise, it's the working gray.

    Opacity percentages should probably be independent from icc profiles, so I assume they are calculated differently. I don't know how, but Lab L might be a reasonable reference.

    Andreas Resch
    Inspiring
    November 4, 2018

    Hello.

    Here's a comparison. The left side shows a red layer on top of a white background at 25% opacity. The right side show the same layer with 100% opacity but a mask filled with 25% gray. As you can see, the mask version is darker.

    You can download the PSD-file here ... http://www.andreasresch.at/upload/Opacity_Test_01.zip

    I also tried the L value of the LAB mode, but it doesn't work either.

    Cheers.

    rob day
    Community Expert
    Community Expert
    November 4, 2018

    If you check the gray value of the layer mask it is 82% (Option-Click the mask thumbnail):

    That makes the Opacity 18% (100-82). Note that I've hidden your background layer, which is at 100% in order to get the layer's Opacity reading from the Info panel:

    If I adjust your layer mask's grayscale value to 75%, the Opacity will change to 25%:

    rob day
    Community Expert
    Community Expert
    November 4, 2018

    How are you measuring the values? I think Opacity should be the inverse of the mask's gray value (100% - K%).

    Make sure you target the layer art to get the Opacity reading, and then the mask to get the K value.

    Here I'm targeting the layer art, and the Opacity reading is 75%, while the K reading is 12%. But the layer art's Grayscale reading represents the conversion of the art's sampled RGB value to grayscale, and not the mask's gray value:

    If I target the layer's mask and take a reading, the mask channel's actual gray value is 25%, or 100%-Op%: