Home Technical Talk

Saturation To Grayscale?

polycounter lvl 12
Offline / Send Message
daniellooartist polycounter lvl 12
I've been looking through plenty of images I enjoy on the internet. One way to study them is to use photoshop's hue/saturation adjustment layer. Desaturating it will expose the value. Giving it full saturation will expose the hue. But is there any way to convert a pixel's saturation value to grayscale? Like saturated being white and desaturated being dark?

Replies

  • bounchfx
    as a kind of side note: I've found that using the Black & White filter in photoshop gives different results from simply sliding the hue/saturation slider down to gray. I was told B&W filter was more accurate to see the values but I don't exactly know the math behind the different functions. 
  • Eric Chadwick
    Hey that's a neat tool! If you check the Tumblr link, there's a link to 3CH Color Analyzer which links to a RAR file at 3CH Color Analyzer. Seems to work fine here in Windows 8.1. The Color Intensity button seems closer to what you're after than the Saturation button.

    Why the B/W filter is different than Desaturation... in Photoshop go to Image, Adjustments, Black and White. Each hue has a different default %. This approximates how the brain perceives the relative brightness of each hue. A nice diagram from here shows how the cells in your eye convert hues differently




  • JedTheKrampus
    Offline / Send Message
    JedTheKrampus polycounter lvl 8
    In Krita: make two clone layers of the image or the top level group you want to analyze. Add a Desaturate filter mask (Rec. 709) to the bottom one and set the top one to Difference blending mode. Add a Desaturate filter layer on top of them both, then a Brightness/Contrast filter layer that you can adjust to more easily see the saturated areas. Works well for image diagnostics (you can group those layers and hide the group while you work) and is nondestructive.

    Example image:



    Saturation measured in this way:



    Edit: this isn't quite right. Maybe I'll try again later.

    Edit 2: I've found that I get the most illustrative results by setting both Desaturates to Lightness. I can't guarantee that the values you get out of this are suitable for converting directly back into saturation.

    Edit 3: I've figured out what I was doing wrong. I didn't separate the chroma data before finding the difference in luminosity. The ACTUAL best layer stack for this task is created like this: create a clone layer of your image or a top-level group, create a fill layer with the color #803f3f, set the fill layer to Luminosity mode, group those two layers, create a clone layer of the group, set that clone layer to Difference blending mode, add a Desaturate (Lightness mode) filter mask to that clone layer, then add a Desaturate (Lightness mode) filter layer above that with a Brightness/Contrast Curves filter mask with the top-right point moved left to the first vertical grid line. Whew. I think that just about does it right, although there's a loss of precision compared to what it would probably look like if there were just a filter that did this.

    I'm using filter masks because you can collapse them. Of course you can do all of this with filter layers instead, if you wish.
  • daniellooartist
    Offline / Send Message
    daniellooartist polycounter lvl 12
    I can't get 3CH to work. It opens for a quarter of a second before closing itself. I'm on the latest version of windows 10. I have attempted this in both admin mode and compatibility mode. I even downloaded the latest .net framework. What gives?
  • Eric Chadwick
    To be clear, did you try it with the suggested .Net installer? http://www.hydropix.com/3CHCA.htm I didn't have to though, it just works.
  • daniellooartist
    Offline / Send Message
    daniellooartist polycounter lvl 12

    Edit 3: I've figured out what I was doing wrong. I didn't separate the chroma data before finding the difference in luminosity. The ACTUAL best layer stack for this task is created like this: create a clone layer of your image or a top-level group, create a fill layer with the color #803f3f, set the fill layer to Luminosity mode, group those two layers, create a clone layer of the group, set that clone layer to Difference blending mode, add a Desaturate (Lightness mode) filter mask to that clone layer, then add a Desaturate (Lightness mode) filter layer above that with a Brightness/Contrast Curves filter mask with the top-right point moved left to the first vertical grid line. Whew. I think that just about does it right, although there's a loss of precision compared to what it would probably look like if there were just a filter that did this.

    I'm using filter masks because you can collapse them. Of course you can do all of this with filter layers instead, if you wish.

    can this be done in Photoshop?



    Also Eric, 
    The link on his page didn't go anywhere.
  • Eric Chadwick
  • JedTheKrampus
    Offline / Send Message
    JedTheKrampus polycounter lvl 8
    Let me spin up my handy-dandy Windows VM and check.
  • daniellooartist
    Offline / Send Message
    daniellooartist polycounter lvl 12
    I'm already on a much higher version of .Net framework.
  • Eric Chadwick
    Does it actually prevent you from installing the older version? Could have some legacy DLLs the tool depends on. Whatever. It seems like you're reluctant to get it working.
  • daniellooartist
    Offline / Send Message
    daniellooartist polycounter lvl 12
    Actually yes it does. I tried installing NetFx20SP2_x64.exe (42.6MB) before. It asked me if I wanted to allow this application to install (click yes) and nothing happens. But I am on Windows 10 and their latest version is 4.6.1 so I can see why it did not work.
  • JedTheKrampus
    Offline / Send Message
    JedTheKrampus polycounter lvl 8
    Well, it's not non-destructive, but I think I've found a way that works pretty well in Photoshop.
    1. Duplicate the layer that you want to visualize the saturation of.
    2. Change the image mode to Lab color (Image->Mode->Lab Color.) Don't flatten the image when it asks you.
    3. In the channels palette click the Lightness channel.
    4. Fill it with neutral gray (L 50, a 0, b 0) (Shift+F5).
    5. Go back to RGB image mode.
    6. Make sure you're on all RGB channels. Make a new layer and fill it with the same neutral gray (Shift+F5). Set this layer's blending mode to Difference.
    7. Flatten it with the underlying layer and convert to black and white (Shift+Alt+Ctrl+B).
    I don't think I know enough about Photoshop to come up with a non-destructive technique. But it might not be impossible.
  • daniellooartist
    Offline / Send Message
    daniellooartist polycounter lvl 12
    Well, it's not non-destructive, but I think I've found a way that works pretty well in Photoshop.
    1. Duplicate the layer that you want to visualize the saturation of.
    2. Change the image mode to Lab color (Image->Mode->Lab Color.) Don't flatten the image when it asks you.
    3. In the channels palette click the Lightness channel.
    4. Fill it with neutral gray (L 50, a 0, b 0) (Shift+F5).
    5. Go back to RGB image mode.
    6. Make sure you're on all RGB channels. Make a new layer and fill it with the same neutral gray (Shift+F5). Set this layer's blending mode to Difference.
    7. Flatten it with the underlying layer and convert to black and white (Shift+Alt+Ctrl+B).
    I don't think I know enough about Photoshop to come up with a non-destructive technique. But it might not be impossible.
    I think I got it working. I noticed it was a bit darker than yours but a quick curves layer bumped it up. Everything seems like it's proportional to the original images saturation value. Thank you so much for putting in the time to figure that out. You're like some sort of color wizard!


  • JedTheKrampus
    Offline / Send Message
    JedTheKrampus polycounter lvl 8
    Yeah, it always turns out a little darker than I would like and I always have to use a curves filter. Good to see you got it working.
  • JedTheKrampus
    Offline / Send Message
    JedTheKrampus polycounter lvl 8
    I also found a much more straightforward way to do it in Krita. You need two 50% gray fill layers, the bottom set to Lightness (or something similar like Intensity), the top set to Difference. Then, you need to put a Desaturate (Rec.709) filter layer on top of both of those. Put them in a pass through group and you can look at the saturation anywhere in your layer stack non-destructively.
  • kwyjibo
    Offline / Send Message
    kwyjibo polycounter lvl 7
    If you have maya, you could probably do this by plugging out color of a file texture node into a rgb to hsv node or rgb remap node (forget which one) and then plug output saturation into r g and b color channels of a material applied to a simple plane. You could make a scene with the shader network set up and select the file in the file texture node when you want to check a file. I don't have access to computer now to try it out but I'm pretty sure it can be done very easily.
  • RN
    Offline / Send Message
    RN sublime tool
    Some cool stuff in this thread.
    I'm also into the approach kwyjibo described, which is to "program" that the saturation should become the RGB values.

    A way to do that can be through ImageMagick, it's a command line application that can convert images and do several filters, such as a "FX" filter where you can write expressions that happen on each pixel (that could do stuff like outputting the saturation as RGB for example). It's kinda brutal, but once you set up a shortcut on your desktop it should work with drag-and-dropping images from the web browser.
    It should be simpler to use than firing up a beast like Maya or Photoshop just for that.

    I also wondered if you couldn't do that with javascript\HTML5, here's is a JSFiddle (a javascript demo) that loads an image and shows the saturation:
    https://jsfiddle.net/48dLgvqb/1/

    There's a commented line in there that also shows it as the "chroma" from LCH (the cylindrical form of LAB mode). It's a different way to measure the vibrance of colours.
    From that candy image Jed posted, here's a comparison.




  • gnoop
    Offline / Send Message
    gnoop sublime tool
    There is a GPL  Photoshop  plugin  for such kind of masking :

    http://www.russellcottrell.com/photo/saturationMask.asp

    works non destructively on smart objects

    ps. To get "right"  grayscale  from desaturated rgb I am using gamma 1.27 in "exposure" adjustment layer  once I run an action that saves a certain layer comp as an alpha channel within an output file trough copy/paste

  • radiancef0rge
    Offline / Send Message
    radiancef0rge ngon master
    You could definitely do this in HLSL by converting RGB to the correct color space which might be HSL? And then isolating the saturation vector?

    http://www.chilliant.com/rgb2hsv.html
  • daniellooartist
    Offline / Send Message
    daniellooartist polycounter lvl 12
    Hello guys. Great advice from everyone here! I'm digging this up again because I think I have reached a conclusion when looking through both 2D and 3D work. And please, correct me if I'm wrong.

    (a) The less diversity you have in your hue, the more diversity you can add in your saturation. Think skin tones with bright red shadows and near white red highlights
    (b) The less diversity you have in your saturation, the more diversity you have in your hue.

    The reason I bring this up is because now is because at some point I want to create 3D material in which the shadows change color. The change depending on the overall average saturation of my scene (which I define myself by typing in a number presumably between 0-1). You know, just to give it some kind of hue offset for saturated scenes and a saturation offset for brightly colored scenes.
  • [Deleted User]
    Offline / Send Message
    [Deleted User] insane polycounter
    The user and all related content has been deleted.
  • daniellooartist
    Offline / Send Message
    daniellooartist polycounter lvl 12
    I misspoke. I should have said, the more you have of one, the more you are [allowed] to add of the other while still maintaining a valid colour harmony. And this is new material shadow colour is based on the object color after it is blended with the light. It wouldn't have to be realistic but some neat styles could come out of it. The cooler end of the spectrum is more forgiving than the warm.

    Using this example from this amazing painter. https://www.artstation.com/artwork/1Z5Ye

    This girl's skin had a wide hue range. Lots of blues blended with orange. But it works because there's still a tons of gray mixed in. This could not happen with highly chromatic colours because blending blue and orange with high chroma just creates nasty gray mud in between, and creates invalid colour harmony.

    Let's look at Vinogradov's painting of Rey in contrast. https://www.artstation.com/artwork/Eben4

    Her skin looks like it has a lot of different hues. But when looking at the range of hues, it sits in a very thin slice of the red range the whole time. But the chroma goes from anywhere to being an off-grey to half way full.

    Despite what may be valid when it comes to photorealistic 3D materials, I don't see why we wouldn't be able to replicate either of these painter's colour pallets regardless of the texture color and light color. So if we tell the material that our scene saturation is low (based on how we eyeball it), then the highlights could add more degrees to the acceptable hue range and shadows could reduce degrees to the acceptable hue range, I imagine there would have to be a few extra parameters to allow some extra controls since these aren't absolute rules, just common patterns.
  • [Deleted User]
    Offline / Send Message
    [Deleted User] insane polycounter
    The user and all related content has been deleted.
  • daniellooartist
    Offline / Send Message
    daniellooartist polycounter lvl 12
    Oh I get what you're saying now. So light dictating colour in the material is an absolute rule right? And this is for all styles and not just photo realism ?

    If that's true, then does that mean light of the opposite colour as the material always turns said more gray in real life? Exception being things glass etc.
  • [Deleted User]
    Offline / Send Message
    [Deleted User] insane polycounter
    The user and all related content has been deleted.
  • RN
    Offline / Send Message
    RN sublime tool
    The colour that comes from the reflection of light from a material can be explained by subtractive mixing.
    Like Teriyaki wrote, a white \ neutral light is the only way to truly know what's the local colour of a material. When the light has some tint or flavor it will influence how our eyes see the material. You can read more about it here: the effects of coloured illumination.

    The context is also important. Our eyes have this thing called "chromatic adaptation" which tries to give us an accurate appearance of objects by adapting to the colour of light sources, or something like that. You can see a nice example here: http://gurneyjourney.blogspot.com.br/2011/09/part-3-gamut-masking-method.html
    There's more material on this if you search for "white balance", a concept from photography: http://ronbigelow.com/articles/white/white_balance.htm
Sign In or Register to comment.