180 lines
13 KiB
Plaintext
180 lines
13 KiB
Plaintext
|
|
Episode: 3520
|
||
|
|
Title: HPR3520: Inversion Layer Modes
|
||
|
|
Source: https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr3520/hpr3520.mp3
|
||
|
|
Transcribed: 2025-10-25 00:56:15
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
This is Hacker Public Radio Episode 3,524 Friday, the 28th of January 2022.
|
||
|
|
Tid's show is entitled, Inversion Layer Modes and is part of the series Gimp It is hosted by Ouka
|
||
|
|
and is about 18 minutes long and carries a clean flag. The summary is, more on Layer Modes in Gimp,
|
||
|
|
with the Inversion Modes. This episode of HPR is brought to you by archive.org.
|
||
|
|
Support universal access to all knowledge by heading over to archive.org forward slash donate.
|
||
|
|
Hello, this is Ouka, welcoming you to Hacker Public Radio and another exciting episode in our Gimp series.
|
||
|
|
Continuing our march through all of the Layer Modes, and we're going to look at the Inversion Layer Modes today.
|
||
|
|
And as the name kind of implies, you know, Inversion is about inverting, okay, and in digital color,
|
||
|
|
what that means is that dark things tend to get brighter, bright things tend to get darker.
|
||
|
|
So remember, in contrast, the bright things get brighter, the dark things get darker.
|
||
|
|
Now we're going the other way, dark things get lighter, like things get darker,
|
||
|
|
but also there can be coloring versions that come out of this as well.
|
||
|
|
And again, I want to emphasize that all of these calculations that go on, go on channel by channel.
|
||
|
|
And you know, that makes a difference.
|
||
|
|
So the first one to look at is called Difference Mode.
|
||
|
|
This one's 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 this difference is used.
|
||
|
|
So absolute value means it is literally just the difference between the values
|
||
|
|
and thus it is commutative. In other words, the order of the layers does not matter.
|
||
|
|
Now, as an example, I put the red layer on top and the blue layer on the bottom
|
||
|
|
and got the magenta result when I combine them using Difference.
|
||
|
|
And if that sounds familiar to you, we got that result previously adding things together.
|
||
|
|
So why does doing the difference? Well, the math makes it clear.
|
||
|
|
For the red channel, you subtract FF from 0, 0 and get minus FF.
|
||
|
|
But then you take the absolute value and it's back to FF.
|
||
|
|
For the green channel, it's 0, 0 minus 0, 0 equals 0, 0.
|
||
|
|
And for the blue channel, it is FF minus 0, 0 equals FF.
|
||
|
|
So put it all together and you have FF 0, 0, FF.
|
||
|
|
And as we have seen, that is magenta.
|
||
|
|
Now, if we combined black and white, the result would end up being pure white for a similar reason.
|
||
|
|
The difference between them is always going to be FF, FF, FF, FF.
|
||
|
|
So in general, the effect tends to be an inversion of the colors. So I did one taking our dog image
|
||
|
|
and doing the difference with a white layer.
|
||
|
|
And the darkest part of the dog image becomes much brighter.
|
||
|
|
The brightest part of the dog image becomes much darker.
|
||
|
|
The color tends to migrate a little bit as well.
|
||
|
|
So what were predominantly brown tones in the original image are now predominantly blue tones.
|
||
|
|
And overall, it's kind of like a funny sort of a negative.
|
||
|
|
So, how does this work?
|
||
|
|
Well, let's say we have a pixel with a value of 57, 57, 8098, 57, 8098.
|
||
|
|
Well, that's kind of a dark, bluish gray.
|
||
|
|
But you combine that with the white, FF, FF, FF.
|
||
|
|
And the inversion gives us C6 AF 90.
|
||
|
|
And that's a tan color.
|
||
|
|
Well, you know, the dog had a lot of tan and brown tones in it.
|
||
|
|
So inverting, we're getting a lot of blue stuff.
|
||
|
|
So you start to see how this works.
|
||
|
|
Now, if we had used a pure black layer instead of pure white,
|
||
|
|
the dog image would be unchanged.
|
||
|
|
Now, what happens if we combine that with the toy image?
|
||
|
|
You know, a little bit of both.
|
||
|
|
The toy image had a lot of white in it.
|
||
|
|
So those places where it was white,
|
||
|
|
the dog image showing through is similar to when we just did it with the pure white layer.
|
||
|
|
Where the toy image has a dark background, it's a little bit different.
|
||
|
|
So, you know, there was a point in the both the dog image and the toy image.
|
||
|
|
There was a place on the right that was white in both images.
|
||
|
|
Now, it's black.
|
||
|
|
Now, the next note I want to look at is called exclusion.
|
||
|
|
Now, this layer mode is similar to difference.
|
||
|
|
It's just a little milder.
|
||
|
|
So I did an example.
|
||
|
|
And in my example, I combined again the dog and the toy images.
|
||
|
|
They're similar, but the exclusion mode is a little less intense.
|
||
|
|
You know, I can see, for instance, that the toy parts of the image are kind of washed out
|
||
|
|
a little more than they are with the difference.
|
||
|
|
And that's where it's most noticeable.
|
||
|
|
Well, you know, there were some dark contrasts and things there that probably added to that.
|
||
|
|
Now, this seems like a good time to bring up something that you always want to keep in mind.
|
||
|
|
And that is that we're looking at these layer modes kind of in isolation,
|
||
|
|
so that we get a sense of what the effects are.
|
||
|
|
But in practice, you would be combining different settings to get the effect you want.
|
||
|
|
So I did an example where I used the exclusion layer mode
|
||
|
|
with the toy image on top, but then I reduced the opacity of the top image to 50%.
|
||
|
|
And, you know, that's a different kind of an image.
|
||
|
|
So I bring this up because what you're going to find proficient users of GIMP
|
||
|
|
are always going to be combining a bunch of tools and settings in order to get the desired effect.
|
||
|
|
And so you just want to keep that in mind, I think, as we go through this.
|
||
|
|
Not occasionally, think to remind you of it.
|
||
|
|
Now, the next inversion mode is called subtract.
|
||
|
|
Now, this is kind of the opposite of the addition mode that we saw when we looked at the various
|
||
|
|
lightened 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 as low as color values can go.
|
||
|
|
The result will be a darker picture, of course, with a lot of black.
|
||
|
|
And the order of the layers does matter here.
|
||
|
|
So which one is on top makes for a difference.
|
||
|
|
So I first did one with the dog image on top.
|
||
|
|
And, you know, what I got was basically a very faint image of the dog and a very dark image of
|
||
|
|
the toy. So the dog image on top, that's the darker image, which means lower numbers.
|
||
|
|
We're subtracting lower numbers.
|
||
|
|
And, you know, you have to keep that in mind.
|
||
|
|
What if we turn it around? We put the toy image on top. Well, the toy image is lighter.
|
||
|
|
So we're subtracting larger numbers. And, you know, a lot of that toy image is white.
|
||
|
|
And so the areas where it was white or very bright are black or near black now when we combine them.
|
||
|
|
So that's how that one works.
|
||
|
|
The next one in the inversion is grain extract.
|
||
|
|
Now, similar kind of related to subtract, you start by subtracting the top from the bottom,
|
||
|
|
but then you add 128 to the values.
|
||
|
|
Now, they put that formula in the GIMP documentation, but it's obviously left something out.
|
||
|
|
You could still have negative numbers. You know, a simple example will show how that can happen
|
||
|
|
if the bottom layer had a value of say
|
||
|
|
five, a very, very dark pixel. The top had a 250.
|
||
|
|
We have a very, very light pixel. Well, 5 minus 250 is negative 245
|
||
|
|
and 128. You're still going to get a negative number.
|
||
|
|
Negative 122, I think.
|
||
|
|
So you've got to also put in a proviso that says in the event there's a negative number,
|
||
|
|
it gets just changed to zero.
|
||
|
|
Now, as it called grain, if you look at the GIMP documentation, it says 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 and embossed appearance.
|
||
|
|
Well, I'm not sure if that explanation is terribly helpful, but you know, the best way to see
|
||
|
|
what's going on is to do some test images. And that's of course what I've been doing as I go along
|
||
|
|
with this. So I did a take first using the dog on the top image and the toy on the bottom.
|
||
|
|
You don't see a lot of the dog, but what you do see it tends to be bluish.
|
||
|
|
There's still a large area where the dog was dark that is white in this image and then an area
|
||
|
|
where on the right there was white in both of the images is now kind of a dark gray, I would say.
|
||
|
|
Now, let's flip it. Let's put the toy image on top. Now we get something that's really dark.
|
||
|
|
But you get some interesting changes. So the wizard's staff, which was kind of a darkish brown,
|
||
|
|
is now a light blue. The wizard's gloves that were yellow are now blue and so on. It's an interesting
|
||
|
|
effect. Then the next mode we can look at is something called grain merge in some sense,
|
||
|
|
the opposite to grain extract. So in this case, you add the top and bottom layers and then subtract
|
||
|
|
128 to get the final result. Now, as with the grain extract, the documentation leaves out
|
||
|
|
something. This formula is not complete because the most you can have in the result is 255.
|
||
|
|
So two very light pixels added together, manned up being pure white.
|
||
|
|
Since this particular one begins with addition, this is commutative, meaning the order of the
|
||
|
|
layers does not matter. Either picture could be the top layer and the result would be the same.
|
||
|
|
So I did a grain merge and again with our dog and the toy and you basically, you're seeing a little
|
||
|
|
of each in the image. I think the dog comes through as a little lighter and the toy comes through
|
||
|
|
as a tad darker than in the original images. That's just the way these things happen to combine.
|
||
|
|
Now, the next mode is called the divide mode and this takes the values from the bottom layer,
|
||
|
|
multiplies them by 256, then divides by the values from the bottom layer, but you add one.
|
||
|
|
And the reason you do that, what if you had a value from the bottom layer that was zero?
|
||
|
|
You know, pure lack of color in that channel. Well, you cannot divide by zero.
|
||
|
|
Right? That is, in mathematics, that's considered a forbidden operation, undefined.
|
||
|
|
So to avoid that, you add one to whatever the value is in the top layer.
|
||
|
|
So bottom layer times 256 and then divide that by top layer plus one and that gives you
|
||
|
|
your result. Now, we did it with the dog image on top and basically got something that was very,
|
||
|
|
very light. The dog image basically disappeared entirely from the combination.
|
||
|
|
The dark parts, particularly the parts that were similar in color to the dog,
|
||
|
|
have just changed color entirely. You can kind of make out a little bit of the dog in like the
|
||
|
|
body of the wizard and stuff like that. Well, this is exactly the case that we talked about when
|
||
|
|
we put boundary conditions on this. The toy image on the bottom is very light. The dog image on
|
||
|
|
the top is fairly dark. So the result of combining them with divide therefore produces a very
|
||
|
|
washed out image. Now, reversing the layers and putting the toy on top is very different.
|
||
|
|
Now, the places where the dog is up against the white background of the toy image,
|
||
|
|
well, the dog just comes through virtually unchanged. For the toy, the areas that were dark
|
||
|
|
when the dog was on top are now lighter. In fact, pretty much everything is a little bit lighter
|
||
|
|
except the base of the crystal ball kind of thing. Now, one interesting use of this mode is to
|
||
|
|
remove particular tones from an image. As an example, I took a color that is in the dog image.
|
||
|
|
It's kind of a mid-tone brown. Now, how do you take a color from an image? Well, there's something
|
||
|
|
called the color picker. It's the icon looks like an eyedropper or something like that.
|
||
|
|
You click on a pixel in the image and it will pick up whatever that color is. You take a look
|
||
|
|
in the color picker for the background and foreground and it will give you the numbers.
|
||
|
|
So this particular one was 857369. Okay, so a little more red than blue, but you know,
|
||
|
|
it's a mid-tone brown so you can plug that in and see what that looks like. I created a layer
|
||
|
|
with that color. I put that layer on top and the dog layer on the bottom and then use divide mode.
|
||
|
|
And what happens is there are pixels that have color in the original image
|
||
|
|
that have basically just gone white. So it's an interesting effect that removes that particular color
|
||
|
|
out of the image. So any pixel that had that color gone now.
|
||
|
|
So those are the inversion modes. We're getting near the end. There's only two more groups to go.
|
||
|
|
So we'll pick that up next time and for now this is a hook up for hacker public radio signing off
|
||
|
|
and as always encouraging you to support free software. Bye bye.
|
||
|
|
You've been listening to hacker public radio at hackerpublicradio.org.
|
||
|
|
We are a community podcast network that releases shows every weekday, Monday through Friday.
|
||
|
|
Today's show, like all our shows, was contributed by an HPR listener like yourself.
|
||
|
|
If you ever thought of recording a podcast and click on our contributing to find out how easy it
|
||
|
|
really is. Hacker public radio was founded by the digital dog pound and the infonomicon computer club
|
||
|
|
and is part of the binary revolution at binrev.com. If you have comments on today's show,
|
||
|
|
please email the host directly, leave a comment on the website or record a follow-up episode yourself.
|
||
|
|
Unless otherwise stated, today's show is released under Creative Commons
|
||
|
|
Attribution, share a light 3.0 license.
|