Author Topic: New script: ColorMask  (Read 81912 times)

Offline RickS

  • PTeam Member
  • PixInsight Jedi
  • *****
  • Posts: 1298
Re: New script: ColorMask
« Reply #105 on: 2017 August 06 14:03:58 »
I'll have a look tonight, Andrés.  Have you tried using readout mode to check the hue values in the synthetic images?  Color is a very slippery thing!

Cheers,
Rick.

Offline RickS

  • PTeam Member
  • PixInsight Jedi
  • *****
  • Posts: 1298
Re: New script: ColorMask
« Reply #106 on: 2017 August 07 04:38:15 »
Hi Andrés,

I had a play with synthetic images as you did.  Everything is behaving much as expected, IMO.  I have done the same exercise before and got the same confusing results as last time.  I think that colours can be very subjective.  My wife and I certainly don't have the same sense of colour  :D

The way the script works is by assuming that each of the predefined colour ranges is 120 degrees wide and centred on a multiple of 60 degrees (0 = red, 60 = yellow, 120 = green, etc.)  This is only approximately correct, but I find it close enough most of the time.  For careful work I use the cursor readout to check actual hue values in my images.

The big complication is that in reality hue isn't a simple linear thing.  If you look at one of your synthesised colour images with the readout cursor you will see some weird stuff.  What is the hue value at the endpoint where it should be 360 degrees? On the 0.5 chrominance image it is 359.28 degrees which is pretty close, but on the 1.0 chrominance image it is 3.2846 degrees.  You may get different results depending on what colour space you are using but I don't expect them to be any less weird.  Here's another weird thing: the hue values through most of the green area in the 1.0 chrominance image are all the same at 134.3887 degrees.  I presume what is happening here is that the colours are being clipped to the gamut of the colour space.  Take a look at the L values.  They aren't all 0.5 as you would expect.  Similarly, the chrominance values aren't all 1 - they vary between roughly 0.4 and 0.8.

So, to build a ColorMask script that works "perfectly" you need to take into account the intricacies of colour spaces and the varying human perception of colour.  That's something I couldn't do without a lot of research and perhaps not even then.  Despite being simplistic I think the script is still useful but I'd be happy to jump ship if someone builds a better one!

Hope that explains your results & concerns.  If not, let me know the details including what colour space you are using.

Cheers,
Rick.

Offline Sedat

  • Member
  • *
  • Posts: 63
  • Newbie
Re: New script: ColorMask
« Reply #107 on: 2020 January 13 06:11:54 »
Hello Rick,

Thanks a lot for developing this script. It's a great tool.

I'm having the same problem that Andres reported some time ago. When I use the "h" value everything is fine, I'm able to pick the colors I intend to. But when I use the preset buttons it's a different story. For example, when I press the Red button, the script selects magenta and blue....when I press the Blue button, it selects red, yellow and green colors on the attached color wheel image.

h value readouts are as follows:

Red - 77
Yellow - 106
Green - 138
Cyan - 237
Blue - 307
Magenta - 330

whereas H values are 0, 60, 120 etc respectively, distributed evenly at 60 degrees separation.

I'm no expert in color spaces and I will do some more reading tonight. Maybe, there is something wrong with my PI settings which is causing this issue.

Sedat

Offline RickS

  • PTeam Member
  • PixInsight Jedi
  • *****
  • Posts: 1298
Re: New script: ColorMask
« Reply #108 on: 2020 January 14 03:08:54 »
Hi Sedat,

Thanks for the kind comment.  I have just retired and will hopefully have a bit more time for writing scripts now :)

I don't think it is likely that your PI settings are causing this issue.  It's just that our perception of colour is complex and varies from person to person and the simple rules that are currently used for the colour buttons are only a rough approximation of reality.  I did experiment with more complex ranges to match better in the past but it wasn't an unqualified success and I came to the conclusion that custom ranges were almost always required in practice anyway.

Cheers,
Rick.

Offline Sedat

  • Member
  • *
  • Posts: 63
  • Newbie
Re: New script: ColorMask
« Reply #109 on: 2020 January 14 04:51:06 »
Thank you for your kind answer. Congrats on your retirement! Hope this proves to be a good thing :) I have not been able to retire myself yet....

The thing is the color buttons are taking H values as their reference whereas the script only cares for the  h color space values.

When the "Red" button is pressed it spits out a range between 300 and 60 degrees which is wrong by h color space standards. These values should be something like 40 to 90 for Red. The color buttons are producing the color ranges in H color space which, apparently, doesn't mean anything to the script. Below is a chart I just put together showing H and h values of some colors. There should be nothing subjective about these figures as far as I understand.





Sedat

Offline pfile

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 4729
Re: New script: ColorMask
« Reply #110 on: 2020 January 14 08:49:44 »
for me, it seems that the script produces proper masks for a given color when i press the buttons, but any time i tried to measure my image the way Sedat has and then input ranges into the UI i always got something unexpected. i decided it was user error/ignorance of the h color space and stopped trying to fine tune it.

rob

Offline Sedat

  • Member
  • *
  • Posts: 63
  • Newbie
Re: New script: ColorMask
« Reply #111 on: 2020 January 15 03:27:09 »
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 others 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.
Sedat