PixInsight Star Removal

Removing the stars from your image can be done for artistic purposes or to separate the nebulosity from the star field so it can be processes differently.  Removing the stars is highly dependent on a good star mask.  There’s a couple tricks to getting an accurate star mask.  The first is using MultiscaleMedianTransform to kill the larger structure sizes.  If your image is in color already, I normally extract the lightness data from it (see Figure 1) to use as a support image for creating the star mask.  I typically rename this image star_mask_support.

Figure 1: Extracting lightness data

Next, I bring up MultiscaleMedianTransform and make sure it’s reset to the default settings.  Then I disable the residual layer (see Figure 2) and and set the Target to Lightness (CIE L*).  You may have to change the layers (while keeping the residual layer disabled) depending on your star sizes.  For the data I’m working with, 4 layers worked quite well.  There will typically be a little nebulosity or galaxy structure left after running this.  I use the clone stamp tool to remove the the non-stellar stuff before creating a star mask.

Figure 2: MultiscaleMedianTransform used to remove larger structures

The second trick is to make several star masks to catch the different star sizes (see Figure 3).  This part takes a lot of fiddling.  I don’t touch much in the Mask Preprocessing section except the Midtones.  For the Mask Generation section I typically leave all options off and vary the Smoothness based on the star sizes I’m trying to re-create (if the start to look square, I up the value some).  The other parameters just take experimentation.

Figure 3: Three passes of StarMask to capture different star sizes

Now that you have several different star masks we need to combine them.  I like to use PixelMath to do this.  Some people use addition but I think that throws things off when you have the same star represented in multiple scale levels, so instead I use the max function (see Figure 4).  This way the brightest elements of all three star masks will be combined into on mask.  I typically apply this to the image called star_mask and then close the others.

Figure 4: Combining star masks with the max function in PixelMath

Now that we have an accurate star mask we can start removing stars.  Apply your star mask to your image (leave it non-inverted) and then bring up the MorphologicalTransformation tool (see Figure 5).  We are going to use the erosion mode which will shrink the stars, pinching in the surrounding data as the star reduces in size.  Apply MT to your image and you’ll see the stars get smaller and fainter.  Once the stars are almost non existent I switch back to MMT to smooth out the result a little (see Figure 6).  Basically invert the layers you had disabled when creating the star_support image, so if you were using 4 layers before with the residual disabled switch that so the first four layers are disabled and the residual is enabled (if your image is in color remember to switch the target to RGB/K mode).  Figure 7 shows a sequence of how the stars were reduced in this image where the first 6 tiles were using MT and the last 2 using MMT.

Figure 5: MorphologicalTransformation in Erosion mode

Figure 6: MultiscaleMedianTransform being used to remove stars

Figure 7: Sequence of star reduction

Figure 8: Side by side comparison after star removal

If you are really having trouble getting an accurate star mask, then there’s one other trick you can try.  It requires that you plate solve your image and use that as a reference for the CatalogStarGenerator script.  I only use this as a last resort because the catalogs frequently do not include all the star in the field.  But if you simply can’t separate the stars from the nebulosity in your image this technique might help.

I hope this is useful!


4 thoughts on “PixInsight Star Removal”

  1. Hi, great tutorial!
    Quick question….after the erosion using MT. Do you leave the mask in place or remove it for the inverted MMT step?
    Thanks again

  2. Hi Carlos,

    Yes, the star mask is still in place when doing the MMT step to remove stars.


  3. What if you wanna add the stars back in later? Is there a way to remove the stars and then replace them. Or more specifically. …remove narrowband stars and replace them with rgb stars?

  4. Hi DJ,

    You can definitely do this. If you want to add back in the existing stars, maybe with stretch different to what you’ve done to your starless image, you can take the image prior to star removal and subtract the image with star removal (you will need an offset to make sure there is no clipping of the shadows). This will create an image of just the stars. Then they can be added back together (taking care to remove the offset you added before) after you’ve done whatever you want to the starless and star only images.

    If you have RGB star data you can add that in one of two ways (that I know of):
    1) Make a mask of the star only image I described above and use that to limit adding just the stars from the RGB data in to the starless image
    2) Make a starless version of your RGB data and then go through the same process to create a star only version of it. Then just like adding in the original stars you can stretch them separately before adding them together.


Leave a Reply

Your email address will not be published. Required fields are marked *