What's the Diff? Over the years, I've accumulated a few different uses for Photoshop's Difference Layer functionality, in much the same way I've accumulated old computer parts. I didn't really go looking, it just sort of happened. My impression is that there are three kinds of Photoshop users: those who've never stumbled across Difference, those who have played with Difference and a few who actually use Difference. This how-to should appeal to all three. What is this Difference You Humans Speak of? |
A little bit of simple math up front, then on to the good stuff...I promise. There are a couple of different spots in Photoshop where difference shows up. For the following fooling around, assume that we're talking about the Difference option that appears in the Layers blending menu. What does it do? In simplest terms, it compares a layer to the layer just below it. Where the pixels have the same RGB value, it displays black (0-0-0). Those zeros mean there is no difference between the two layers.
Let's start with these two images. The original image on the left contains three swatches; 255 red / 255 blue / 255 green. The comparison image adds a stripe of white 255 / 255 / 255 on top, and black 0 / 0 / 0 on the bottom. If we place the comparison image in a layer above the original image and set that layer to Difference, we get this: |
So what does that image tell us? Well, let's start from the bottom. Where the comparison image was black, we see the original colors. What it means is the difference between black, where all the RGB values equal 0, and any other color is the the value of the original color: In the middle stripe, where the colors are the same, which is to say, no difference, the result is a black strip. The difference between a red pixel and a red pixel is 0, green and green, 0, and so on. Etc. The top looks a little funky. What's the deal? Well, now we have a white stripe, where all the RGB values equal 255. So now we get this: The astute reader will notice that I'm not being consistent about what layer's RGB values I'm subtracting, sometimes one, sometimes the other. All we are really interested in is the magnitude of the difference. The equation would actually look something like this: Absolute Value of (Layer_1 Red - Layer_0 Red) The bottom line: Where the images are the same, you get black. Where they are different, you get something else.
|