2

I have 2 layers in Photoshop, I want to substract one layer from the other so that every pixel that is the same in both layers gets deleted and every pixel that is different stays. I tried to do it with blending but I think its not the right tool for this quest.

  • Hi. Welcome to GDSE. What are you actually trying to achieve by doing this? Can you show what the ultimate goal is by sharing some images? There might be a better way to do it. – Billy Kerr Jul 6 at 22:16
  • I need the output for a painting bot im programming at the moment. For that I need a png that has all the differences betweem 2 layers so the bot only draws the differences. All the areas that have the same color should get deleted. I cant provide an example because I dont know a way to o it by hand. Only the Pixels that are different should be kept – Tiger Jul 6 at 22:54
  • 1
    Examples of input files would be nice. For the moment it's difficult to understand what properties your inputs have: if the have transparency, halftones. User2650501's answer may work for a specific case but without knowing your particular case people will waste their time on guessing what you need. – Sergey Kritskiy Jul 8 at 5:43
3

With a simplified example, it's not hard, I think this will also cover a realtime problem:

I have 2 rectangle layers with an overlap: enter image description here

ctrl_click layer1 thumbnail, to select all pixels in that layer: enter image description here

ctrl_shift_alt_click layer2 thumbnail, now you get overlapped part selected: enter image description here

ctrl_shift_i to invert selection, then click on layer1 thumbnail to select it, then add layer1 mask: enter image description here

alt_drag that mask thumbnail to layer2, to clone the mask, now you get what you wished. Do an export or visible stamp layer.... enter image description here

1

The correct blending mode would be Difference.

This blending mode does not only mark you which pixels are different but at what extent.

It the difference is very subtle, you can not see it, you need to adjust the resulting image to see the pixels.

On this webpage, I used the blending mode to analyze the difference between a base image and the artifacts produced by different JPG settings of different programs. But as an extra step, I used Levels to increase the contrast and actually see the pixels.

Difference blending mode will render pure black if there is no difference and will give you lighter colors depending on how different the subjacent pixel is.


Now, for "deleting the pixels" you probably want to make a mask out of this resulting image, and applying it to any of your two original sources.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.