PixInsight Forum

Software Development => New Scripts and Modules => Topic started by: RickS on 2014 November 13 20:22:00

Title: New script: ColorMask
Post by: RickS on 2014 November 13 20:22:00
My first attempt at a script and my first time programming in JavaScript so please excuse any newbie errors.  Any feedback on non-idiomatic PJSR programming, bugs or improvements will be gratefully received.

The ColorMask script is intended to provide a convenient and interactive method for tweaking color.  It builds a mask that selects a range of hues in an image.  You then apply the mask and manipulate the image, e.g. with CurvesTransformation (probably using a real-time preview to examine the results of fine adjustments.)

I have been meaning to play with PI scripting for a while.  David Ellison, who shares a scope with me at SRO, suggested that I try to automate Bob Franke's process for getting nice Hubble Palette colors in PhotoShop (http://bf-astro.com/hubblep.htm).  Trying to do the whole process in one go seemed a bit hard, so this is a first step towards that.  The following demonstrates the use of the ColorMask script to do a quick & dirty color adjustment on a SHO narrowband image of the Soul Nebula.

Here is the "before" image created simply with a [L]RGBCombine followed by an unlinked STF stretch applied with HistogramTransformation.  It shows the usual magenta stars.  The worst of the green was fixed by the unlinked stretch but the colors aren't particularly attractive.

(http://rickstevenson.smugmug.com/photos/i-dhJmdZC/0/O/i-dhJmdZC.jpg)

This is the after image resulting from successive application of a few color masks and manipulation with curves. This was just slapped together quickly as an example.  It is not intended to be a perfect image - just an improvement on the one above  :)

