170 lines
14 KiB
Plaintext
170 lines
14 KiB
Plaintext
|
|
Episode: 3440
|
||
|
|
Title: HPR3440: Lighten Layer Modes
|
||
|
|
Source: https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr3440/hpr3440.mp3
|
||
|
|
Transcribed: 2025-10-24 23:28:41
|
||
|
|
|
||
|
|
---
|
||
|
|
|
||
|
|
This is Hacker Public Radio Episode 3444 Friday, the 8th of October 2021.
|
||
|
|
Tid's show is entitled, Light and Layer Modes, and is part of the series'
|
||
|
|
Gimp It Is Hosted by Aoka, and is about 19 minutes long, and carries a clean flag.
|
||
|
|
The summary is, we continue our look at the Layer Modes, and gimp with the Light and Modes.
|
||
|
|
This episode of HPR is brought to you by an honest host.com.
|
||
|
|
Get 15% discount on all shared hosting with the offer code HPR15.
|
||
|
|
That's HPR15.
|
||
|
|
Better web hosting that's honest and fair at An Honesthost.com.
|
||
|
|
Hello, this is Aoka, welcoming you to Hacker Public Radio and another exciting episode
|
||
|
|
in our ongoing Gimp series, and we are continuing our look at the different Layer Modes,
|
||
|
|
and today I want to look at the Layer Modes for Lightning.
|
||
|
|
Now, remember that the Layer Modes are ways of combining two layers so that they interact
|
||
|
|
with each other in some way.
|
||
|
|
So, the first Layer Modes I'm going to look at is something called Light and Only,
|
||
|
|
and Light and Only looks at each component of each pixel in the top and bottom layers,
|
||
|
|
and always selects the largest value for the combination.
|
||
|
|
That means it will always, at the very least, lighten since larger numbers are lighter than
|
||
|
|
smaller numbers. Now, in RGB space, pure black is 0000 in hexadecimal, and pure white is FFFFFFF.
|
||
|
|
Each component is a two-digit hexadecimal number, where the first two digits are red,
|
||
|
|
the next two are green, and the last two are blue.
|
||
|
|
So, as an example, if you had a pure red layer that would have the combination FFF0000,
|
||
|
|
if you had a pure blue layer that would have the formula 0000FFF.
|
||
|
|
Now, if you combine to them using Light and Only, the result would be an image where each pixel
|
||
|
|
had the number FFF00FF, and that, as it happens, is magenta, the combination of red and blue.
|
||
|
|
Now, you can do the experiment yourself in GAMP by simply creating some layers,
|
||
|
|
using the Light and Only mode to see what happens. I've done that, and you can see how that works
|
||
|
|
on my web page, which link is in the show notes for all of that, and that's just a good time to
|
||
|
|
mention that given that we're talking about a visual program in an audio medium, which is kind
|
||
|
|
of interesting. So, you know, a lot of the examples are the images, if you want to see the images
|
||
|
|
that I create in doing all of this, you want to go to the web page and take a look at that.
|
||
|
|
Now, again, if you, suppose you took a copy of the magenta image,
|
||
|
|
and then added a pure green layer 00FF00 using Light and Only mode, you would then get a pure
|
||
|
|
white image, because now every pixel would be FFFFFFFF. Now, the point of all of this is to focus
|
||
|
|
on the components. Now, I have seen people say, in shorthand, casually, well, Light and Only mode
|
||
|
|
selects the lightest pixel from each layer. Yeah, not entirely correct, you know. The fact is,
|
||
|
|
you cannot talk meaningfully about pixel lightness separate from the lightness of each component,
|
||
|
|
the red degree in the blue. Now, in a lot of cases, it probably doesn't make a difference,
|
||
|
|
but there are cases where it does. And that's why I always want to emphasize the correct way of
|
||
|
|
thinking about it is to think component by component. So, if you wanted to see what difference that
|
||
|
|
makes, you would have to do some analysis. And in comparing some of these modes, I sometimes do
|
||
|
|
that analysis. Now, the interesting thing is what happens when you're using images with some
|
||
|
|
content in them. Now, I picked kind of randomly two images that I've been using as examples here,
|
||
|
|
because they're very different. And I think that that sometimes is useful. And the very different
|
||
|
|
ones are an image of the face of a dog and an image of a toy with a wizard and a crystal ball.
|
||
|
|
So, with those two images, I did Light and Only. And what happens is, I got a bit of the dog
|
||
|
|
coming through because the side of the dog's head is in sunlight and is lighter than the shadow
|
||
|
|
side of the toy. And because the crystal ball is so dark, you see a bit of the dog come through
|
||
|
|
there as well, even though that part of the dog's head is in shadow in the image of the dog.
|
||
|
|
Now, it's worth noting that for Light and Only, the mode is commutative. And what that means for
|
||
|
|
those of you who haven't studied mathematics in a long time is that the order does not matter.
|
||
|
|
Now, for some layer modes, it is a very clear distinction between the top layer and the bottom
|
||
|
|
layer when you're doing this. But there are others where it doesn't. And those are called commutative
|
||
|
|
layer modes. And there's a number of them. Now, the next thing I want to talk about is Luma slash
|
||
|
|
luminance light and only. And this gets a little bit technical. I've got links in the show notes
|
||
|
|
again to a lot of this stuff. Luma and luminance are measures of brightness. The difference appearing
|
||
|
|
to be whether one measures it in black and white or in color. Now, Wikipedia is frequently my go-to
|
||
|
|
source for good basic explanations of these kinds of things. Which is good because in fact,
|
||
|
|
this is not documented at all in the GIMP documentation. Now, in video, in video, in video,
|
||
|
|
Luma represents the brightness in an image, the black and white or acromatic portion of the image.
|
||
|
|
Luma is typically paired with chrominance. Luma represents the acromatic image
|
||
|
|
while the chroma components represent the color information. Converting our prime G prime
|
||
|
|
B prime sources such as the output of a 3ccd camera into Luma and Chroma allows for Chroma
|
||
|
|
subsampling because human vision has finer spatial sensitivity to luminance, black and white
|
||
|
|
differences, and chromatic differences. Video systems can store and transmit chromatic
|
||
|
|
information at lower information, optimizing perceived detail at a particular bandwidth.
|
||
|
|
So, clearly what they're talking about is how can you compress a signal for broadcast?
|
||
|
|
And a lot of this was initially developed for that reason. Now, luminance is a weighted
|
||
|
|
average of the RGB values. So, again, going to Wikipedia, while Luma is more often encountered,
|
||
|
|
relative luminance is sometimes used in video engineering when referring to the brightness of a
|
||
|
|
monitor. The formula used to calculate relative luminance uses coefficients based on the CIE
|
||
|
|
color matching functions and the relevant standard chromaticities of red, green, and blue.
|
||
|
|
For example, the original NTSC primaries and for the REC 709 and SRGB primaries, the linear
|
||
|
|
combination based on pure colorometric considerations and the definition of relative luminance is
|
||
|
|
and these use different colors. Now, Y equals 0.2126, R is at 0.7152 and green is 0.0722.
|
||
|
|
So, there's a formula for all of this. The formula used to calculate Luma in the REC 709 spec
|
||
|
|
arbitrarily also uses the same coefficients, but with gamma compressed components.
|
||
|
|
And that's the R prime G prime B prime where the prime symbol denotes gamma compression.
|
||
|
|
Okay, now, what the heck is gamma compression? I found a wonderful explanation on a blog post.
|
||
|
|
Again, link on the show notes, what every coder should know about gamma that I thought made
|
||
|
|
it pretty clear. The idea is that brightness is not perceived in a linear fashion, but instead
|
||
|
|
follows a power relationship. And so, the blogger who wrote this says the 24-bit RGB color
|
||
|
|
model used on virtually all consumer level electronic devices uses 8-bit gamma-encoded values
|
||
|
|
per channel to represent light intensities. If you recall what we discussed earlier, that means
|
||
|
|
that pixels with RGB, such as 128, 128, 128, will not emit approximately 50% of the light
|
||
|
|
energy of pixels with an RGB value of 255, 255, 255, but only about 22%.
|
||
|
|
Now, that makes perfect sense. Because of the non-linear nature of human vision,
|
||
|
|
a light source needs to be attenuated to about 22% of its original light intensity to appear
|
||
|
|
half as bright to humans. RGB 128, 128, 128 appears to be half as bright as RGB 255, 255, 255 to us.
|
||
|
|
Now, if you find this confusing, reflect a bit on it because it's crucial to have a solid
|
||
|
|
understanding of what has been discussed so far. Trust me, it will only get more confusing.
|
||
|
|
Of course, gamma encoding is always done with the assumption that the images ultimately meant
|
||
|
|
to be viewed by humans on computer screens. In some way, you can think of it as a lossy MP3-like
|
||
|
|
compression, but for images. For other purposes, like scientific analysis or images meant for
|
||
|
|
further post-processing, using floats and sticking with linear scale is often a much better choice.
|
||
|
|
So, this is all from John Novak, Link in the Show Notes.
|
||
|
|
So, what this boils down to is that most computer monitors utilize gamma compressed,
|
||
|
|
or sometimes called gamma corrected values, for displaying RGB colors. And that's a good thing
|
||
|
|
for most purposes. Now, this makes for a small difference when using Luma Luminance Lighting Only mode.
|
||
|
|
Since this mode will work with the perceived value of the color values rather than the absolute
|
||
|
|
value of them, the main difference is that Luminance is taking into account the brightness of the color.
|
||
|
|
So, I did a combination again of the the dog and the toy, this time using Luma Luminance.
|
||
|
|
And if you're just looking at that compared to the light and only, it's very hard to see a
|
||
|
|
difference. There is a way to get an objective measure of what the difference is, and there's another
|
||
|
|
layer mode that does that, it's called the difference layer mode. I can take any two images,
|
||
|
|
put them on layers and use the difference layer mode to see how different they are.
|
||
|
|
And when I take the two images and use that difference layer mode, and I've put this on the
|
||
|
|
web page, you can see the result. It does pick up differences between them.
|
||
|
|
Now, assuming the black is identical in the two images, and both had white backgrounds,
|
||
|
|
it makes sense that we're seeing a lot of black in the difference image. But where we see color
|
||
|
|
other than black, there is a difference. So, anything black is identical in the two images,
|
||
|
|
anything that's not black represents a difference.
|
||
|
|
Now, screen mode. This actually has a documented formula. Yay! It's a little bit complicated.
|
||
|
|
Again, we're working with the RGB values, which range from 0 to 255. 0 is black, 255 is full color.
|
||
|
|
And again, you do this with the R value, the G value, and the B value separately.
|
||
|
|
That's happening in the background. You may not be aware of it, but you have to do it that way.
|
||
|
|
So, the formula says the resulting image, if you use screen mode, you start with a value of 255,
|
||
|
|
and then subtract from that a complicated expression where you first take 255 and subtract the top layer,
|
||
|
|
whatever that value is, and multiply that by 255 minus the bottom layer, whatever that is.
|
||
|
|
So, they're multiplied together and then divided by 255, and then that whole thing is subtracted from 255.
|
||
|
|
You can see the formula on my web page or in the game documentation.
|
||
|
|
So, what does that mean? Let's take a look at a calculation here. Let's say one image had a red
|
||
|
|
value of 104. It gets inverted as 255 minus 104, which is 151. Then do the same thing for the
|
||
|
|
red value in the other image. So, let's say the other image had a red value of 87.
|
||
|
|
Inverting that by subtracting from 255 gives us 168. Multiplying them together, we get 151 times 168,
|
||
|
|
and that is 25368. Then we divide by 255, giving us 99. Then we re-invert that because we subtract it
|
||
|
|
from 255 and get 146. So, we started with red values of 104 and 87 and wind up with 146.
|
||
|
|
So, the red level is distinctly higher now than either of the starting values.
|
||
|
|
So, in essence, this mode will make dark colors fade more than light colors and can be useful
|
||
|
|
for removing dark backgrounds. Again, this is another example of a commutative layer mode.
|
||
|
|
The order doesn't matter. Whether it's top or bottom, the calculation is the same no matter which
|
||
|
|
order you do them in. In general, this is going to give a more washed out appearance to the resulting
|
||
|
|
image. Again, I've got examples on my web page. Now, I tried using this mode using the image
|
||
|
|
from the Luma Luminance layer mode and the dark image I got from using the Difference mode.
|
||
|
|
Now, as you can see, the black background, if you take a look at the image on my website, is completely gone.
|
||
|
|
Another interesting use of this mode can be seen in a tutorial I ran across from a fellow named
|
||
|
|
Chris Parker, who posts a lot of tutorials on YouTube, and he uses it to create a soft glow effect
|
||
|
|
for photography, such as wedding photos. He duplicates the image, then adds Gaussian blur to the duplicate,
|
||
|
|
then he uses the screen mode to combine the two, and fine-tunes the result using opacity.
|
||
|
|
If you want to see his tutorial, I put a link in the show notes for that.
|
||
|
|
Now, the last of the lighten modes for this tutorial is addition, which is pretty straight forward.
|
||
|
|
You simply add the values from the two images, but the maximum is 255.
|
||
|
|
So, you can't go above that. So, if we had the values for red, as in the screen example above,
|
||
|
|
adding them would give us a value of 191. Since this is less than 255, we can keep this value.
|
||
|
|
But, suppose the values were 104 and 187 in the two input pictures.
|
||
|
|
Then the total would be 291, and we round it back down to 255.
|
||
|
|
Now, this is somewhat similar to the screen mode in effect, but there are differences if you look
|
||
|
|
closely at the two images, such as in the base of the globe, the crystal ball, the wizard's hat,
|
||
|
|
the wizard's beard. There are some small differences there.
|
||
|
|
Now, there is in fact one more lighten mode, but I'm going to treat that in a separate tutorial.
|
||
|
|
It's paired with a darken mode, and also has a couple of tools doing similar things.
|
||
|
|
So, our next gimp tutorial is going to be on Dodge and Burn, where Dodge is the lighten,
|
||
|
|
and Burn is the darken. Interesting stuff there, too, I think. So, this is Ahuka for Hacker Public
|
||
|
|
Radio, signing off, and is always encouraging you to support FreeSoftware. Bye-bye.
|
||
|
|
You've been listening to Hacker Public Radio at Hacker Public Radio.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 HBR 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 dog pound and the
|
||
|
|
infonomican 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
|
||
|
|
on the creative comments, attribution, share a light, 3.0 license.
|