Understanding and Working with HsY
|
|
Abu Nasu
Code Monkey
Join date: 17 Jun 2006
Posts: 476
|
12-16-2006 03:18
I'm a fairly hardcore Photoshop user. Sometimes I'm so hardcore, I've been known to give even advanced gurus a headache. Those that know me, know very well how prone I am to rambling about a variety of topics. Since you folks don't know me and I've been rather quiet, I'm finally gonna jump in and give y'all a taste of my ways.
Now, I'm a very nuts-n-bolts kind of guy. I'll take the simpliest thing, tear it apart, turn it into a mountain, and then break it down again. I'm into understanding every little thing so I can use those things with intent, and so I'm not left wondering why something isn't working even though I think it should be.
To start, I want to talk about colour spaces. In particular, HSL and HSB. These are two common spaces and bits of them can be seen in certain places in Photoshop.
HSL = Hue, Saturation, and Lightness HSB = Hue, Saturation, and Brightness
HSL is commonly depicted in 3d space as a double cone, while HSB is commonly depicted as a single cone. Both of these 3d depictions are misconceptions. Why? Because in both spaces, Sat is a percentage from 0% to 100%. This actually makes both spaces look like a cylinder in 3d. Not terribly relevant, but you never know if that little bit will come in handy.
One place you can find HSL in Photoshop is in the Hue/Sat command (ctrl + u). One place you can find HSB in Photoshop is in the Colour palette.
Personally, I like to keep my use of spaces rather consistant. The different spaces have different definitions for the pieces, and I like to avoid the little surprises that can result when mixing spaces. Not that I can't deal with them, but I would prefer to not have them crop up at all.
Which brings us to blending modes. These can be found all over the place in Photoshop. From Layers palette, Brush Tool option Mode, and many others.
I'm sure many of you are familiar with the blending modes Luminosity, Hue, Saturation, and Colour. Now, this is where things get kind of messy.
When using those blending modes, yet another colour space is being used. I used to call this space HS/Lum, but that was kind of confusing. One day I had a little chat with the guy from Simpel Filter and found out that he calls this space HsY. I like HsY better because its easier for... various reasons. Although, Y = Luminosity and that can lead to some confusion. So, when I say Lum, I'm talking about Y in HsY.
Yeah, it can be a mess.
Just for fun, lets take a look at one of the major differences in these three different spaces.
Brightness = Max(R,G,B) Lightness = ( Max(R,G,B) + Min(R,G,B) ) / 2 Luminosity = R*0.30 + G*0.59 + B*0.11
Even though B, L, and Y are basically the same component of their respective spaces, the definitions are *very* different - and those differences can lead to some interesting hair-pulling sessions.
That's just a few thoughts for now to get you thinking. If you bear with me long enough, the foundation will be laid and we'll get to the really good stuff. Yes, this stuff will eventually become very relevant.
|
|
Abu Nasu
Code Monkey
Join date: 17 Jun 2006
Posts: 476
|
12-16-2006 08:40
Okay, let's chat about one thing about these spaces that is consistant for all three spaces: Hue. No matter which space or range, hue is hue.
But it's not so much hue as a range that I'm interested in. Rather, I'm interested in how pure, or raw hue is manifested in RGB values.
Somewhere in the Gradient presets, there is a full spectrum preset. It's RYGCBM in all of it's fully saturated glory. I keep this loaded by default because I use it so much and I can't remember the name of the preset set that it's a part of, but shouldn't be too hard to find. Find it, and lay it down in a new document. Make sure your Colour palette is open and set to RGB sliders. Grab the Eyedropper tool and run it around. As you do, keep an eye on the RGB values. As you do, you should eventually notice a pattern. That pattern goes something like this:
- one value will always be 255 - one value will always be 0 - one value will be variable
When looking at the pure hues of a photograph, that pattern is what we are after.
I've read a lot of tutorials on how to get pure hues out of a photograph and they are all the same - and they all fall short. They don't come anywhere near to getting the Hue <> RGB pattern. Meh!
The technique that I'm about to show you is *much* better. Still not quite perfect, but way tons better like a pillow case filled with bricks.
- Start with some random photograph. - Layer > New Adjustment Layer > Invert, bring Opacity down to 50% - Layer > New Adjustment Layer > Hue/Sat, Hue +180 - Clip the Hue/Sat layer to the Invert layer - Layer > New Adjustment Layer > Hue/Sat, Sat +100
You should now be looking at a bunch of uber saturated hues. Truly a thing of beauty.
I have recorded myself an action that will start a layer set and create all of that in the set. Just collapse the set when done and turn it on/off as needed. And, since it's all adjustment, its... dynamic. That is, you can make changes and see them on-the-fly. I highly recommend that you record your own action and use it like a madman with a pillow case filled with bricks.
There is one little thing about this technique that is interesting, and that is what happens when there is no saturation. I'll leave it to you to see this phenom for yourself.
And, like I said, it's not entirely perfect. There is a little thing that happens with quantanizing, but you have to look for it to notice it. Bonus Abu points if you find it.
Now, this trick may seem like a bauble, but it's *immensely* useful. It can reveal a great deal about a photograph. You may even make some interesting observations about the nature of hue in photographs and our human perception. For example, green grass isn't always green.
Play with it.
|
|
Abu Nasu
Code Monkey
Join date: 17 Jun 2006
Posts: 476
|
12-16-2006 17:27
Time for some chat about saturation. Now, I don't really know how to define saturation in words. Brilliant colours? I don't know. But I do know how to define saturation as a formula, and that will tell us a great deal more than words can.
In HSL and HSB, saturation is a ratio or percentage. This is why these spaces look like cylinders in 3d space. However, the little 's' in HsY isn't a percentage, it isn't relatived. Rather, sat in HsY is an absolute.
And here is the formula:
Sat = Max(R,G,B) - Min(R,G,B)
That's it. No fancy-smancy division. Just plain ol' subtraction.
So, how do we get the sat in HsY out of a photograph? If you know your ChOps and blending modes, the above formula tells you all you need to know. But there is a way that is a bit simplier and dynamic.
Enter: Selective Colour
- Layer > New Adjustment Layer > Selective Colour
In SC, there is a drop-down that allows you to tweak RYGCBM and HML. For RYGCBM, bring the Black slider all the way down to -100%. For HML, bring the Black slider all the way up to +100%. Make sure that the Absolute checkbox is checked.
And that's it. You will be left with sat in HsY in greyscale. Pretty snazzy, eh?
* This may seem backwards, but Selective Colour is subtractive. You know, print instead of monitors.
Go ahead and use your favorite method to copy merge and paste.
Now, putting the saturation back in can be a bit tricky. Let's go back to the forumla for second:
Sat = Max(R,G,B) - Min(R,G,B)
If you are in RGB mode and looking at greyscale, then R = G = B. This means that no matter what value of grey you are looking at, sat = 0. This does us no good for putting saturation back in.
The trick to putting the saturation back in is, once again, in the forumla.
- Make sure your saturation in greyscale is on a layer all by itself. - Go to G channel in Channels palette and fill with pure black. - Go to B channel in Channels palette and fill with pure black.
You should now be looking at saturation in, uh... red scale. Or whatever you want to call it.
Go ahead and set the blending mode to Saturation and watch the magic. If you are looking at the exact same photograph that you started with, then you did good.
Why does this work? It's in the formula. We now have something a bit like this:
Sat = Max(R,G,B) - Min(R,G,B) Sat = R - (GB) Sat = R - 0 Sat = R
Tada.
If you were to extract S in HSL or HSB and tried to put it back in using Saturation blending mode, you would be getting a shift in saturation. You are taking one form of saturation and applying as another. Egads! I'll drop a few more notes about this later.
Now, working with saturation in red scale can be a bit different. For example, if you want to use Curves or Levels to tweak saturation levels, you have to do so in the R channel. No big deal. Same goes for hand painting saturation in this manner. It's just a little shift in flow, but definitely worth trying.
Bear in mind that tweaking saturation with Curves in this manner is far different than setting a Curves Ad-Layer to Saturation. Extracting and tweaking saturation as I have shown is far more predictable and actually makes far more sense to most folks.
Once again, I have recorded myself an Action that will set up the Selective Colour adjustment layer for me with but a stroke of a key. Nice.
|
|
Cottonteil Muromachi
Abominable
Join date: 2 Mar 2005
Posts: 1,071
|
12-17-2006 05:11
Mmm, useful. . . .like an umbrella. . . made from newspaper.
|
|
Abu Nasu
Code Monkey
Join date: 17 Jun 2006
Posts: 476
|
12-17-2006 10:12
We have hue and we have saturation. This means that we have colour.
Colour = Hue + Sat
Each alone are pretty powerful for fixing photographs. Together, they add up to some amazingly quick and easy fixes. Like I said, I'm about bits-n-pieces. Fix the little things, and they will add up. I'm going straight to the problem and fixing it there in the little things. No mucking about.
Lets say that I have two photographs that are wildly different. Let's also that I want to mix the two. I just just hear a bunch of people hollering about Clone, Healing, and various other things. Me? Find the differences and bring them together. I can see the differences on a certain level with my eyeballs. But... what exactly are the differences?
The first thing I'm going to do is extract Hue + Sat = Colour information. One kid has higher sat in the yellow hues. The other kid has lower sat reds/magenta. By looking at hue and sat seperately, I can fix uber quick-n-sleazy with Hue/Sat - and see the fixes at the level at which I am implementing them. That is, I'm looking at *just* Colour (Hue + Sat) without the Lum playing tricks on my eyes.
Quick and easy with visual feedback. Less than five minutes and their colour information has been normalized. Boom. Done deal.
* I did make two strokes with Paintbrush above the one kid's eye. The compression was a bit too much right there.
|
|
Abu Nasu
Code Monkey
Join date: 17 Jun 2006
Posts: 476
|
12-19-2006 17:11
Much to the chagrin of my adoring fans, getting sucked into other things. This means I will probably disappear for awhile. But I still want to toss a few simple things out there. These last little tid-bits are pretty basic, but lead to some awesome techniques.
How do we get Lum out of a photograph? The Y in HsY?
The formula is:
Lum = R*0.30 + G*0.59 + B*0.11
Looking at that, one of the more obvious ways to get Lum is to use Channel Mixer. Just check Monochrome and use those numbers.
A slightly less obvious method to get Lum is through Sat. Rather, the lack of Sat. If you take the saturation out, there is no hue, and you are left with luminosity. Just make sure you are taking the right flavor of saturation out. That is, take out the s in HsY.
- new layer - fill with any shade of grey - set blending mode to Saturation
And you will be left with Lum, or Y in HsY. This is the exact same information used by the Luminosity blending mode. No surpises when you switch this to Lum blending mode. Contrived and predictable.
Using a greyscale layer set to Sat is just as dynamic as the Hue/Sat tricks I showed. You can adjust the Lum while keeping an eye on it without the colour information playing tricks on your eyes.
Although, sometimes I'm in the mood for a little variation: - Edit > Fill -- Using: White, Black, or 50% Grey -- Mode: Saturation
Quick experiment: - start with a random photograph with some decent saturation - copy to new layer - on the copy, ctrl + shift + u - set blending mode to Lum
As you turn that layer on and off, you will see some differences. Why? Because you extract L in HSL, but are putting it back in as Y in HsY. Since the two are different, the results are different.
As I'm sure a lot of you folks know, lighting information is very important to use humans. The lighting information, shadows and highlights, gives us visual clues as to the topography of a surface. This is why colour information is compressed more than lighting information in several image formats.
When it comes to 3d work, such as done by the artists in SL, therein lies a great quandry. How much lighting in the texture and how much lighting left to the render engine? If there is too much in the texture, it can look oddly wrong in-world. If you don't put enough in, it can look way too flat.
This is where we get into the idea of frequency. It might sound odd, but 2d information can come in different frequencies. High frequency in a photograph is the finer detail, like stitching. Low frequency in a photograph would be the gross shading from ankle to thigh.
Here is the very basic technique: - random photograph and extract the Lum to it's own layer - copy the Lum layer to another layer for 2 copies of Lum - on the bottom Lum layer, Gauss @ 10 - on the top Lum layer, High Pass @ 10 - set the High Pass layer to Linear Light @ 50% Opacity
You should be looking at pretty much the same Lum information that you started with. Take it apart into high and low frequencies, then put it back together.
Maybe seem like a bauble, but immensely useful. Let's say you take the time to come up with a low frequency solution on an avatar. Just basic, gross lighting. You can then extract the finer detail from other sources and layer right over the low frequency. Why, you can even use the low frequency solution over and over for different sources of high frequency. Got two wildly different shirts that you want to take into SL? Take out the finer details, layer over the gross lighting, and the rest is cake.
Believe me, that is the very quick and dirty of it. There are advanced techniques to using frequency.
One example of advanced frequency is breaking a photograph apart into high, medium, and low frequences. Low frequency would be gross lighting from armpit to shoulder. Medium frequencies would be the wrinkles. High frequencies would be texture and stitching.
Another example of advanced frequency use is variable frequency. Not only can you use high, medium, and low, but you can do so in a variable manner. It is more than possible to take the high frequency of eyelashes and the medium frequency of a nose out in one go and on the same layer with perfect blending. Why, you can even blur and sharpen in one go with this technique. The Uber.
Using these techniques, even the basics, it becomes rather trivial to blend things together quickly and easily at the source of difference.
I'm leaving out a lot of little things, but time for me to focus on something else for a bit. Good chance I'll pop in every now-and-again to drop some more notes about this junk.
|
|
Abu Nasu
Code Monkey
Join date: 17 Jun 2006
Posts: 476
|
12-19-2006 17:57
Well, poopy. Looks like I'm back for a little quickie.
Remember the colour information that I quickly normalized? Well, time to do their Lum.
When I picked these two kids, I didn't do any scouting for conducive photographs. The only criteria that I kept in mind was that I had a decent of amount flesh between them. I did not look for two photograph with similiar lighting conditions or anything like that.
Upper-Left Their original Lum. Untouched. As you can see, wildly different.
Upper-Right Used Curves on both to bring values closer together. They currently exist on seperate layers, so no big deal.
Lower-Right With their Lum values closer together, the line between is quick work for Clone, Healing, or whatever. Much easier to blend this line like this than trying to do so on the original Lum. I also painted in some gross lighting real quick. Just a touch of brightening here and there using Linear Light. Just gross painting, so no nitty-gritty painting. Yeah, quick-n-sleazy.
Lower-Left The final Lum with the normalized Colour information tossed back in. While still not exactly perfect, a damn good running start for some quick-n-sleazy prep work. With it all together on seperate layers in HsY chunks, no big deal to fix the little things that need fixing. Or even merge it and use other techniques to finish cleaning it up. Or maybe even spend a little more time to begin with. When I'm in a hurry, I'm naughty like that.
I'm outtie for now.
|
|
Malachi Petunia
Gentle Miscreant
Join date: 21 Sep 2003
Posts: 3,414
|
huh?
12-19-2006 18:10
Is this relevant to SL? Remember, any SL player may be using an uncalibrated sRGB gamut or a fully calibrated larger gamut. This means you have no control over what anyone sees. For example, #FF0000 might not be pure red on all monitors.
Is there a question in here or is it just a statement?
|
|
Chip Midnight
ate my baby!
Join date: 1 May 2003
Posts: 10,231
|
12-19-2006 18:50
This is really interesting stuff, Abu. The final result in your last example is pretty impressive for color matching and I can see many times that would be incredibly useful. Now that you've laid it all out can you give a quick recap of the steps used to match photo B to photo A? That would make the previous explanation a bit easier to wrap my brain around. Thanks!
_____________________
 My other hobby: www.live365.com/stations/chip_midnight
