Inversion Layer Modes

Done using GIMP 2.10.24 on Kubuntu Linux 20.04 LTS

Difference Mode

This one is pretty simple. In this mode the value of the Top layer is subtracted from the value of the Bottom layer, and then the absolute value of the of this difference used. The Absolute Value means that it is literally just the difference between the values, and thus it is commutative, i.e., the order of the layers does not matter. As an example, I put the Red layer on top and the Blue layer on the bottom, and got the Magenta result when I combined them using Difference. And the math makes it clear why. For the Red channel, you subtract ff from 00, and get -ff. But take the absolute value and it is ff. Then for the Green channel, it is 00-00=00, and for the Blue Channel it is ff-00=ff, so put it all together and you have ff00ff, and as we have seen that is Magenta. And if we combined Black and White, the result would be pure white for similar reasons. In general, the effect tends to be an inversion of the colors. Here is what I got using our Dog image with a pure white layer:

Dog and White images combined using Difference Layer Mode

I think this really brings out the inversion aspect as it produces something like a negative. For instance, a pixel with the value 578098 would be dark bluish-gray, but combined with the white the inversion gives us c6af9d, and that is a tan color. If we used a pure black layer instead of pure white, the Dog image would be unchanged. But combine the Dog image with the Toy image and you get:

Dog and Toy images combined using Difference Layer Mode

Where the Toy image has a white background, we get the dog image as a negative, and some of the toy pixels have flipped as well. Basically, where there is very little difference, the end result will be very dark. For example, in the right-hand side both images had white pixels, and now you see a black patch there. But when the difference is large, you get very light pixels. Of course, we had used this mode previously to detect whether there was difference between images that to the eye appeared the same.

Exclusion

This layer mode is very similar to Difference, but is just a little milder. Here is the result I get from my Dog and Toy images:

Dog and Toy images combined using Exclusion Layer Mode

So you can see that the images are similar, but the Exclusion mode is less intense. And this seems like a good time to bring up that while we have looked at the Layer Modes in isolation to see the effects they have, in practice you would be combining different settings to get the effect you want. Here is that same Layer Mode, but in this case I reduced the Opacity of the Top layer (the Toy image, in this case):

Dog and Toy images combined using Exclusion Layer Mode, but Toy image reduced to 50% opacity

A proficient user of GIMP would always be combining tools and settings to get the desired effects, so you should always keep that in mind.

Subtract

This is of course the opposite of the Addition Mode we saw when we looked at Lighten Modes. You subtract the values of the top layer from the bottom layer, but any negative numbers that result are set to zero since that is as low as color values can go. The result will be a darker picture, of course, with a lot of black. The order of the layers does matter here.

Formula for Subtract Mode

Here is the result with our Dog image on top:

Subtract mode with Dog image on top

Now if we reverse this and put the Toy image on top, we get this:

Subtract mode with Toy image on top

This is what we should expect. Remember we are subtracting the top layer values from the bottom layer values. Since the Dog image is primarily darker to begin with, and dark pixels have low values, you just aren’t subtracting as much. But when the predominantly white Toy image is on top, using Subtract mode will produce a lot of black pixels, and it is the parts of the Toy image that were dark to begin with that come through in the combination.

Grain Extract

This is related to Subtract, but after you subtract the top layer from the bottom layer, you add 128.

Formula for Grain Extract

Now this formula is not quite correct because it could still produce negative numbers, so you have to allow for setting a minimum of zero.

To quote the documentation:

Grain extract mode is supposed to extract the “film grain” from a layer to produce a new layer that is pure grain, but it can also be useful for giving images an embossed appearance.

https://docs.gimp.org/2.10/en/gimp-concepts-layer-modes.html

I first did a take using the Dog as the Top image to get this:

Dog image on top using Grain Extract Layer Mode

Compared with Subtract this is a lighter image and somehow softer. Now doing it with the Toy image on top we get:

Toy image on top using Grain Extract Layer Mode

So as you can see this is again a lighter image than with the Subtract mode, but there are still significant areas of black because the top Toy image has areas of white while the bottom Dog image had areas that were dark . These are places where the formula in the documentation would have given us a negative number, so they are instead set to zero.

Grain Merge

This is in some sense the “opposite” to Grain Extract. In this case you add the top and bottom layer values, then subtract 128 to get the final result.

Formula for Grain Merge

And as with Grain Extract, while the documentation doesn’t say this, the most you can have in the result is 255, so two very light pixels added together may end up being pure white. And since this begins with addition, it is a commutative mode, meaning that the order does not matter. Either picture could be the top layer, and the result would be the same. Here is what we get with our two images.

Images combined using Grain Merge Layer Mode.

Divide

This layer mode takes the values from the Bottom layer, multiplies them by 256, then divides by the values from the bottom with 1 added to them to avoid possible “divide by zero” errors.

Divide Layer Mode formula

Obviously we would again need to put some boundaries on possible results since if the bottom layer was very light and the top layer very dark you could easily get values above 255, and that is not allowed. And of course it matters which layer is on top for this calculation. With our Dog image on top we get this:

Dog image on top with Divide mode

This is exactly the case we just talked about, since the Toy image on the bottom is very light, and dog image on top is fairly dark. The result of combining them with Divide, therefore, produces a very white washed-out image . Reversing the layers and putting the Toy on top is different:

Toy image on top with Divide mode

In this case, a lot of the dog image comes through relatively unchanged. For the Toy, though, the areas that were dark when the Dog was on top are now lighter, and vice-versa.

An interesting use of this mode is to remove particular tones from an image. As an example, I picked a color 857369, which is kind of a mid-tone brown, and created a layer with this color. I put that layer on top, and the Dog layer on the bottom, and used the Divide mode:

Brown layer on top of Dog using Divide Layer Mode

Compare this with the untouched Dog image:

Image of Dog after cropping

As you can see, the image where we used Divide has those brown tones removed, and areas that were brown originally have in some cases become pure white.

Well, that concludes our look at the Inversion Layer Modes, and we are getting near the end since there only two more groups to go.

 Save as PDF