New script: ScreenStars

Mike1485

Well-known member
Bill Blanshan and I have released a new script designed to help add and remove stars from images. The script features a preview window so you can see what you are doing! The basic approach is the commonly used screening and unscreening methods, however, we have incorporated an additional option for non-linear data which is to incorporate a "reverse stretch" so that removal and addition is done a 'pseudo-linear" image. This really helps preserve star colour, especially when the starless image for recombination is in a very different colour palette to the image from which the stars have been derived. Bill has created a video explaining the use of the script on his YouTube channel: AnotherAstroChannel. You can obtain the script by adding the following url to your repository list: https://www.cosmicphotons.com/pi-scripts/screenstars/.

Clear skies, Mike
(Visit my website for more PixInsight scripts)
 
I just watched the video of Bill on YT, this is impressive and awesome what you guys accomplished.

Cheers
Tom
 
Awesome work. Well done.👏👏
For me, the cherry on the cake would be screening linear stars onto a non-linear starless image, using a custom GHS stretch on the stars, with preview. Bet it cant be done (see what I did there!).;)
Impressive work.
Cheers
Bill
 
Hi Mike, thank you very much (again) to you and Bill for your awesome work!!
Mike, I found a problem when I try to install the script, I get this error message:
"https://www.cosmicphotons.com/pi-scripts/screenstars/: Network error: schannel: next InitializeSecurityContext failed: SEC_E_ILLEGAL_MESSAGE (0x80090326) - This error usually occurs when a fatal SSL/TLS alert is received (e.g. handshake failed). More detail may be available in the Windows System event log."
I tried both with and without antivirus and got the same message. Any idea please?
Thanks
Jordi
 
Hi Jordi - sorry you are having problems - everything is working within the repository so far as I can tell. What version of Windows are you running and have you installed all available updates for it?
 
If you are having problems with the repository, as a work around you can download the release package from my GitHub repository here and then install via FeatureScripts - just remember to delete the ScreenStars.xsgn file if you are running PixInsight 1.8.9 or earlier - keep the .xsgn file for 1.8.9-1.
 
I have watched the video and I like the idea a lot. One question, you have to generate a starless image first. How do to stars created by this process compare to the stars only image created by StarNet/StarXterminator? I don’t have the chance to check it out yet so curious how the stars would differ.
 
I have watched the video and I like the idea a lot. One question, you have to generate a starless image first. How do to stars created by this process compare to the stars only image created by StarNet/StarXterminator? I don’t have the chance to check it out yet so curious how the stars would differ.
At a high level, the big difference is that ScreenStars offers the "reverse stretch" method which can be better at preserving star colours, especially when the stars are added back onto an image in a different colour palette - e.g. RGB stars onto a NB starless image.

However, there are some more subtle differences which some may wish to understand - if you don't like maths or are just interested in the headlines, I recommend you stop reading at this point!

StarNet generates a star mask by simple subtraction, ie star_mask = original - starless.

StarXTerminator has two options, if unscreen stars isn't checked the stars image is created by subtraction in exactly the same way as StarNet; if unscreen stars is checked they are removed using the formula (original - starless)/(1.005 - starless).

The 1.005 in the SXT formula is a "fudge factor" designed to give some protection when SXT is used on images with clipped nebulosity.

In designing the screen stars script we wanted:
Objective 1: to ensure that if you create a stars only image and then recombine with the same starless image then you will get back to where you started (and broadly this is the case, subject to a caveat I will mention later); and
Objective 2: to offer the new "reverse stretch" option that neither SN nor SXT offer.

To achieve the first of these objectives using the SXT formula the recombination would have to use the formula: 1.005*stars+starless*(1-stars). When screening back onto an image other than the starless image you used to create the stars in the first place (as you usually will do) this could lead to clipping which we consider to be undesirable. In ScreenStars, therefore, we remove stars using the true inverse of the conventional screen blending formula, i.e. we remove using the formula: (original - starless)/(1 - starless).

So ScreenStars "stars only" images can be screened back using the conventional screening formula: stars + starless - stars*starless, or in PixelMath you can use combine(stars, starless, op_screen()).

If using linear data and numbers are small the 1.005 fudge factor can distort calculations, hence rc-astro recommends not checking the unscreen option in SXT when using linear data. However, in ScreenStars we do not use this 1.005 fudge factor and so the same issues do not occur. Furthermore when the pixel values in the linear starless image are very small, the denominator of (1 - starless) is very close to 1 and so there is very little difference between unscreening and simple subtraction.