|
|
Abu Nasu
Code Monkey
Join date: 17 Jun 2006
Posts: 476
|
12-19-2006 20:41
Events have transpired and I'm stuck for a bit. So I am going to be rude and say, "I have nothing better to do." Man, that's rude. I hate it when my bud calls me on the tele and says, "I'm bored and thought I would give you a call." Yeah, thanks for thinking of me. How about calling me when you have something cool instead of using me as a last resort for amusement?
Meh.
How about a recap of the whole thing? Text only? Okay.
Like I said, I'm all about bits-n-pieces. Break things down into easy to use and understandable chunks. Fix the little things and eventually they will add up to a better whole. I used to tutor a lot of math and everything always started with two plus two is four. Multiplication is nothing more than addition. If you really want to, you can break calculus all the way down to subtraction. Same idea here of breaking things down. For this, that breaking down is into HsY chunks.
I grabbed two photographs. No real criteria for either other than having some shared flesh to blend. That's it.
Having one photograph over the other, just a layer mask and a little bit of gradient to get the blend going. No painting on the layer mask what-so-ever. None. Just a tight, linear gradient.
Then I started up my raw hue rig. This being those three adjustment layers to expose just the hue information with uber saturation and no luminosity. These are in a layer set all by themselves. I can turn the whole rig on/off easily, and I can see adjustments on-the-fly to hue when it's on.
With raw hue exposed, I added a Hue/Sat adjustment layer to each original photograph and brought the hues closer together. Just two sliders and my eyeballs - no number work at all or getting fancy.
With the hues closer, just a few strokes with a paint brush to take care of some unruly hues that weren't playing nice with Hue/Sat.
Tuck my new hues away and get started on saturation.
Previously, I showed Hue + Sat = Colour in the attached graphic. I actually did the colour work in hue and sat seperately. And, if I remember correctly, I didn't talk too much about this aspect.
With hue taken care of, I started up my Selective Colour to grab saturation in greyscale. Then did the ChOps to get saturation greyscale in just the R channel. Then painted in some saturation using just R. The kid on the right has much lower saturation, so I painted some in using just shades of red.
Put the saturation back in over the hue and you have colour. Hue on the bottom, then sat in red set to Saturation blending mode. At this point, some of the JPEG compression was causing some problems over the one kid's eye. Smudge it real quick and done.
Stand back and take a few minutes to admire. Beautiful. Truly. So far, just a handful of basic techniques and really sloppy painting. That's it.
With colour taken care of, time for luminosity. With luminosity, a bit more care has to be taken. Lighting information has more weight with our peception and has more of an impact than colour information. No more being sloppy like with colour.
* That is a bit of a misconeption. Sometimes little changes in colour can be readily seen. This aspect gets into perceived colour balance. For example, a shade of grey in the middle of a sea of yellow can appear to be blue. Fanscinating subject, but not for today. Just be aware of the background playing tricks on your eyes.
Okay, added a new layer and filled with a shade of grey. Set this to Saturation blending mode. What I'm left with is just luminosity information. Not your average greyscale, but the greyscale used in the Lum blending mode. Kudos for that.
With that still turned on, each original photograph got it's own Curves adjustment layer. Using both Curves, I brought the differences closer together. One got a tad darker, and the other got a tad brighter. Not only did this normalize the lum between the two, but also reduced the visable line between the two. That smaller visable line between the two is much easier to fix with Patch, Clone, et al. Major kudos for that.
With the lum largely normalized and the visable line patched up, time for some minor frequency work. All I did was paint in some areas to be a bit brighter. This is also to help suggest the same lighting source.
Now, thinking in frequency is a bit weird at first. If you ever have this epiphany, you can easily become a master of shadows and highlights. The funny thing is that a lot of you folks aready think like this. All I am doing is identifying it, exploiting it, and spreading Peter Hajba awesome work.
I'll see about clarifying this frequency thing a bit more using an SL-centric example.
See? Bits-n-pieces using simple techniques. A whole lot of sloppy and a little bit of care - it all added up to a better result. You gotta be able to add before you can multiply. Not that there is anything wrong with case study tutorials out there, but I prefer to show things on fundamental level. When armed with the uber basics, the uber advanced comes fast and easy.
Okay, I'm off to work on a frequency example using something a bit more SL.
|
|
Abu Nasu
Code Monkey
Join date: 17 Jun 2006
Posts: 476
|
12-23-2006 01:46
Taking a break from rotating vectors. I got a real quick-n-sleazy example of frequency work for y'all.
Now, lighting information can be a real pain to work with. Our eyes are rather sensitive to lighting information - details and subtle shading make all the difference. This is how we see surface curvature and texture.
Is there a way to break lighting down into easy to manage chunks? There is, and that way is frequency. In this particular little chat, low and high. Or gross/broad and detail.
See attachment.
In the upper-left, we have a small chunk of some photosourcing I was working on some months ago. It's unfinished and I'm not sure if I'm gonna finish it. Looking at that little chunk, the lighting suggests that the main light source is up and to the left. This is evident in the lighting around the eye, nose, and lips. That suggestion of lighting does us no good. I mean, it's just not good. If we leave the light source like that, then it will look funny when a real light source is on the other side. If we mirror it to the other side, it will look even funnier, especially down the middle right down the nose.
Ugh!
Lighting in the texture and lighting in the render engine... quite the quandry.
One of the better solutions is to have general purpose lighting in the texture. A common solution for this is ambient occlusion. Or you can just paint some in. You know, darker armpits and lighter shoulders. Whatever you are comfortable and capable of.
For the gross lighting in this, I'm going to borrow from the other thread. You know, that thread about with the funny talk about normals and falloff maps. Using those tricks, I'm going to put the gross lighting right in the middle and slightly up. This is in the upper-right of the attachment.
Now it's time for the details, or high frequency. I'm going to go back to the original image, extract the Lum information, and run High Pass on it. I think the radius I used was around 7 or so. I can't really remember. This is in the lower-right of the attachment.
Time to put it all together. Colour information from the original. Gross lighting using Lum blending mode from the normal thing. Then detail from the original put back in using Linear Light. (For the most part, I prefer Linear Light, but sometimes I'll settle on another blending mode depending on various things.)
The final result of putting it together is in the lower-left. As it is here, I've uploaded it and it looks pretty good on my avatar. It looks a bit too flat in Photoshop, so I was a bit suprised at how good it looks in-world.
Of course, could use more tweakage to make it look even better. - take out the highlights in the High Pass layer around the nose and/or move said highlights to the middle (very end of nose) - a little more saturation on the outer curve of eye - a touch of darker near the jowel in the gross lighting - reduce some of the halo in the High Pass around eyebrow - take out the bright spot right in the nostril in the gross lighting
Because of the way I have it torn apart and put back together, those fixes should go pretty quick and easy. Then I would be ready to really shine at the skin shops.
Pretty neat, huh? Using frequency, the light source was completely moved and detail has remained. Although, don't get too crazy because the finer detail can suggest different lighting than the gross lighting and that can be confusing to our eyes as well. But smaller shifts in the gross usually go unnoticed.
And that is frequency in a nutshell. Quick-n-sleazy. There are more techniques to using frequency, but I'll save them for another day.
|