Files
hpr-knowledge-base/hpr_transcripts/hpr3500.txt

177 lines
12 KiB
Plaintext
Raw Normal View History

Episode: 3500
Title: HPR3500: Contrast Layer Modes
Source: https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr3500/hpr3500.mp3
Transcribed: 2025-10-25 00:28:07
---
This is Hacker Public Radio Episode 3,500 for Friday, 31 December 2021.
Tid's show is entitled, Contrast Layer Modes and is part of the series Gimp It is hosted by Auka
and is about 17 minutes long and carries a clean flag. The summary is, more on Layer Modes in Gimp
with the Contrast 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 Auka, welcoming you to Hacker Public Radio in another exciting episode in our Gimp series.
We're continuing our look at Layer Modes and today we're going to look at what are called contrast modes.
As the name implies, they increase the contrast as the layers are combined.
They do that in a variety of ways that effectively will increase the brightness of bright pixels and decrease the brightness of dark pixels,
thus increasing the overall contrast.
First one that I want to look at is called Overlay.
I have to say these contrast ones are fairly complicated compared to the others when you dig into what's going on in the background.
This has a complicated formula, the Overlay mode, and you start by inverting the values of the pixel in the lower layer.
In the Gimp documentation, the lower layer is always referred to as i for image.
Inverting means to subtract from 255, so if you had a value of 200, which is relatively bright, you subtract it from 255, you get 55, which is relatively dark.
That's what inverting is.
Then you take the pixel value for the upper layer, which is called m for mask, and you multiply that by 2.
You've doubled that, and then after you've doubled it, you divide by 255.
We're not done yet.
Then you take that doubled upper layer, divided by 255, and then multiply it by that inverted lower layer pixel.
Then you take that product, you add the value of the lower layer pixel.
You multiply it by the value of the lower level pixel, and then divide all of that by 255.
Kind of complicated what's going on here.
I'm going to work through an example just to maybe make a little bit clearer what's going on.
In this example, I'm only going to focus on one channel, and the thing you want to remember is, and I've seen many, many people skip over the part that all of this is done channel by channel red, green, blue.
Instead they just talk as if, well, the pixel has a value of 240.
240 what?
Is it 240 across all three channels?
You need to be precise, I think, to really get a handle on some of this stuff.
I'm just going to take one channel, and let's give that channel a value of 50 for the lower layer, and 40 for the upper layer.
Now remember the lower numbers are darker, so these are fairly dark values.
Now inverting the value with the lower layer is 255 minus 50, and that's 205.
Then twice the upper layer is twice times 40, that's 80, and then dividing that by 255 is about 0.31.
So a lot of these numbers will end up being approximate, depending on where you round off.
So then 0.31 times 205 is about 64, add the lower layer value to that, 64 plus 50 is 114.
Now multiply that by the value of the lower layer, and that be 114 times 50, that's 5,716.
And finally divide all of that by 255.
The resulting combined pixel value is approximately 22.
So the resulting value is lower than either of the layer values we started with.
So we started with fairly dark values and wound up with even darker ones.
Now let's try some different numbers.
I'll just invert the numbers I used from the previous example.
So the inverse for the lower layer, it was 50 before, now it'll be 205, and the upper layer, which was 40 before, will now be 215.
Inverting the lower layer gives us 50.
Then twice the upper layer is 2 times 215, that's 430.
Dividing that by 255 gives us 1.69.
Multiply that by the 50 from inverting the lower layer gives us 84.3.
Then we add the lower layer to get 84.3 plus 205 equals 289.3.
Multiply that by the lower layer, 289.3 times 205 equals 59309.
Finally dividing that by 255 gives us the final value of 232.5.
So in this case we started with higher numbers, meaning brighter, lighter values, and wound up with something even brighter than either of what we started with.
So from this you can see why this is an example of a contrast layer mode, because it has the effect of increasing the contrast by making dark values darker and light values lighter.
Now looking again at the formula, you might see some resemblance to a few of the modes we've looked at before.
You can kind of think of this as a combination of the multiply, which is darken, and the screen, which is lighten modes.
So I've done some examples that you can see on the web page for all of these.
So I did one with the toy as the top layer and the dog as the bottom.
And it's pretty evident that the contrast has grown up in addition to having two layers combined.
Now the next one we want to talk about is soft light.
Now this again has a complex equation.
A lot of these are complex.
So first you start with the screen mode.
Now the screen mode was you invert both the top and the bottom pixel values and then multiply those together.
Then you take what you've multiplied together you divide by 255 and then take that answer and subtract it from 255.
And now a screen mode, which was a brighten.
And now you plug it into yet another equation.
And in this other equation, what you do is you compute first of all you invert the lower layer.
And then take that inverted lower layer, multiply it by the upper layer, and then add what you get from screen mode.
And divide that whole thing by 255.
And then you multiply it by the value of the lower layer.
So there's like two equations here going on.
But what does it do?
Well soft light.
And that really does what it says it does.
It adds a soft light to the image.
So I did an example taking my dog image and using the soft light thing.
And you can see that it is noticeably lighter.
But it's still the same picture.
It's just as if there was a little more light on the subject.
Now you can reduce how strong the effect is by reducing the opacity of the top layer.
If the opacity goes to zero, you just get the bottom image on altered.
So it's an interesting effect.
And to really get the best benefit, what you really want to do is you want to take an image and then create a separate layer and just fill it with pure white.
Combine that with the soft light mode.
And it's a very nice effect.
And I can see where there be occasions where you'd want to use it.
Now hard light.
This is different.
And again, it's very complex.
I'm not going to dig into all of the details of the equation this time.
You can look it up in the documentation.
It depends on the values of the pixels in the upper layer.
And what it does is it separates them and does a different formula.
Depending on whether the value is above 128 or below 128.
128, of course, is roughly the middle between 0 and 255.
So you have a different formula for light values and a different formula for dark values.
And generally the light values get lighter, the dark values get even darker.
So I did an example using the dog image and the white layer.
And this time I put the dog image on top and applied the hard light mode.
And you could see it is different from the soft light.
It is as if there was a stronger light illuminating the dog.
So yeah, it's like the dog is lit up by a powerful light.
But if you look closely, you'll see the dark areas are just a tad darker.
Now the next one is vivid light.
Vivid light works off the gray scale of the image.
And applies a color dodge to pixels that are above 50% and a color burn to pixels below 50%.
So remember, dodge is a lightened and burn is a darkened.
So what we're doing is we're lightening the lighter pixels and darkening the darker pixels.
We're doing it in a somewhat different way.
And it tends to produce a stronger contrast when you do it that way.
Now the next one I want to mention is called pin light.
And it's similar to vivid light.
It also uses gray scale values.
It does divide them at the 50% mark.
But where vivid light used dodge and burn respectively,
pin light uses the lightened only and darkened only modes respectively.
So again, you're lightening the light ones and darkening the dark ones.
But you're doing it in a slightly different way this time.
And again, the effect is the increased contrast by making dark pixels darker and light pixels lighter.
And the effect looks very similar to the vivid light image.
But when I look at the two images using the difference mode, I can see that they are different.
One reason is that the middle of the gray scale tends to disappear with this mode.
Now one way to see this is to use a gradient layer.
So I created one using a black and white radial gradient.
And it might as well be black and white.
Because remember, this is all based on gray scale.
And I set it to a 50% opacity.
And radial gradient means it was black in the very center of the image and got gradually wider as you moved out from the center.
And doing that with the dog image, I got an interesting effect.
You can see the image I created on the web page.
Particularly the right hand side of the dog's face, the pixels are definitely darker.
The rest is washed out and there really are no midtones to speak of.
Now the next one is linear light.
This also works off of gray scale and is similar to vivid light.
But instead of color, dodge and color burn, it applies linear dodge and linear burn.
So just another variation on the theme.
The last one that I want to mention is an interesting one called hard mix.
Now this mode operates on the three channels red, green and blue.
And starts by adding the values in each channel.
Now if the total is at or above 255, the value is set to 255.
If the total is below 255, the value is set to zero.
What does that mean?
Well, the effect is essentially to posterize the image with very pure colors.
You know, everything is either 255 or zero.
So for every pixel, you can have pure black, which would be 000000.
Pure white, FF, FF, FF.
The three primary colors of RGB, so red is FF0000, green is 0000, FF0000, and blue, which is 0000, FF.
Then you get the combinations.
And the combinations are yellow, FF, FF0000, magenta, FF00, FF, and cyan, 0, FF, FF.
Now, did you notice something interesting about what happens with colors here?
In online digital color for the web, things like that, the colors we use are red, green, and blue, RGB.
In the print space, and you would know this if you had, for instance, a color printer.
The colors that are combined are yellow, cyan, magenta, and yellow, which are what you get from combining red, green, and blue.
So they are two different ways of doing things, but it shows there's a relationship between the colors here.
Now, I don't really want to stop right now and do a whole in-depth look at color theory.
I'm just kind of pointing that out so that you see that there's a relationship.
So, that concludes our look at the contrast modes, and we have three groups to go.
On our next tutorial, we'll look at the inversion modes.
So, this is Huka for Hacker Public Radio, signing off, and encouraging you as always to support FreeSoftware.
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, then click on our contributing to find out how easy it really is.
Hacker Public Radio was founded by the Digital Dove 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 status, today's show is released under Creative Commons,
Extribution, ShareLite, 3.0 license.