For ScreenStars, therefore we use the unscreening formula for both linear and non-linear data. And, in keeping with Objective 1, adding stars back is always done by the conventional screening formula whether linear or not. This avoids potential top end clipping when adding stars to a brighter image than the stars were removed from.

So, I said there was a caveat to Objective 1 and that is that the unscreening formula: (original - starless)/(1- starless) can yield a negative result if the pixel value in the original image is smaller than the pixel value in the starless image. This can happen surprisingly frequently and not just in areas of bright nebulosity. In this case the "stars image" pixel value is truncated to zero so screen blending wouldn't quite get you back where you stared. If this were super important to you the work around would be to form a modified starless image using PixelMath as follows: min(original, starless). However, this is unlikely to be an issue in practice.

Formula Reference

I know that some people get confused with the mathematical equations for screening and unscreening so, as a final point, here are some formulae as a helpful reference:

Screen blending formulae
The following four formulae are effectively mathematically identical:

1 - (1 - starless)*(1 - stars)
starless + stars - starless* stars

In PixelMath:
~((~starless)*(~stars))
combine(starless, stars, op_screen())

Unscreening formulae
The following four formulae are effectively mathematically identical:

1 - (1 - original)/(1 - starless)
(original - starless)/(1 - starless)

In PixelMath:
~((~original)/(~starless))
rescale(original, starless, 1)

note the unscreening formulae involve a division by (1 - starless) which could be zero so this may need to be caught.

That is almost certainly far more detail than you wanted but I thought it may help to have chapter and verse to refer to.
 
@Mike1485 I love your scripts. I have PI installed on a Mac and on a Win 11 machine. On the Mac, all the scripts are visible under Scripts, Utilities. On the Win 11 machine, of your scripts, I can only see ColorMask. The install log, however, lists all of the installs including Star Reduction, etc. Any clue what is going on and if there is an easy way to remediate this?
 
@Mike1485 I love your scripts. I have PI installed on a Mac and on a Win 11 machine. On the Mac, all the scripts are visible under Scripts, Utilities. On the Win 11 machine, of your scripts, I can only see ColorMask. The install log, however, lists all of the installs including Star Reduction, etc. Any clue what is going on and if there is an easy way to remediate this?
Sorry you are having problems. Can I suggest you check out this video by Paulyman Astro - hopefully it will help you get up and running but if you are still having problems post back here.
CS, Mike
 
Hey Mike. I went to your website to download the scripts, but I got a 404 error that the scripts were not on the server. I tried both my Windows and Mac. Any suggestions? Cheers, Mike
 
Hey Mike. I went to your website to download the scripts, but I got a 404 error that the scripts were not on the server. I tried both my Windows and Mac. Any suggestions? Cheers, Mike
You need to add the repository address to your repository list in PixInsight (Resources>Updates>Manage Repositories). Then check for updates (Resources>Check for Updates). This will let you download the scripts - you will then need to restart PixInsight to install them.
 
Thank you for the script, in general terms, would you recommended extracting stars from (1) a linear image>stretch stars only >screen blend to processed starless or (2) extract the stars from an already stretched image with the reverse stretch method?
 
Hello Mike,
I used ScreenStars until recently and it worked fine. Now, when I apply the script, PI crashes and hangs like in the first screenshot. The only way to exit PI is to close the script and I get the second screen shot error. I tried with both linear and non-linear images. I don't feel like I've changed anything in PI.
John
 

Attachments

  • ScreenStar.jpg
    ScreenStar.jpg
    375.5 KB · Views: 106
  • ScreenStar1.jpg
    ScreenStar1.jpg
    244.5 KB · Views: 103
Hello Mike,
I used ScreenStars until recently and it worked fine. Now, when I apply the script, PI crashes and hangs like in the first screenshot. The only way to exit PI is to close the script and I get the second screen shot error. I tried with both linear and non-linear images. I don't feel like I've changed anything in PI.
John
Hi John, you need to ensure the id you enter for the new image is a valid image id. It looks like you have entered "Star Mask" - blanks are not permitted in an image id. Hopefully that will resolve your issue. In the next release I will add logic to catch this!
CS, Mike
 
Small feature request… Either an option to blank the name of the newly generated window between uses or have separate names for when doing the removal and replacement processes so it doesn’t reuse the same name by default. Even better would be auto appending _stars or _replaced (or similar) to the appropriate starred/starless file.

Another nice feature would be a button that will do the processing and close the window. Small thing but after doing previews I usually am happy and one button to process/close would be nice.

Bonus; sometimes the stars include non stars based on what the starless rendering looks like. Maybe a warning can be raised if the stars look like they have non points?
 
Back
Top