TUTORIAL: How to eliminate star halos in PixInsight

Bright stars next to dim deep-sky objects are one of the more challenging issues to deal with when processing an image, especially when there are reflection halos off a filter.  This is especially true with narrowband imaging, where we are stretching the image aggressively.  This can make what would otherwise be an inconspicuous reflection look like a giant circle drawn over your image.  The most common example is Alnitak when imaging the Horsehead Nebula, but this issue crops up in other objects.  In this case, with Gamma Cassiopeia when trying to image IC59 and IC63.

Here is one quick way to address this with PixInsight’s PixelMath process.  There are several other tutorials online that describe a similar approach, but they seemed needlessly complex, so I’ve written up what I think is a faster way to do it.

Here is our offending image, an H-alpha image of IC59/IC63 with Gamma Cass lighting up the whole center area.

Gamma Cass 1

Here are the steps we’ll follow:

  1. Get the left, right, top, and bottom values of the halo.
  2. Clone the image and tell PixelMath to generate a mask from the clone.
  3. Blur the mask.
  4. Apply the mask to our original image, and use HistogramTransformation to remove the halo.

STEP ONE:

We just need to get four numbers:  the X values for the left and right edges of the halo and the Y values for the top and bottom.  In PixInsight, you can move the cursor to the appropriate spot and read these values from the bottom panel.  In the image below, you can see that the left edge has an X value of about 1928.

Gamma Cass 2

STEP TWO:

First, clone your image by dragging the image identifier tab on the left side to anywhere on the workspace.  The only reason we do this is to create an image that matches the size of the original exactly. Now we’re going to use PixelMath to create a mask for the halo with these four numbers in one step. Here’s the formula to enter on the RGB/K line:

iif(sqrt((x()-(R+L)/2)^2 + (y()-(B+T)/2)^2) < (R-L)/2, 1, 0)

This is just an application of the formula for a circle to an IIF statement that turns the pixel white if it’s within this circle and black if it’s not. From the quick measurements I took above, I can enter the left, right, top, and bottom values on the Symbols line.  Your values will differ depending on your image, but you just need to assign them each to their appropriate letter symbol:

L=1928, R=3342, T=912, B=2334

It should look like this:

Gamma Cass PM

Ensure “Replace target image” is checked (not “Create new image”), and then apply this process to your cloned image, and you should get a mask that looks something like this.

Gamma Cass mask1

STEP THREE:

As with any mask, it needs to have softer edges, to open up the Convolution process and apply a little blur.  In this case, I’ll try a Std Dev of 20 pixels, since it’s such a large halo. For smaller halos, you’d use a smaller Std Dev setting.

Gamma Cass mask2

Much better.

STEP FOUR:

Now apply the mask to the original image by dragging the image identifier tab on the left up to the original image’s gray bar on the left (or you can use the menu options if that’s what you’re used to).  Leave the mask enabled, but unclick  the “Show Mask” button so you can see what your doing.  Open the HistogramTransformation process and click the check mark so it’s tracking the currently active view.  Now, open the Real-Time Preview by clicking the little circle at the bottom of the process.  Drag the black point slider to the right until the halo disappears.  Apply to the image once you are happy with the setting.  That’s it!

Gamma Cass HT

In this case, here’s the final image:

Gamma Cass Result

If the mask was off center or needs to be adjusted, you can undo and go back to tweak your values, especially the amount of blur that needs to be applied.  If you have inner halos due to other reflections, you can just repeat the process using their coordinates.

The ‘puckered’ halo around Gamma Cass above is an artifact of the microlenses on the sensor… alas there is not a simple solution for these other than layering in data from a shorted exposure or directly editing the area in another image processing tool.


19 thoughts on “TUTORIAL: How to eliminate star halos in PixInsight

  1. what if star is too bright, the same one you are masking here for halo. How can I dim it a bit so that it isn’t over powering the “ghost”

  2. This is a difficult processing challenge, and there are several options. In general, you make a smaller mask for the star (blurred/feathered of course), then run HistogramTransformation and slide the midpoint slider to the right. You can also use Curves. It’s going to depend on the image and how big/bright the core star is. Another option is to blend in data from a shorter exposure, which is more complicated because you have to match the background brightness.

  3. Hola el pixel mat me dice que no encuentra la imagen clonada,image not found,podrias decirme cual es mi fallo.
    Gracias ,saludos.

  4. Thanks for this. Improved my M45 image no end. The halos are still there but not such an eyesore. Most had artifacts left due to my not getting exact measurements, not enough, or, too much blurring etc. By making a clone of my de-haloed image and giving that a couple of subtle convolution runs. It could be blended back into the original 50/50 which hid those mistakes by me.
    Thanks again gatsbyiv.

  5. May want to consider the GAME script to make the mask described above and follow this technique to remediate the halos – I’m going to try this technique on M42.

  6. I have a weird issue. When I plug in the four coordinates, it places the mask in the wrong location. I’ve tried multiple times and I know the coordinates are right but yet it doesn’t work. Any thoughts? Thx

  7. When I use Histogram Transformation to tweak the image in Real Time Preview, as soon as I move the black point slider, it starts to just go black, not gradually fade . . . it removes everything, including stars. I am using an OSC, and have tried doing this on unstretched and stretched images, both full color, and extracting R, B and G and working on B only, then adding back together in PixelMath. Any tips? Jon

    1. Hard to diagnose this without more info, but that definitely shouldn’t happen with a stretched image. If the histogram is anything other than a narrow spike against the left edge, I don’t see how this could be happening.

      1. What information would help? I’ve tried both the auto-stretch, then processing a bit and doing an STF/arcsinh stretch with the same result. I don’t think I can post screenshots here.

  8. It sounds like you perhaps have the screen stretch enabled, giving you the illusion that the image is stretched when the underlying data are actually still linear. Easy way to tell: does your histogram look like a narrow spike or the wide hump shown in the example images? Did you de-Bayer the image? Was a narrowband filter used? How experienced are you with PixInsight?

  9. Just saw this reply. I’ll need to go through the steps again to see if screen stretch was enabled as I’ve been working on some other issues in the past few weeks. The image was debayered. I have a version using narrowband, and a version without narrowband filter. Which does this work better with? After 2 years, I am still a beginner with PI compared to others, but I understand some of the basic basics.

  10. Ok, I am using an osc. 183mc pro. I am working with a starless image (StarXterminator). I stretched by dragging the triangle from STF to the bottom border of HT, then reset STF, then dragged HT triangle to the now black image. This got the image back as it should be, but now permanently stretched. Got the mask just fine. When I open HT again and reset it, making sure that the check is on, then open real-time preview, when I drag the black point slider the right, the halo fades, but it fades and leaves a black hole where it was. My guess is that there is no data back there to be uncovered, so removing the halo just uncovers blackness?

  11. Thank you so much for this! I have some halos that are ring shaped rather than circle shaped. I updated your formula to draw a ring based on the coordinates of the inner and outer circles:

    iif(sqrt((x()-(R+L)/2)^2 + (y()-(B+T)/2)^2) < (R-L)/2 && sqrt((x()-(sR+sL)/2)^2 + (y()-(sB+sT)/2)^2) > (sR-sL)/2, 1, 0)

    L=3008, R=3063, T=1815, B=1868, sL=3018, sR=3056, sT=1822, sB=1858

    In my formula, sL, sR, sT, and sB define the left, right, top, and bottom of the small, inner circle that forms the ring. L, R, T, and B define the large, outer circle, just like your original formula. Figured I should share this to pay it forward and help anybody else in a similar position. Clear skies!

Leave a comment