6 Replies Latest reply on Oct 29, 2017 8:44 AM by JJMack

# How does Photoshop determine the new RGB pixel values when the top layer's opacity is lowered?

For example, the top layer's RGB values for a given pixel are:

R=11
G=208
B=206

And the same pixel on the layer under it are (found by turning of visibility of the top layer):

R= 195

G=57

B=63

When the top layer's visibility is turned back on and it's opacity is changed to 80%, the new values for the same pixel are now:

R=71

G=184

B=183

The question is: How does Photoshop calculate the new values?

[Moved from the non-technical Lounge Forum to the Program forum... Mod]

• ###### 1. Re: How does Photoshop determine the new RGB pixel values when the top layer's opacity is lowered?

I would not expect the Pixel color to change at all. I think it would be more like adding a gray layer mask that makes the whole layer partly transparent the color you see is the result of blending.  Create a new document fill the background with red.  Convert to a normal layer 0.  Lower the opacity.  You do not see one color you see the transparency checkerboard blended in you see two red shades.   Use the color sampler on the layer it will sample 255 0 0 red.

• ###### 2. Re: How does Photoshop determine the new RGB pixel values when the top layer's opacity is lowered?

Thanks, JJMack.

My question was purely theoretical. If you have two layers, say some text on the top layer, and a photo beneath, and you wanted the text to be semi transparent, you would lower the opacity of the text layer.

By enlarging the screen all the way, to 3200%, you see the individual pixels - be sure the pixel grid is on.

First set the text or top layer to 100% opacity, and in the example above, sampling one pixel with the eyedropper tool shows the rgb values of the text layer pixel. R=11

If you then hide that layer by clicking the eyeball, and, with the eyedropper,sample the exact same pixel of the picture underneath, you get the rgb values for it. R=195

Then turn the visibility for the text or top layer back on, and change the opacity to 80%, you get the rgb value for the pixel, as shown in the example. R=71

I was just wondering what the math is that photoshop uses to arrive at this value.

I was trying 80% of the R = 11 value plus 20% of the R=195 value, but that doesn't add up to 71.

Can anyone come up with the math that Photoshop uses?

• ###### 3. Re: How does Photoshop determine the new RGB pixel values when the top layer's opacity is lowered?

So you want to know the displayed RGB, not the pixel values. The math is all public - for example in the PDF specification - and depends on the blend mode.

• ###### 4. Re: How does Photoshop determine the new RGB pixel values when the top layer's opacity is lowered?

Afraid I cannot answer your question , but you might like to look up Dr Alvey Ray Smith who invented the alpha channel and co-founded Pixar. I can tell you the relationship between two pixels on separate layers is given by

tA+(1-t)B

where t=the transparency of the uppermost layer as a decimal(actually t is written alpha usually-hence the name alpha channel)

A is a pixel on the topmost layer and B is the corresponding pixel on the layer below.

So if the transparency is 70%

0.7A+(1-0.7)B

or 0.7A+0.3B

this means in the combined layers at 70% transparency the final pixel value consists of 70% of the top pixel value and 30% of the bottom pixel value. How that translates to RGB I cannot tell you

• ###### 5. Re: How does Photoshop determine the new RGB pixel values when the top layer's opacity is lowered?

Photoshop's transparency (and PDFs) is much more complex than alpha channels, though I think it can work in an equivalent way. I definitely agree that a starting point is to forget the spurious idea that RGB values lie between 0 and 255. They are floating point numbers between 0.0 and about 1.0 in any colour science.

• ###### 6. Re: How does Photoshop determine the new RGB pixel values when the top layer's opacity is lowered?

It depend on how many layers  above and below are involved in the blending of the document pixel blending and the blending modes involved.   Blending the layer composite view is very complex the math use depends on many things.