No announcement yet.

how does PS merge layers?

  • Filter
  • Time
  • Show
Clear All
new posts

  • how does PS merge layers?

    Am I in the right forum, or should this query be posted elsewhere?

    What happens when you merge layers [image, not fill or adjustment] in Photoshop? The qualitative answer seems to be: WYSIWYG. But I am looking for a quantitative answer. I am looking for a precise - mathematical, if you will - description of the effect of the Photoshop Merge command.

    Suppose I have two layers, 1 on top and 2 below it, and consider a position [pixel] P where the RGB intensities [on the usual 0-255 scale] are (r1, g1, b1) in layer 1 and (r2, g2, b2) in layer 2. Opacities are t1 and t2 [on the usual 0-100% scale].

    Both layers are visible. Layer 1 is active. When I merge the two layers, the RGB intensities at the position P will be

    My question: how is r related to r1,t1,r2,t2 ? And likewise for b and g.

    What happens if I merge three layers?

    Thanks in advance for all the erudite responses that will doubtless be forthcoming.

    Ben Winter

  • #2
    I guess I'm uncertain about what you mean exactly. If R is 255 and you reduce its transparency 50%, it's now 128. Discounting blend modes, it will add R128 to any color below it, so 0,0,255 will become 128,0,255.

    Am I oversimplifying?
    Learn by teaching
    Take responsibility for learning


    • #3
      I'm sorry, but I have no idea what you're asking (maybe I haven't had enough coffee yet?). Any chance you can rephrase the question in non-math terms?
      My only response, at this time, would be, have you "merged" the layers and taken a reading?


      • #4
        TOTALLY befuddled !



        • #5
          If both layers are at 100% opacity and the blend mode is Normal, any non-transparent pixels in the uppermost layer will be the pixel values for the merged layer.

          Think of layers as sheets of acetate. Whatever is on top will be what is visible. At 100% opacity, the pixels are like perfectly opaque ink. They allow nothing from lower layers to show through.

          Certainly, different settings for blend mode or opacity will affect things. Same with the Blend If sliders. You can alter the default behavior in lots of ways with Layer Styles.

          You can find a description of the various blend modes in any good book on PS. For example, Multiply mode is aptly named. It multiplies the pixels from both layers together and then divides by 255. What this means is that if either pixel is 0, the result will be zero. But if either is 255, you will get the value of the other pixel, since 255/255 = 1.




          • #6
            What will happen to individual pixel values will depend entirely on which blend method you have chosen, the exact mathematical calculation of which would best be addressed as a question to Adobe.
            There is no one answer since there are many blend modes.


            • #7
              Thanks for all your replies. Allow me to comment on them, and then make my query more concrete.

              Doug's example is indeed simpler than what I had in mind. A more complex, perhaps more illustrative, example is given at the end of this post.

              Vikki asks whether I've taken a reading. My query actually looks at the matter in the opposite direction: given all the necessary information about two layers, how do you _predict_ what the readings will be? I.e., what are the rules that govern the Merge operation?

              Kiska - if you think you are befuddled now, just wait 'til we get further into this swamp!

              Gary correctly observes that much depends on the blendmodes in effect. Let me clarify: I am interested in the basic operation of the Merge command, apart from blendmode effects. I am only aksing about what Merge does when all visible layers have blendmode Normal.

              Gmitchell states the generally known rule ["sheets of acetate"] for the case blendmode Normal op.100% . . But what happens if we depart just a bit from that simple situation? What happens if opacities are less than 100%?

              To avoid further confusion as to what it is I am asking, consider the following concrete example.

              Using Photoshop Elements 2, I made a brand new image [transparent], added a fill layer [solid color RGB (150, 100, 50), mergemode Normal, op.80%]; call that layer A. Then added another fill layer [solid color RGB (250, 100, 0), mergemode Normal, op.60%]; call that layer B. Then did Merge Visible. -- What do you think will be the RGB for the final result? Does your conclusion match the reading on the Info palette?

              That was with layer B on top of layer A. What do you think you'll get if you switch layers, to A on top of B?

              I am looking forward to the next batch of responses.

              Ben Winter [aka mediatevictoria]


              • #8
                Tried out your experiment ...... interesting, not predictable by me at any rate. However I am unaware of the algorithm that is being used to calculate values. As I said before Adobe are really the only people you are likely to get this information from, or ex-adobe employees willing to tell. Best of luck with your endeavour, post results if you find out.


                • #9
                  UNCLE!!! my brain hurts.



                  • #10
                    Here's come the math

                    This is a really great site.
                    I've been lurking in the shadows for some time, but now it seems there's somewhere that I can be of some use.

                    First a slight correction of the question, lets call the opacity o1 and not t1 (this gets important later).
                    I think this is what you're looking for:

                    r12 = (r1o1 + (r2 - r1o1) * o2) / o12 ........ where

                    o12 = 1 - (1 - o1) * (1-o2)

                    Repeat for 'b' e 'g' and (if I wrote it all down right) you'll get the numbers 215 / 100 / 17 just like the info palette tells you. What the info palette doesn't tell you is that the resultant layer has an opacity of 92%.
                    The 'o12' bit is easier if you consider transparency and not opacity. Then you can write:

                    t12 = t1 * t2 ......... where t = 1 - o

                    Well! You asked for it.

                    Now my little brain hurts too.



                    Related Topics


                    • Sharon
                      Merge Layers Tip
                      by Sharon
                      In PhotoShop Versions 5 & 6, to have a flattened layer above your individual layers you do the following:

                      1. Create a new layer above all your other layers.
                      2. Hold down the Alt key.
                      3. Go to Layers, Merge Visible

                      Now your have a flattened version...
                      12-12-2001, 04:10 PM
                    • jonk
                      Flatten vs Merge
                      by jonk
                      Hi All!

                      Can anyone answer what is the difference between Flattening an image vs Merging Visible? I really do not know what the difference between them are.

                      Thanks Again!
                      03-29-2005, 08:33 PM
                    • jvr
                      Merging Layers with different Blend Modes
                      by jvr
                      Hi all,

                      I've been asked to give a retouched image with transparent background in a single layer. Just one layer with no effects, with no adjustments.

                      My problem is that in the retouch, I used Normal layers, multiply layers and lighten layers. When I Merge all the layers,...
                      03-15-2009, 02:57 PM
                    • gpeisach
                      create and use of multiple layers in photoshop
                      by gpeisach
                      HI there

                      I've been browsing the challenges section and noticed that many of you use "multiple layer technique".
                      I'm a newcomer to the Photoshop world - could someone please explain what this technique is and how to use it? (or point me to a tutorial on this)/
                      06-03-2004, 10:21 AM
                    • savage
                      Layers Question CS3
                      by savage
                      I'm new to the program and have learned much but just can't understand one thing. Maybe someone could explain.

                      Lets say I open an image, duplicate layer, make adjustment layer and adjust "levels", open new adjustment layer and adjust "contrast", and then create a...
                      07-11-2007, 05:37 PM