Using Starnet++ at linear stage.


PixInsight Ambassador
Aug 16, 2012
Dear all, I've published a microtutorial on YouTube on using Starnet++ at linear stage.

The tutorial, unfortunately, is only in italian, but i suppose you can easily follow it with the automatic subtitle translation.

here the link

Clear skies


Jan 9, 2019
Fantastic, and thanks!  I just created a set of icons to run the process and it works like a charm.  Translation on the video was a bit rough to deal with but the pictures are all you really need to follow along.



Well-known member
Feb 19, 2013
Removing Stars from Linear, Unstretched Images
v 1.0                                                                                                                    Alex Woronow, Jan. 18, ?20

Here is my version of the work-around for removing stars from linear (unstretched) images. It is based on a video to do the same thing by Edoardo Luca Radice: . Unfortunately, the video is in Italian, but you can play it with ?translated? subtitles. Basically, the steps are
Stretch the image using either the HistogramTransform (HT) (perhaps with parameters determined through the ScreenTransferFunction( STF))
Remove the stars from the stretched image
Transform the starless image back to its original linear form
Subtract that reversed-transform from the original image to obtain the unstretched stars
Celebrate, or whatever

Now, the video does not include the fact that the black-point is adjusted by STF, or can be adjusted manually in the HT. So I went back to the HT documentation, and started from the transfer equation given there. It also does not reveal the way to handle the black point, but otherwise is what I needed.

Now HT has three parameters: Shadows (s), Hightlights (h) , and Midtones (m). We need not adjust h, so there is no additional use for it. The value of s is the black-point. Values < s become zero and CANNOT BE RECOVERED from the stretched image. Tread lightly and keep this value fairly low. (Often it is <.005 or so, unless your images have a pedestal.) Usually, for our faint astro-imges, the midtones have a value of around m= .001. (It is actually an rightward offset from s.) Don?t worry about setting these values too well, whatever values we use we will undo them later anyway.

We can manipulate our linear image directly in HT using the preview function and moving the 2 left-most sliders, or by entering values for s and m. Alternatively, we can start with STF. Let?s do that.
Open your linear image in the workspace
If you have already applied a screen stretch to your linear image, REMOVE IT
Open STF and click the yellow & black circle on the left column of tools...this does a temporary screen stretch
Open HT
Back in the STF, at the left bottom is a blue triangle. Grab it and drop it on the bottom icon bar of the HT instance
Remove the STF from the image
Adjust the shadows and midtones values if you like, it should not matter in the end.
Again, remove the STF from the image and apply the HT...Your Image Is now stretched.
Remove the stars using StarTools (inside PI, if you installed it) or use StarTools++ from a command line, in which case you will have to export the stretched image, operate on that exported version, then bringing the starless version back into PI.)

We pause for a moment and look at my PixelMath (PM) icon for removing the stretch on the starless image. (The icon is attached to this article.)

We need two values from HT to enter into the PM icon: s and m, or the value from the Shadows and Midtones boxes in the lower left of the HT window. So, copy and paste over the text now in the icon. You can also change the destination, but DO NOT CHECK THE RESCALE RESULTS BOX!

image attached

We are back with a starless linear image exactly comparable to our star-filled linear image. Therefore we can subtract the former from the latter (PixelMath again) and obtain a linear image containing only the stars. If this image of the stars also contains significant other stuff, something is not right. Try again or contact me through this site. However, remember the value of s could cause some fraction of the darker pixels to be set to zero and become unrecoverable--that?s usually somewhere near the round-off error anyway and not really visible. But if you set s too high, artifacts could become visible.

Hope this works for you!




Well-known member
Jan 13, 2015
Wexford, PA, USA
Alex's function will exactly invert the stretch, provided only the midpoint is transformed. Eduardo's method does not exactly invert the stretch.

Edit: As Juan points out, I am incorrect here. Eduardo's method is exactly the same and much simpler.
Last edited:


Well-known member
Jul 28, 2020
I'm late to the party but this was very helpful today in trying to blend in some Ha, removing the stars first. Well, it didn't work well, but that was for a different reason, bad target to do that with. Thank you for doing this.

Luca Amerio

Aug 26, 2017
Hi everybody,
I'm working on a method to extend Edoardo's method, but allowing to set a black-point (-ish) to your image.
Now... a normal HT is composed by two steps:
  1. Map the input range [0,1] to the output range [x_low, x_high]. This can be done with the function
  2. Apply the MidtonesTransferFunction (MTF) to the mapped values. I.e.:
As Alex was saying, the problem with this procedure is the f(x) is not invertible due to the "hard" min-max operation. This is what makes a normal HT irreversible.

Edoardo's solution was therefore to skip this step, and perform only the midtones stretch.
The problem I (and others, judging the comments below Edoardo's youtube video) are having, is that if your background is not dark enough, stretching only the midtones causes a non-negligible stretch to the background too, turning the whole image white-ish.

A solution I'm working to is to "smooth" the min-max clipping operation, using a modified softplus function.

This function is fully invertible, even for x<x_low (where x_low is the shadow clipping value).

At the moment the problem I'm having is that tuning the shadow clipping value and the midtones value using this modified function can be tricky. These values can't be directly copied from the STF as the softplus makes some adjustments required. At the same time, without a live-preview and/or a live histogram preview, tuning these requires a lot of iterations.

Is there someone that would be interested in helping me bringing this approach forward?

PS: at the moment I'm not modifying the highlights clipping point. For this reason I do not need a second "smoothing" at the upper kink. However the softplus equation can be modified to turn it into a "pseudo" sigmoid with a second horizontal asymptote at y=1. Only, the math will become slightly trickier.
  • Like
Reactions: astroedo


PixInsight Ambassador
Aug 16, 2012
Hi @Luca Amerio this is very intersting.
If you are interested I've improved the method of my youtube video using an algorithm similar to the AutoSTF function (based on a given number of sigma in the "noise" of the image to get the black clipping point).

This improved version has a drawback: it is not fully reversible because it causes a smal amount of black clipping.
Anyway it seems to work fine.

By the way I put all together in a script: you can see the thread here.

We can continue discussing your solution on the script thread if you want.