(http://rickstevenson.smugmug.com/photos/i-DWsWZmJ/0/O/i-DWsWZmJ.jpg)

Here are the four steps that I used.

1. Make magenta mask (just click on the Magenta button) then apply desaturation twice:
(http://rickstevenson.smugmug.com/photos/i-vTJtm8x/0/O/i-vTJtm8x.jpg)

2. Apply green mask (just click on the Green button) then reduce Green slightly:
(http://rickstevenson.smugmug.com/photos/i-FLLFH82/0/O/i-FLLFH82.jpg)

3. Apply cyan mask (you can probably guess this one) then use Curves to boost Blue and Red, reduce green and increase saturation:
(http://rickstevenson.smugmug.com/photos/i-TzT4Hk3/0/O/i-TzT4Hk3.jpg)

4. Apply yellow mask and boost Red.  Voila!
(http://rickstevenson.smugmug.com/photos/i-VV3mjkQ/0/O/i-VV3mjkQ.jpg)

I hope some of you find the script useful.  If you have ideas for improvements let me know.

Cheers,
Rick.

NB: as of PixInsight 1.8.5 ColorMask is now included as one of the standard scripts. I would remove the download but it doesn't look like editing the post allows me to do that.
Title: Re: New script: ColorMask
Post by: msmythers on 2014 November 13 20:47:00
Rick,

This opens some interesting doors!



Mike
Title: Re: New script: ColorMask
Post by: RickS on 2014 November 13 21:00:30
Hope you find it useful, Mike!
Title: Re: New script: ColorMask
Post by: gvanhau on 2014 November 14 11:28:44
Hello Rick

I have just a couple of NB images almost ready for processing.
Your script seems interesting to give it a try.

Can it be downloaded from somewhere?
Edit: I just saw the download clip at the bottom.


Geert
Title: Re: New script: ColorMask
Post by: Alejandro Tombolini on 2014 November 15 06:57:16
Hi Rick, it works perfectly well. Thanks for this script.

Saludos,
Alejandro.
Title: Re: New script: ColorMask
Post by: cdesselles on 2014 November 15 11:33:46
After downloading, How do we integrate this script into PI?
Title: Re: New script: ColorMask
Post by: Alejandro Tombolini on 2014 November 15 11:45:13
Hi, see this (http://www.pixinsight.com.ar/en/docs/2/pixinsight-add-script.html) video about adding scripts.
Saludos, Alejandro.
Title: Re: New script: ColorMask
Post by: RickS on 2014 November 15 14:08:03
Hi Rick, it works perfectly well. Thanks for this script.

Thanks for the feedback, Alejandro.  I have a few ideas for improvement when I get some free time.
Title: Re: New script: ColorMask
Post by: cdesselles on 2014 November 15 14:18:39
Got it!  Played around with it just a little.  Works fine.  I can see a lot of potential use for this one.  I hope it goes "Prime Time" real soon.  Thanks!   :D
Title: Re: New script: ColorMask
Post by: RickS on 2014 November 15 15:43:28
Got it!  Played around with it just a little.  Works fine.  I can see a lot of potential use for this one.  I hope it goes "Prime Time" real soon.  Thanks!   :D

Great, thanks!
Title: Re: New script: ColorMask
Post by: IanL on 2014 November 16 08:59:44
Great job.  Just did a quick test and managed to knock back some magenta halos in about 30 seconds.  Before:

(https://lh3.googleusercontent.com/-6kL5_bkv2J0/VFp8v5nN-fI/AAAAAAAAEzc/tsXtohF5AXE/w1167-h875-no/M33_V3_4x.png)

After:

(https://lh3.googleusercontent.com/-33pyYrx1SdU/VGjWyblHxcI/AAAAAAAAEzs/CyEe4VMapDA/w1167-h875-no/M33_V3_1_4x.png)

My only request would be to make it possible to turn the script in to a process icon.  I've noticed some scripts have the ability and others don't, which makes it hard to create repeatable processes that rely on such scripts.  Even without, this ought to be put in the standard release asap!
Title: Re: New script: ColorMask
Post by: cdesselles on 2014 November 16 10:24:47
Yes.  It did a very nice job on the magenta stars.  But it also knocked back any areas of Ha in the galaxy.  But this is a problem of the mask being applied globally to all magenta across the image, which is exactly what is was designed to do. 

The only way around that issue I can think of is to be able to apply more than one mask simultaneously.  For instance, create both a magenta color mask and a star mask and use them on the main image in such a way as to only affect the magenta color of the bright stars while leaving the galaxy alone.  Unfortunately, I don't think this is currently possible in PixInsight.  Something for the future maybe?
Title: Re: New script: ColorMask
Post by: IanL on 2014 November 16 11:29:44
Yes.  It did a very nice job on the magenta stars.  But it also knocked back any areas of Ha in the galaxy.  But this is a problem of the mask being applied globally to all magenta across the image, which is exactly what is was designed to do. 

The only way around that issue I can think of is to be able to apply more than one mask simultaneously.  For instance, create both a magenta color mask and a star mask and use them on the main image in such a way as to only affect the magenta color of the bright stars while leaving the galaxy alone.  Unfortunately, I don't think this is currently possible in PixInsight.  Something for the future maybe?

It was only a quick test and it also picked up a fair amount of the background which I would also want to protect.  The answer is probably something like creating the colour mask, taking an existing star mask (which I have) to just protect the just stars in the colour mask (might need to use dilation or similar to grow the star mask a bit first), then use dilation to grow the unprotected (background/galaxy) parts of the colour mask, and then finally apply the modified colour mask to the image and apply curves.  Other strategies using pixelmath to apply a star mask to a colour mask might also work quite well.

The advantage of using the colour mask seems to be that it is a lot better at picking up the magenta halos that start in the dark areas just outside the stars and bleed some way to the centres. I've tried other methods of growing/blurring normal star masks to do the same job, but they usually end up creating undesirable artefacts inside or outside the stars as it is quite hard to grow/soften them correctly to fit all the different sized stars.
Title: Re: New script: ColorMask
Post by: RickS on 2014 November 16 14:46:06
My only request would be to make it possible to turn the script in to a process icon.  I've noticed some scripts have the ability and others don't, which makes it hard to create repeatable processes that rely on such scripts.  Even without, this ought to be put in the standard release asap!

Good thinking.  I can add the ability to create process icons in the next version.  I have some of the code already in there and I just need to finish off the save/restore of the parameters.

Yes.  It did a very nice job on the magenta stars.  But it also knocked back any areas of Ha in the galaxy.  But this is a problem of the mask being applied globally to all magenta across the image, which is exactly what is was designed to do. 

The only way around that issue I can think of is to be able to apply more than one mask simultaneously.  For instance, create both a magenta color mask and a star mask and use them on the main image in such a way as to only affect the magenta color of the bright stars while leaving the galaxy alone.  Unfortunately, I don't think this is currently possible in PixInsight.  Something for the future maybe?

As Ian mentioned, the way to do this in PI is to combine masks with PixelMath.  His suggestion of using Morphological Dilation to "fatten" the stars in a star mask is a good one.  A HT stretch would probably help too.  Then if you use PixelMath to multiply the masks: fat_star_mask*magenta_mask, you'll get a mask that targets just the magenta stars and their halos.

Cheers,
Rick.
Title: Re: New script: ColorMask
Post by: cdesselles on 2014 November 16 17:15:05
I'm definitely not up to speed with Pixel Math yet.  Could you elaborate on that method of combining masks a little?
Title: Re: New script: ColorMask
Post by: RickS on 2014 November 16 17:48:26
I'm definitely not up to speed with Pixel Math yet.  Could you elaborate on that method of combining masks a little?

Sure... you create the magenta mask using ColorMask and let's assume its name is "magenta_mask".  You create a star mask and fatten the stars by whatever method you prefer.  Let's call this mask "fat_star_mask".  Now, you type "magenta_mask*fat_star_mask" as the RGB/K expression in PixelMath and run the process by clicking on the new instance triangle and dropping it on either mask.  This will create a new mask (or replace the one you dropped the new instance on depending on if PixelMath has "replace target image" set.)

The pixel values of the new mask are calculated by multiplying the pixel values in the fat_star_mask and the star_mask.  Because the result of multiplying by zero is always zero, the new mask will be zero anywhere either of the source masks is zero.  You'll only get nonzero values where there is a star and the colour is also magenta.

Hope that helps...

Cheers,
Rick.
Title: Re: New script: ColorMask
Post by: Juan Conejero on 2014 November 17 03:23:25
Hi Rick,

Very nice and useful script. What are the "canned magic hue parameters"? Magic settings, especially when they are used to mimic the behavior of other applications, isn't something we like too much in PixInsight. In my opinion, the Red, Green, etc. color buttons should set device/application-independent hue ranges by default, such as (just sample values, not intended to be these ones precisely):

Red = {330,0,30}
Green = {90,120,150}
...

and so on. Then you can create an auxiliary dialog to define custom color range presets. User-defined color range presets can be stored as plain text files (for example, CSV files) that your script can load very easily on demand. With this change your script would be a really powerful, general-purpose image processing tool. Let me know if you need help to implement this.
Title: Re: New script: ColorMask
Post by: cdesselles on 2014 November 17 04:18:13
Two great responses Rick and Juan.  Seeing this script come into its full potential is exciting to watch.  A learning process all to itself.   :D

Title: Re: New script: ColorMask
Post by: RickS on 2014 November 17 11:04:07
Hi Rick,

Very nice and useful script. What are the "canned magic hue parameters"? Magic settings, especially when they are used to mimic the behavior of other applications, isn't something we like too much in PixInsight. In my opinion, the Red, Green, etc. color buttons should set device/application-independent hue ranges by default, such as (just sample values, not intended to be these ones precisely):

Red = {330,0,30}
Green = {90,120,150}
...

and so on. Then you can create an auxiliary dialog to define custom color range presets. User-defined color range presets can be stored as plain text files (for example, CSV files) that your script can load very easily on demand. With this change your script would be a really powerful, general-purpose image processing tool. Let me know if you need help to implement this.

Thanks, Juan.  The predefined colour parameters are a hangover from the original attempt to emulate Bob Franke's technique for narrowband colour.  I agree that a mechanism to allow for presets is a much better and more general solution.  I'll have a go at implementing that and let you know if I need any help.

Cheers,
Rick.
Title: Re: New script: ColorMask
Post by: msmythers on 2014 November 17 11:29:23
Rick,

Is it possible to add a selection for a wavelength range? I know the user must define the color space properly but I would think that type of masking would be very helpful.



Mike
Title: Re: New script: ColorMask
Post by: RickS on 2014 November 17 12:04:59
Rick,

Is it possible to add a selection for a wavelength range? I know the user must define the color space properly but I would think that type of masking would be very helpful.



Mike

Mike,

Do you mean something like providing a preview and matching the range of hues it contains?  That seems like an interesting idea.

Cheers,
Rick.
Title: Re: New script: ColorMask
Post by: msmythers on 2014 November 17 13:42:12
Rick,

Exactly. Build bandpass, bandstop filters with masks.


Mike
Title: Re: New script: ColorMask
Post by: RickS on 2014 November 17 13:58:21
Exactly. Build bandpass, bandstop filters with masks.

I put that on the wishlist and give it some thought...
Title: Re: New script: ColorMask
Post by: msmythers on 2014 November 17 15:04:32
Thanks Rick. This might push me into learning the world of PI Scripting.


Mike
Title: Re: New script: ColorMask
Post by: jkmorse on 2015 January 07 12:18:24
RickS,

Got a chance to do some narrowband processing during the holidays with images that had given me fits in the past and I found your ColorMask tool invaluable.  Finally was able to get the Hubble Palette colors where I wanted them.

Thanks for a great script!!  ;D

Best,

Jim
Title: Re: New script: ColorMask
Post by: RickS on 2015 January 07 18:59:21
I'm very glad it was helpful, Jim!  I'm still planning to do a new version based on the feedback I have received.  I just need to stop processing images for a few nights (and spending time with my family) to do it  :D

Cheers,
Rick.
Title: Re: New script: ColorMask
Post by: jkmorse on 2015 January 08 07:32:08
Rick,

I can understand the processing, but the family?  What are you thinking??  >:D

Best,

Jim
Title: Re: New script: ColorMask
Post by: RickS on 2015 January 08 13:10:15
Rick,

I can understand the processing, but the family?  What are you thinking??  >:D

Best,

Jim

Just thought I'd mention it in case my wife walks past the screen  ;)
Title: Re: New script: ColorMask
Post by: g.oikonomou on 2015 March 27 15:43:24
Hi !!!
I would like to learn how can I apply the script colour mask? You must set the parameters in the start, middle and end hue or is by definition for each image
Title: Re: New script: ColorMask
Post by: RickS on 2015 March 27 18:43:06
Hi !!!
I would like to learn how can I apply the script colour mask? You must set the parameters in the start, middle and end hue or is by definition for each image

Yes, you select a hue range each time you run the script or you can click on one of the colour buttons to select a pre-canned range.

I'm still intending to do a major revamp of the script and implement the suggestions from Juan et al.  I just need to find a spare evening or two...

Cheers,
Rick.
Title: Re: New script: ColorMask
Post by: mikalovich on 2015 May 23 16:26:06
Can someone please tell me where I can find the "color mask script" in PI and how do I add it to my favorites. I am still new to PI and learning all it can do. I saw an example someone did with it and want to play around with it myself but can't find it anywhere in PI. I went to scripts/featured scripts but it is not listed in there. I have read thru this thread 3 times, gone to the PI resource page and don't see it anywhere. Any help would be greatly appreciated. Thank you!
Title: Re: New script: ColorMask
Post by: msmythers on 2015 May 23 16:42:19
Very first page of this posting has the script for download. This script is not part of the official release at this time I believe. You have to add the script to PixInsight. If you read the whole posting you will also see link from Alejandro to a video on how to add a script to PixInsight.



Mike
Title: Re: New script: ColorMask
Post by: mikalovich on 2015 May 23 18:45:35
Thank you. I finally found the zip file under the first posting and when I click on it and try to open it, I get a "windows script host" window with a big red X and this is what I get: C:\Users\Mika\AppData\Local\Temp\Temp1_colorMask_v0.2zip\ColorMask.js
Line :   16
Char:   1
Error:   Invalid character
Code:   800A03F6
Source: Microsoft JScript compilattion error

I am not understanding this or how to do it. I have watched Aljandro's vid on how to add scripts 20 times but again not getting it.  His desktop in the vid is in Spanish, which I don't read, there in no information on how to do it, just a quick moving of the mouse to here and there and I have no idea what he is doing in his vid. I'm getting really frustrated with this and about to give up. It looks like an awesome script to play with, that is if I could get it added.  Is there some place else where there are more "understandable" instructions on how to add this?
Title: Re: New script: ColorMask
Post by: Alejandro Tombolini on 2015 May 23 19:21:31
Hi mikalovich, I am not going to have a computer with PI for a week to prepare a better explanation of adding a script.
If I remember well the procedure should be:
Download the script
Save it in a folder
Unzip it
Open PI
Go to script>featured script
Select "add" button
Find the folder where you have unzipped the script
Select it
Select Done
It should says 1 additional script found
Hope it helps
Saludos, Alejandro
Title: Re: New script: ColorMask
Post by: mikalovich on 2015 May 23 20:19:12
OHHHH THANK YOU SO VERY MUCH!!! That helps explain what I was seeing in the vid. I will try that and see if I can get it to work. Thank you so much for taking the time to explain it better to me, I really do appreciate it :-)
Title: Re: New script: ColorMask
Post by: RickS on 2015 May 24 04:10:16
Thanks for the helpful info, Alejandro!

I just uploaded a new version of the script (v0.3).  It adds an option to create a mask whose strength is based on Chrominance which I find very useful.  I still intend to do a very major overhaul of the script to implement all the feedback I have received.  Unfortunately, I'm spending too much time at work and too little on image processing so it may take me a while...

Cheers,
Rick.
Title: Re: New script: ColorMask
Post by: msmythers on 2015 May 24 05:33:13
Rick

Very nice addition to the script. I find myself using the script often.


Thanks


Mike
Title: Re: New script: ColorMask
Post by: RickS on 2015 May 24 14:38:43
Glad to hear it is useful to others, Mike!
Title: Re: New script: ColorMask
Post by: mikalovich on 2015 May 24 14:44:25
Thank you so very much Alejandro for taking the time to explain how to add the colormask script to my PI. I did it today and it WORKED!!!! Now to figure out how it works and play with it. I really do appreciate it. Mucho Gracias!!!

RickS...I have read and seen examples of your script and it looks awesome and something fun to play with. Now that I have it added I am going to play with it and see what I can do. Thank you too. That is what is so wonderful about this forum and PI, is the amount of people willing to help newbies like me out.
Title: Re: New script: ColorMask
Post by: Warhen on 2015 May 30 13:55:59
Rick S, Congrats!! This is very nice and will be included in Inside PixInsight, my book for Springer Press. I'd liken it to the power of Photoshop's (Sshhh...) Color Range selection tool. It enables PI users to target specific color ranges and works very well at defaults. I have a ways to go yet (17 chapters done) but when I get closer to postprocessing  tweaks such as this, I'd like to contact you for more specifics if that would be alright. Again, thank you very much from all of us Rick, and well done!
Title: Re: New script: ColorMask
Post by: RickS on 2015 May 30 18:17:23
Rick S, Congrats!! This is very nice and will be included in Inside PixInsight, my book for Springer Press. I'd liken it to the power of Photoshop's (Sshhh...) Color Range selection tool. It enables PI users to target specific color ranges and works very well at defaults. I have a ways to go yet (17 chapters done) but when I get closer to postprocessing  tweaks such as this, I'd like to contact you for more specifics if that would be alright. Again, thank you very much from all of us Rick, and well done!

I'm glad you find it useful, Warren.  You're welcome to contact me at your convenience and perhaps this will give me the push needed to finish off the v2 version  :)

Cheers,
Rick.
Title: Re: New script: ColorMask
Post by: Warhen on 2015 June 03 10:53:49
Yes, please do it Rick, I'm sure others would back me up. At your convenience of course! Not only is it useful for defining color ranges, but since color is often directly related to chemical composition and structure, the masks can be useful for adjustments other than just color-related ones (i.e. gamma, sharpness, etc.). I'd love to be able to produce multiple masks at one time. It would be important to, and I think a worthwhile addition even in its present form to identify the mask as 'R' or G, etc. Thanks Rick, talk soon.
Title: Re: New script: ColorMask
Post by: Geoff on 2015 September 15 19:58:47
Just downloaded the script yesterday and have been playing around today.  My image is starting to look very nice and no doubt will improve with a bit more practice.  Thanks Rick.
Geoff
Title: Re: New script: ColorMask
Post by: RickS on 2015 September 15 21:50:24
My pleasure, Geoff!
Title: Re: New script: ColorMask
Post by: RickS on 2015 September 18 03:49:56
I'd love to be able to produce multiple masks at one time. It would be important to, and I think a worthwhile addition even in its present form to identify the mask as 'R' or G, etc.

Hi Warren,

I have added a suffix to the mask image name if you press one of the preset buttons (R = red, G= green, B = blue, Y = yellow, C = cyan and M = magenta.)  Hope that helps.  I still have a long list of other improvements.  I'll have to take a night or two off work and image processing and just get them done :)

Cheers,
Rick.
Title: Re: New script: ColorMask
Post by: msmythers on 2015 September 20 06:01:15
Rick

Could you add a color bar like ColorSaturation has? Here is what I had in mind. And just for the record this image was done completely in PixInsight.



Mike
Title: Re: New script: ColorMask
Post by: llpastro on 2015 September 20 07:29:45
To update from version 0.3 to 0.4 do I need to first remove 0.3?  Or can both reside together in PI?

Larry
Title: Re: New script: ColorMask
Post by: Alejandro Tombolini on 2015 September 20 07:37:25
Hi Larry, when you unzip it you will see that it has a different name (previous: ColorMask, new: ColorMask 04, so you can maintain both, or remove the previous one and add the new one.

Note that the version 0.4 when you open the script says 0.3

Saludos, Alejandro.
Title: Re: New script: ColorMask
Post by: msmythers on 2015 September 20 11:25:15
I missed version 0.4 some how.  :o

It would still be nice to have the color bar.

Mike
Title: Re: New script: ColorMask
Post by: RickS on 2015 September 20 14:42:04
Mike,

I have a long list of suggestions for improvements and a colour bar is certainly one of them.  I'll have to set aside a few evenings and just get them all done.  I have a large backlog of images to process so it is hard to find the time!

If I change things too much Warren will curse me  :D

Cheers,
Rick.
Title: Re: New script: ColorMask
Post by: msmythers on 2015 September 20 15:06:22
I understand priorities! Images ;D
Title: Re: New script: ColorMask
Post by: Geoff on 2015 September 20 19:39:19
Mike,

I have a long list of suggestions for improvements and a colour bar is certainly one of them.  I'll have to set aside a few evenings and just get them all done.  I have a large backlog of images to process so it is hard to find the time!

If I change things too much Warren will curse me  :D

Cheers,
Rick.
Hi Rick
Just a minor point. Reduce the number of decimal places showing in the Process Console.
Geoff
Title: Re: New script: ColorMask
Post by: RickS on 2015 September 20 21:05:33
Hi Rick
Just a minor point. Reduce the number of decimal places showing in the Process Console.
Geoff

Will do, thanks Geoff.
Title: Re: New script: ColorMask
Post by: WesChilton on 2015 December 29 09:42:28
Rick, thank you very much for sharing the script it was very helpful in salvaging some pretty awful data I got on the rosette! I definitely went overboard and pushed this data too hard, but its still a much better result than I had previously. I still have MUCH to learn!

http://www.astrobin.com/231900/E/

Title: Re: New script: ColorMask
Post by: RickS on 2015 December 29 16:11:37
Rick, thank you very much for sharing the script it was very helpful in salvaging some pretty awful data I got on the rosette! I definitely went overboard and pushed this data too hard, but its still a much better result than I had previously. I still have MUCH to learn!

http://www.astrobin.com/231900/E/

Colours look pretty good, Wes.
Title: Re: New script: ColorMask
Post by: rdryfoos on 2016 January 16 07:00:51
Rick,

This opens some interesting doors!

How do you add the script to PixInsight?--I get all kinds of errors--I put in in the repository--no go.

Mike
Title: Re: New script: ColorMask
Post by: RickS on 2016 January 16 15:57:17
How do you add the script to PixInsight?--I get all kinds of errors--I put in in the repository--no go.

In case you missed it in the other thread, Rob Pfile was kind enough to point you here: http://pixinsight.com.ar/en/docs/2/pixinsight-add-script.html

Cheers,
Rick.
Title: Re: New script: ColorMask
Post by: patthehorse on 2016 June 04 10:51:52
Just added your script to my PI (ver0.7) It works very well, even if I don't fully understand it. Being able to mask a colour and adjust the others in my NB images using the hue in Curves is brilliant. A big thanks for all your effort.
Pat.
Title: Re: New script: ColorMask
Post by: RickS on 2016 June 04 18:05:35
Just added your script to my PI (ver0.7) It works very well, even if I don't fully understand it. Being able to mask a colour and adjust the others in my NB images using the hue in Curves is brilliant. A big thanks for all your effort.
Pat.

I'm glad you found it helpful, Pat!

Cheers,
Rick.
Title: Re: New script: ColorMask
Post by: patthehorse on 2016 June 07 20:50:10
Very helpful and fun playing with it. Still smiling and transforming old images. Brilliant! :)
Title: Re: New script: ColorMask
Post by: patthehorse on 2016 June 07 21:05:07
The before and after is immense to me. All processing in PI.

(http://astrob.in/248714/B/rawthumb/gallery/get.jpg) (http://astrob.in/248714/B/)
Title: Re: New script: ColorMask
Post by: RickS on 2016 June 12 13:59:24
It's certainly a very bold image now, Pat!
Title: Re: New script: ColorMask
Post by: Jean on 2016 August 31 06:56:16
Hello Rick,

Is your ColorMask script v 0.7 the latest version and if not where can I find it?

Thanks
Jean
Title: Re: New script: ColorMask
Post by: RickS on 2016 August 31 14:18:16
Hi Jean,

v0.7 is still the latest version.  I have a few more things I'd like to implement when I have time.  I'll upload any new versions to this thread.

Cheers,
Rick.
Title: Re: New script: ColorMask
Post by: Jimmy on 2016 September 23 22:51:58
Hi Rick

I am trying to download your script, I see the small clip on the first page but it is not clickable for me. (Nothing happens)
I have tested with Firefox and IE. Are there any other place that I can download it from?

Can you please help me out

Regards
Jimmy
Title: Re: New script: ColorMask
Post by: RickS on 2016 September 23 23:03:04
I am trying to download your script, I see the small clip on the first page but it is not clickable for me. (Nothing happens)
I have tested with Firefox and IE. Are there any other place that I can download it from?

Hi Jimmy,

Did you try to download before you logged in to the forum?  If you're not logged in I don't think you can do downloads.  There's a copy here just in case that doesn't help: https://www.dropbox.com/s/qgol6hddkuxi8rv/ColorMask_0.7.zip?dl=0

Cheers,
Rick.
Title: Re: New script: ColorMask
Post by: Jimmy on 2016 September 25 23:22:26
Hi Ricks

Actually I tried both signed and not, still can't click it.
But I got it now, thanks Ricks

Kind regards
Jimmy
Title: Re: New script: ColorMask
Post by: rockwall astro on 2016 September 28 17:18:21
looking for some help installing color mask.  I have downloaded and unzipped the file.  I took the file and put it in SRC - scripts folder.  I can see the ColorMask_0.7.js in the folder but cannot see it under scripts utilites in Pixinsight.  when I click feature scripts and add I can see the color mask file but it is not highlighted to select.

what am I doing wrong?

thanks
Title: Re: New script: ColorMask
Post by: RickS on 2016 September 28 20:20:43
looking for some help installing color mask.  I have downloaded and unzipped the file.  I took the file and put it in SRC - scripts folder.  I can see the ColorMask_0.7.js in the folder but cannot see it under scripts utilites in Pixinsight.  when I click feature scripts and add I can see the color mask file but it is not highlighted to select.

what am I doing wrong?

Not sure what could be going wrong.  Have you tried putting it in another folder and then using the Add button to navigate there?  I keep my custom scripts in a PI Tools directory in my home directory.

Cheers,
Rick.
Title: Re: New script: ColorMask
Post by: Buzz on 2016 November 22 11:32:38
Rockwell I thought I had the same problem - in Mac OSX - I tried to add - but all the JS files were greyed out. I just double clicked a random file and it re-scanned the script directory and it appeared in the list
Title: Re: New script: ColorMask
Post by: cdavid on 2016 December 23 11:19:09
I'm having the same issue.  On my new MacBook Pro, I cannot add the color mask script to the scripts tab, it shows up grayed out.  I have tried by adding, rebuilding, placing it in a separate folder.  I can open it in the script editor and launch it from there, but cannot get it to show up in my scripts tab.
Title: Re: New script: ColorMask
Post by: STAstro on 2017 January 13 02:04:22
Is there an updated tutorial, I have installed 0.7 and I do not have options for things like "Curvature Mask" etc, and I have noticed, if I click on Magenta for example, and I then click on the "Start Hue" box to enter a value, it automatically selects "Red" again

Simon
Title: Re: New script: ColorMask
Post by: msmythers on 2017 January 13 08:51:49
Simon

It's not that it is automatically selecting red, it is reverting to the button layout as when you first start the script. Open the script and you will see red is highlighted but the hue parameters are zeros. When ever you make a manual change you override the button selection. So when you select magenta and make a hue change it is no longer true magenta. The red button being highlighted is just a default look for the buttons.

As to the Curve selection that has not been around for a while. I think Rick might have explained why it was removed in a post.

Here is all the versions I know about. There might have been some that I might have missed.


Mike 
Title: Re: New script: ColorMask
Post by: RickS on 2017 January 16 03:08:04
Hi Simon,

Mike is correct.  Clicking on one of the colour buttons will set appropriate start and end hue values.  If you change the start or end hue manually it will override the buttons.  The Red button gets highlighted as a default.  Maybe I should add a "manual" button to make it clearer what has happened.

I removed some of the original features like the Curvature mask because they weren't that useful in practice.

Cheers,
Rick.
Title: Re: New script: ColorMask
Post by: RickS on 2017 January 16 03:10:28
I'm having the same issue.  On my new MacBook Pro, I cannot add the color mask script to the scripts tab, it shows up grayed out.  I have tried by adding, rebuilding, placing it in a separate folder.  I can open it in the script editor and launch it from there, but cannot get it to show up in my scripts tab.

Sorry, I haven't been able to reproduce this.  I don't think it is anything specific to the script.
Title: Re: New script: ColorMask
Post by: souls33k3r on 2017 January 21 18:09:03
Cheers for putting in all the hard work Rick. Much appreciated.

Here comes the silly question, how to use it? I'm only a beginner so I do apologise for asking such question.
Title: Re: New script: ColorMask
Post by: pfile on 2017 January 21 20:03:38
first post describes pretty much how to use it...

rob
Title: Re: New script: ColorMask
Post by: RickS on 2017 January 22 01:21:16
Cheers for putting in all the hard work Rick. Much appreciated.

Thanks.

Here comes the silly question, how to use it? I'm only a beginner so I do apologise for asking such question.

Rob's answer is a good one (thanks, Rob!)  The first post is a rough example of how you could use ColorMask on a narrow band Hubble palette image to get the common gold/turquoise colouring that seems popular.  It shows some of the basic things you can do.

The more general answer is that you use the script whenever you want to isolate and process a specific colour or range of colours.  As an example, say you have a faint blue reflection nebula that you want to enhance.  Make a blue mask with ColorMask, apply it to the image, and use standard PI processes to enhance the blue areas of the image - as an example you could use CurvesTranformation to boost the blue channel and perhaps do a small HistogramTransformation boost to brighten the blue areas as well.

ColorMask is just a basic tool.  It relies on you to figure out when and how it is useful.  If you're just a beginner it may take a while for you to figure that out.  When I started out I found the technical side of processing didn't seem that difficult.  The part I found difficult (still do!) was developing a sense of aesthetics and knowing what an image "needed."  You may find that ColorMask makes more sense as your personal sense of aesthetics develops and you start to have stronger ideas about how you want an image to look.  ColorMask is only one of many tools that you can use to get to where you want to go.

Cheers,
Rick.
Title: Re: New script: ColorMask
Post by: akulapanam on 2017 January 22 23:26:00
Hopefully this gets added to the standard distro soon!
Title: Re: New script: ColorMask
Post by: souls33k3r on 2017 January 23 07:11:38

Rob's answer is a good one (thanks, Rob!)  The first post is a rough example of how you could use ColorMask on a narrow band Hubble palette image to get the common gold/turquoise colouring that seems popular.  It shows some of the basic things you can do.

The more general answer is that you use the script whenever you want to isolate and process a specific colour or range of colours.  As an example, say you have a faint blue reflection nebula that you want to enhance.  Make a blue mask with ColorMask, apply it to the image, and use standard PI processes to enhance the blue areas of the image - as an example you could use CurvesTranformation to boost the blue channel and perhaps do a small HistogramTransformation boost to brighten the blue areas as well.

ColorMask is just a basic tool.  It relies on you to figure out when and how it is useful.  If you're just a beginner it may take a while for you to figure that out.  When I started out I found the technical side of processing didn't seem that difficult.  The part I found difficult (still do!) was developing a sense of aesthetics and knowing what an image "needed."  You may find that ColorMask makes more sense as your personal sense of aesthetics develops and you start to have stronger ideas about how you want an image to look.  ColorMask is only one of many tools that you can use to get to where you want to go.

Cheers,
Rick.

Cheers for this Rick, i think i know exactly what i was doing wrong. I thought that by choosing the parameters and applying them will apply to the actual image that i'm working on but in fact it creates a mask based on the colours available in the image? am i right in saying that? and then apply the mask and like you said make changes to that colour using the CurvesTranformation as an example. Am i on the right track here?

I am getting quite familiar with most of the inbuilt PI features
Title: Re: New script: ColorMask
Post by: msmythers on 2017 January 23 09:15:24
Here is an example I had forgotten about using Rick's ColorMask. I used the color mask with the ColorSaturation and MorphologicalTransformation tools to reduce blue halos around stars in my image.

http://pixinsight.com/forum/index.php?topic=9250.msg59525#msg59525 (http://pixinsight.com/forum/index.php?topic=9250.msg59525#msg59525)


Mike
Title: Re: New script: ColorMask
Post by: RickS on 2017 January 23 09:28:11
Cheers for this Rick, i think i know exactly what i was doing wrong. I thought that by choosing the parameters and applying them will apply to the actual image that i'm working on but in fact it creates a mask based on the colours available in the image? am i right in saying that? and then apply the mask and like you said make changes to that colour using the CurvesTranformation as an example. Am i on the right track here?

I am getting quite familiar with most of the inbuilt PI features

Yes, that's the idea.  Good to hear you're figuring out your way around.  It takes a little while but it is worth the effort!
Title: Re: New script: ColorMask
Post by: souls33k3r on 2017 January 24 09:37:37
Yes, that's the idea.  Good to hear you're figuring out your way around.  It takes a little while but it is worth the effort!

Top man, cheers mate :)
Title: Re: New script: ColorMask
Post by: astrovienna on 2017 February 19 12:43:47
Thanks for writing the script, Rick.  I'd like to use it to shift green to blue in an HOO blend, but I can't get it to select much green.  It selects blue without trouble, and cyan selects the same as blue, but green only gets a few star halos.  Since the green and blue layers are identical, I would have thought it would generate identical color masks.  I've tested this on images posted by other people and I get the same result.  Any idea what I'm doing wrong?

Kevin
Title: Re: New script: ColorMask
Post by: RickS on 2017 February 19 21:36:16
Thanks for writing the script, Rick.  I'd like to use it to shift green to blue in an HOO blend, but I can't get it to select much green.  It selects blue without trouble, and cyan selects the same as blue, but green only gets a few star halos.  Since the green and blue layers are identical, I would have thought it would generate identical color masks.  I've tested this on images posted by other people and I get the same result.  Any idea what I'm doing wrong?

Hi Kevin,

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.

Hope that helps...

Cheers,
Rick.
Title: Re: New script: ColorMask
Post by: dlamothe on 2017 February 21 13:55:34
Hi guys,

What is the step by step to install the Color Mask script in PixInsight. I am running PixInsight on MAC.

Thank you

Daniel Lamothe

Title: Re: New script: ColorMask
Post by: dlamothe on 2017 February 21 13:58:27
Hello.

What is the step by step process to install Color Mask Script?  I am running PixInsight on Mac Platform.

Thank you

Daniel Lamothe
Title: Re: New script: ColorMask
Post by: RickS on 2017 February 21 15:18:36
What is the step by step process to install Color Mask Script?  I am running PixInsight on Mac Platform.

Hi Daniel,

Here's a short tutorial which describes how to add a script: http://pixinsight.com.ar/en/docs/2/pixinsight-add-script.html

Cheers,
Rick.
Title: Re: New script: ColorMask
Post by: cardiofuse on 2017 March 02 08:47:54
Fantastic script.  How does one know precisely what the hue angle values are (if you want to tweak them to your image colors)?
Title: Re: New script: ColorMask
Post by: msmythers on 2017 March 02 13:46:31
Rick

You change the readout data cursor.


Mike
Title: Re: New script: ColorMask
Post by: calan on 2017 April 16 23:13:30
Thanks so much for this script.  ;)

I notice that with strength set to 1 (or even .75), I'm picking up "color" in unexpected areas, and at a value of zero I get nothing. What is a good value to set the strength to normally, and what was the intended use for it...since you can define the target with the hue sliders?

Any updates on when it will become a process?

Thanks again!
Title: Re: New script: ColorMask
Post by: RickS on 2017 April 17 01:58:04
Thanks so much for this script.  ;)

I notice that with strength set to 1 (or even .75), I'm picking up "color" in unexpected areas, and at a value of zero I get nothing. What is a good value to set the strength to normally, and what was the intended use for it...since you can define the target with the hue sliders?

Any updates on when it will become a process?

Thanks again!

Glad to hear it is useful to others.  I use it a lot in my processing.

The Mask Strength parameter defines how strongly the mask matches hues as they move away from the midpoint of the range.  With a strength of 0.5 the mask strength decreases linearly between the midpoint and endpoints of the hue range (from 1 at the midpoint to 0 at the ends.)  For values > 0.5 you get a mtf() curve that is stronger and for values < 0.5 it is weaker.  mtf() is defined in the documentation for HistogramTranformation and the x parameter is 1-mask_strength.

I mostly use the mask strength at the default of 1 and set the start and end hue points carefully, but occasionally I set a wider range of hues and set the mask strength to have less influence away from the midpoint.  It depends on what you are trying to achieve - a strong effect over a range or a diminishing effect at the edges.

If you are picking up "color" in areas you don't expect it then I suspect you need to adjust the range of hues.  Use ReadoutOptions with CIE L*c*h* mode to probe with the cursor in the areas of interest and look at the h* values.

My C++ skills are pretty rusty so I don't see me having the time to convert ColorMask to a process any time soon though it would be nice to have dynamic previews.  Perhaps when I retire :)

Cheers,
Rick.
Title: Re: New script: ColorMask
Post by: jlmanatee on 2017 June 07 15:24:39
I must admit to being a neophyte to understanding masks, so please bear with me.  In v0.7 of this excellent script, the mask references have changed to chrominance, lightness,  and linear.  In the older versions, they were known as binary, lightness, linear and curved.  I'm trying to follow the original instructions.  How do the older mask names correspond to the newer mask names? 
  Also, I understand what is being accomplished by the magenta mask to decrease magenta star halos and the  green mask to decrease green.  In both cases, I assumed the mask is inverted to protect everything but those colors.  But I'm confused by the cyan mask.  Is it applied to protect anything cyan (thus not inverted)?  Or is employed to provide for pushing up red and blue in areas that are already cyan (thus inverted).  I assumed the mask was not inverted.  But my results have not been as I thought they might be in obtaining Hubble pallet colors I was going for (on IC 1396).  Any advice is much appreciated.  The attached files are before/after.  The before is an HT stretch of a simple SHO combination

 
Title: Re: New script: ColorMask
Post by: pfile on 2017 June 07 16:10:50
you want to expose the cyan areas so you can modify the color from cyan to more of a blue.

i usually use chrominance mode. i think rick would have to give the definitive word on how to map the old names to the new; i think chrominance is probably "curved" and binary was dropped but don't quote me on that.

rob
Title: Re: New script: ColorMask
Post by: msmythers on 2017 June 07 19:51:33
I made a screen shoot of the various versions and posted it a couple of pages back in the thread. There is a little explanation of some of the features within the script tools themselves. I remember somewhere Rick explained everything but I that might have been updated as the versions changed. Anyway here is that screen shoot. Maybe this will help. I don't know if Rick ever released a v0.1 , v0.4 or v0.5.

For myself I found the curved mask added complexity that I rarely if ever really needed. For me it was also trial and error. The problem which isn't a negative was that you had to setup a start, mid and ending hue. This set where the curve center point was going to be. This allowed for a possible great slope to one side of the curve if needed. Then you had to decide which direction the curve needed to be. Great control but maybe a bit much for most cases. The chrominace mask I believe is curvature mask with fixed centered midpoint. These are just my observations.

The binary mask was one I never really needed also.

For targeting a very specific color range the chrominance mask is what I use probably 95 percent of the time. The other 5 percent I use the RangeSelection tool.

For what it's worth, this tool is one of those I would sorely miss if I did not have PixInsight. I use it with standard daytime images for fine color corrections.


Mike
Title: Re: New script: ColorMask
Post by: RickS on 2017 June 07 19:58:58
The colour range you select is what the mask exposes.  A magenta mask exposes the magenta areas and a cyan mask exposes the cyan areas.  If you want to adjust the cyan areas just create a cyan mask, apply it and go for it.  If you want to adjust the areas that aren't cyan then use Invert Mask.

The original mask types were Binary (any pixel in the colour range gets a mask value of 1), Lightness (any pixel in the colour range gets a mask value that is the CIE L* value of the pixel), Linear (any pixel in the colour range gets a mask value that starts at 0 near the edges of the colour range and ramps up linearly to 1 at the midpoint of the range), and Curved (same endpoints as linear but the ramp is slow or fast depending on the curvature.)

After using ColorMask a fair bit I found that what I mostly wanted was a mask that was stronger when the colours were stronger, so that's where the Chrominance mask came from.  The mask exposes areas of high chrominance more than areas of low chrominance.

In the latest version of ColorMask I removed the Binary mask since it didn't seem to be very useful.  Lightness is unchanged and Linear is still there.  A Curved mask can be created by adjusting the Mask Strength of a Linear mask, but Mask Strength is now a parameter that can be used with all mask types.

In practice I use a Chrominance mask 95% of the time.

Cheers,
Rick.
Title: Re: New script: ColorMask
Post by: RickS on 2017 June 07 20:06:14
I made a screen shoot of the various versions and posted it a couple of pages back in the thread. There is a little explanation of some of the features within the script tools themselves. I remember somewhere Rick explained everything but I that might have been updated as the versions changed. Anyway here is that screen shoot. Maybe this will help.

Thanks, Mike.

I don't know if Rick ever released a v0.1 , v0.4 or v0.5.

There were some intermediate versions that I don't think I released.  0.7 is the one that incorporated most of the feedback I received (at least all the easy stuff!)

For myself I found the curved mask added complexity that I rarely if ever really needed. For me it was also trial and error. The problem which isn't a negative was that you had to setup a start, mid and ending hue. This set where the curve center point was going to be. This allowed for a possible great slope to one side of the curve if needed. Then you had to decide which direction the curve needed to be. Great control but maybe a bit much for most cases. The chrominace mask I believe is curvature mask with fixed centered midpoint. These are just my observations.

Agree it was too complicated and the extra stuff didn't add much value.

For targeting a very specific color range the chrominance mask is what I use probably 95 percent of the time. The other 5 percent I use the RangeSelection tool.

For what it's worth, this tool is one of those I would sorely miss if I did not have PixInsight. I use it with standard daytime images for fine color corrections.

Interesting that I independently came up with 95% and glad to hear it is useful for daytime images as well!

Cheers,
Rick.
Title: Re: New script: ColorMask
Post by: msmythers on 2017 June 07 20:08:24
Hi Rick

How does the mask strength curve the mask? The original had curvature slider with the center position between concave and convext. Is this a different curve now?


Mike

 
Title: Re: New script: ColorMask
Post by: RickS on 2017 June 07 20:23:29
How does the mask strength curve the mask? The original had curvature slider with the center position between concave and convext. Is this a different curve now?

Mike,

It's the same mtf() function being used but I reversed the sense.  A strength of less than 0.5 is concave and greater than 0.5 is convex.  I thought it was easier to understand that a strong mask selects the edges of the colour range more strongly and a weak mask less strongly.

In retrospect, I should have had a beta program for the script and released it when it was a bit more polished  ;)

Cheers,
Rick.
Title: Re: New script: ColorMask
Post by: msmythers on 2017 June 07 20:59:14
Seems very shiny to me.

I always looked at scripts and modules that we have to add ourselves as beta. They graduate from beta status once they're part of the standard distribution.



Mike
Title: Re: New script: ColorMask
Post by: troypiggo on 2017 June 16 20:19:42
I wonder what's going to come first - PI 1.8.5 or ColorMask 1.0? :P
Title: Re: New script: ColorMask
Post by: RickS on 2017 June 16 20:52:29
I wonder what's going to come first - PI 1.8.5 or ColorMask 1.0? :P

The only things left on my to-do list are the difficult items and I'm about to go on a business trip, so I'd be putting my money on PI 1.8.5  :P
Title: Re: New script: ColorMask
Post by: btuttle on 2017 June 22 09:57:52
I'm a brand new newbie to PI and the forum. I would like to download the New script: ColorMask, but for the life of me, can't figure out where the link is, although it is in front of my face.
Thanks for help
Bruce
Title: Re: New script: ColorMask
Post by: msmythers on 2017 June 22 10:03:37
Bruce

First page of this posting. At the bottom of the first section by Rick there is a paperclip. That is the script.



Mike
Title: Re: New script: ColorMask
Post by: Andres.Pozo on 2017 August 06 10:01:11
Hi Rick,

I am trying to use the ColorMask script, but I get strange results. It seems that the masks don't select the desired colors.

I have generated a pair of synthetic images trying to understand the behavior of the script. The test images are generated using ChannelCombination from monochrome images. The first has the values L=0.5, c=0.5, h=[0..1] and the second L=0.5, c=1.0, h=[0..1]. I have generated masks for the six predefined colors and the masks don't seem to fit the colors. It seems that the ranges of the predefined colors are not right.

I don't know if I am doing something wrong or if there is an error in the scripts.

Andrés.
Title: Re: New script: ColorMask
Post by: RickS 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.
Title: Re: New script: ColorMask
Post by: RickS 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.