Gum15 - Selective Hue Shift - Color Mask script

Dear Adam,

After some wrestling with the ColorMask script, I came to understand that the script uses the "h" value in in CIE L*c*h* read out mode, not the "H" value in HSI or HSV mode. I'm not an expert in color spaces so I believed  H and h values would be the same but discovered the hard way that they weren't.

When I press the Red button, the script selects magenta and blue....when I press the Blue button, it selects red, yellow and green. 

However, when I enter the h value, it selects that color precisely.

I'm wondering if there is something wrong in my PI setting ? This can be a pilot error too... the developer of the script also recommends using the "h" value here --> https://pixinsight.com/forum/index.php?action=post;quote=67432;topic=7751.75

"ColorMask selects colours based on hue values.  If you're having problems selecting specific areas it's worth checking the values in those areas with the readout cursor.  Go to the Edit>Readout Options dialog then choose CIE L*c*h* for the Data / Color Space and enable Show Readout Preview. Then click around the areas of interest and note the range of h values you see.  Make sure the range you select in ColorMask includes these values."

In this case, the preset color buttons are useless and misleading, aren't they ?

I will appreciate your input on this...

Best wishes

Sedat

Comments

  • I agree with you!!
    There is a shift of 60 degrees or something between h and H.
    Here is the thing... Color Mask appears to work in h space as you say... but the Buttons seem to describe H space. At the moment...until I look into it more... I think Rick made a mistake and mixed his h and H!!!
    That is my theory for the moment. 

    Unfortunately..this means I did not quite explain Color Mask correctly..and will need to go back and fix things. Damn it!

    -the Blockhead

  • Indeed! Sorry for being the bearer of  bad news! But hopefully other members will read this post and use the h space as the selection criteria.

    Thanks for your time !


  • Sedat and Adam,

    This discussion is extremely helpful. I had attempted to use Color Mask in the past with very unsatisfactory results base on selection hue with HSV. After seeing this posting I tested selecting a color range with CIE L*c*h* and creating a Color Mask. The results were much more strongly correlated to my hue of interest. 

    But, what I don't understand is the mapping from H to h. Doing selections on some common points on a sample color image, I get the following samples when using the readout modes for h and H. For red and green colors the offset on the color wheel is ~30 deg while it is ~60 deg for green colors. So it seems the difference in the color spaces is more than a simple angle offset.

    h H delta
    21 349 32
    G 128 97 31
    B 291 228 63

    I clearly need to do some more research to understand these color spaces, but knowing they are different is the first step to understanding.

    Regards, 

    Andrew
  • The wikipedia article, https://en.wikipedia.org/wiki/CIELAB_color_space, explains why the mappings are different. I think the following is the best summary from the article:

    "The LCh color space is not the same as the HSV, HSL or HSB color models, although their values can also be interpreted as a base color, saturation and lightness of a color. The HSL values are a polar coordinate transformation of what is technically defined RGB cube color space. LCh is still perceptually uniform.
    Further, H and h are not identical, because HSL space uses as primary colors the three additive primary colors red, green, blue (H = 0, 120, 240°). Instead, the LCh system uses the four colors yellow, green, blue and red (h = 90, 180, 270, 360°). Regardless the angle h, C = 0 means the achromatic colors, that is, the gray axis."

    My summery: it appears as if h is perceptual and based on four colors. H is not perceptually uniform and based on three colors, RGB.
  • Hi Andrew,

    Great summary! Think the issue that people are running into (which I did not appreciate myself) is that by working in h space, the BUTTONS need to refer to h as well. But as Sedat found out... they do not! 
    If you press the red button... you would want to select an h value range of 338 to start and end at 77 (or so...I measured the 120 degree primary H positions on a color wheel). 

    Please see these two images... which I think captures the issue:

    First is the current default when pressing the RED button... it gives a range of 300-60... which is the H range.. not h!!!!
    image

    And then the approximate expected values you *should* input:

    image
  • edited January 2020
    Good day Andrew and Adam. Thank you for your time and effort. As I suspected, there was something wrong with my PI settings so I did reset them and obtained the following new "h" values:


    I hope they are in line with yours this time...

    The buttons are not an essential part of this script but in their current state they are misleading. As long as you remember to use the "h" values for your targeted color range, the script works perfectly.
  • Personally... I think what would be better than the buttons would be an "h" wheel or geometric form (it might not be a circle) that labels the h values. Then you could simply look at the image to input a desired range. 

    Given what we know now... do you think I should address this in an added video to what I have already published? I have the right idea in terms of usage... but I was definitely mislead concerning the H vs h values.
    I am leaning towards doing it... but I just do not want to re-do the whole thing!

    -the Blockhead
  • edited January 2020
    Hi Adam, 

    I believe a note added to the page hosting the video would be sufficient. I think a postscript video addition to what you have already done would be even better. Without the explanation that the Color Mask script works in h space and that h and H are different things, this tool is confusing. I would also include the explanation that the readout mode can show h or H depending on setup. But, I don't think you need to redo the core of your video. It does what it needs to do.

    Learning about h vs H was quite a revelation for me.

    My $0.02,

    Andrew
  • What Andrew says... I don't think you should redo the whole thing.. this is an important detail but could be conveyed via an overlay text where you are suggesting to switch to HSI readout mode.

    Cheers

    Sedat
  • Done. I did add a new section. 
    In addition... demonstrated what the spacing is for constant values of "h" ... it is really weird but informative!
    Please let me know if you think this puts this issue to bed.
    -the Blockhead
  • edited January 2020
    Thank you Adam! This is a very enlightening video.

    I'm afraid there is even more going on here and it has something to do with PI's handling of the CIE L*c*h* or maybe, with PI Color Management Setup, ICC Profiles etc.

    https:// commons.wikimedia.org/wiki/File:Cielab-circle.png

    Regarding the Cielab-circle linked  above, you mention that the values do  not correspond to what you see in PI and that the circle must have been labeled wrong. Well, my PI readings were similar to yours previously, as I mentioned above, but after I reset my PI settings, they are, now, somewhat closer to the label values on the h circle image but not everywhere. There is a real mystery here that needs to be resolved.

  • edited January 2020
    Sedat,

    First... lets clear up the major issue... 
    Would you agree that pressing the RED button with a range of 300-60 is not correct?

    Second: I did not say they were mislabeled...I said they were different likely due to differences in brightness- the L is correlated with h for the perceptual eyeball reasons I guess... which is what I show in the next part of the video...and that correlation is weird! I shouldn't have shown that wheel I think... but I couldn't resist.

    Last... I am pretty certain that values of CIE Lch, no matter what they are, should be something *independant" of devices and software. They are mathematically defined. For a given image, you and I should agree on h always (not matter how it appears on our screens). It seems you are saying this isn't true... so what did you reset? (And why in the world did it change anything in this color space??)

    -the Blockhead
  • Hello Adam,

    I fully agree with you that pressing the buttons is not the way to use this script at its current state. The script produces the desired mask only when we use the "h" values to determine its operation range.

    For your second and third points, I think these are kind of connected. Sorry, if my comments came across in a negative way to you but that was not my intention. All I wanted to say was PI wasn't consistent over the h values across my various PI installations on 3 different systems, 1x Macbook Pro and 2 Windows machines. When, I reset the Windows installations via - StartMenu/All Programs/Pixinsight/Pixinsight - Reset Settings -  all three installations started showing the same values for the same hue. 

    I don't know what is affected by this PI platform reset but this action is certainly affecting a particular  parameter which brings the "h" values closer to the Cielab color wheel you shared, although there is still some difference on the blue/green area.

    For some reason, I'm not able upload images to my posts here so I cannot show you what I mean by sharing some images.

    I also believe that these h values  should be device and software independant and yes, I'm saying this is not true at the moment. I tried to find a way to read the h value in Photoshop but couldn't figure out a way to do it. When I have time, I will try to find a software which can read the h values...

    I'm also planning to post my experiences on the PI Forum and ask Juan to comment on this issue.

    Clear skies

    Sedat
  • Hi Adam,

    I just got a chance to watch your addendum on the h color space and I think you put it to bed. You demonstrated that using h to do hue selection for the Color Mask script works as expected whereas H does not. You all demonstrate that the easy color selection buttons don't current work. I thought your final section was a fun exploration of the h color space. 

    Unfortunately, you will probably need to make changes again when the Color Mask script is corrected. 

    Regards,

    Andrew
  • Hi Adam

    Picking up on this old thread where the hue values don't seem to correspond to what's expected in the ColorMask script, I modified the script to globally replace the function CIEh() to H() so that the script is using the H rather than the h color space for the internal workings. As the H space has a more even color wheel, and also the color buttons now correspond to what was intended this seems like a useful modification - what do you think?

    Regards
    Gordon
  • Excellent! I will have look asap. Thanks for your time and effort.

    CS

    Sedat
  • Gordon:

    I think you are going to make me have to go back and make another video. lol
    Is this an official update to the script (or just you editing the code on your installation)?
    If this is an official adjustment- I could certainly use some language/screenshots to update my video (page) at a minimum.

    -the Blockhead

  • At the moment it's just me editing the code. I've never released a script and anyway it's mostly the original code with just this small change. I can post it here if people would like to test it out?

    Gordon
  • The script file is attached for anyone who would like to test it out. It seems to work ok in the tests that I've done so far - but no warranties! You will need to copy it to a suitable location and then select Feature Scripts in the Scripts menu and find and add the script. For the moment I've called it ColorHueMask.

    All feedback welcome.

    Gordon
    zip
    zip
    ColorHueMask.zip
    6K
Sign In or Register to comment.