Remove Image Defects With a Synthetic Flat Frame

Something happened. You may have forgotten to take flats or there’s a defect that doesn’t calibrate out. You may still be able to recover your image with a synthetic flat frame. This Pixinsight workflow will get you to a usable image and will work for gradients, dust motes, and other issues.

This workflow is based on a tutorial posted by Scotty Bishop in the Telescope Live Facebook community (original post). I’ve tweaked the star removal process somewhat to make it easier.

The RBG image after stacking. The meridian flip mirrored the defect.

I’m not sure what happened here. It’s possible a spider left a calling card in front of my lens. This wasn’t a power line and it’s not in the flat frames. To add insult to injury, the meridian flip mirrored the dark line on the other side of the image. There’s also a pretty bad gradient in the background.

Let’s get to work. First, load your image in Pixinsight, leave it linear (unstretched), and crop as needed. I’ve named this image “RGB.”

Step 1: Clone the Image

Clone the image by dragging the tab into the workspace. Rename the cloned image to “Flat.” This will become our flat frame.

Clone the image to create a flat frame.

Step 2: Remove Stars From the Flat Frame

LinearStarNet

Now we need to remove the stars from our flat frame. StarNet++ is the obvious choice, but it has a drawback - it doesn’t work on linear images. Fortunately, Pixinsight now comes with the LinearStarNet script by Edoardo Luca Radice. Launch LinearStarNet from the Script -> Utilities menu. Make sure the target view is set to your flat frame, uncheck “Show clipping map,” and set StarNet Stride to 64 for a smother-looking result. Now execute on the flat frame.

The LinearStarNet Script is Located in the Script -> Utilities Menu.

StarXTerminator

The commercial StarXTerminator plugin by Russell Croman is an alternative tool to remove stars and, in my opinion, does a much better job than StarNet++. Bonus, it’s much faster. (StarXTerminator can be purchased here). Once you have it installed, launch StarXTerminator from the Process menu under ObjectRecognition. Check the Linear option and execute on the flat frame.

StarXTerminator dialog.

Whether you use LinearStarNet or StarXTerminator, you’ll end up with an image that has most, if not all the stars removed:

Stars Removed from Flat Frame.

Step 3: Clean Up With CloneStamp

Now that the stars are removed, we still need to take care of the galaxies and other objects in our synthetic flat frame. Launch CloneStamp from Process -> Painting. Enlarge the radius (I used 40) and start painting out the galaxies. Once you finish, press the check icon to execute your changes. You should end up with a background image that looks like this:

CloneStamp Applied to Flat.

Step 4: Blur the Flat

Launch MultiscaleMedianTransform from Process -> MultiscaleProcessing. Set the layers at 6, then turn off all layers except for R (Residual).

MultiscaleMedianTransform Settings.

Apply this to your flat frame to blur it:

Blurred Flat Frame.

Step 5: PixelMath!

It’s time to apply the synthetic flat frame to the image! Launch PixelMath (Process -> PixelMath) and enter the formula:

RGB * mean(Flat) / Flat

where RGB is the name of our original image and Flat is the name of the synthetic flat frame.

PixelMath

Apply PixelMath to the original image. Like magic, the defects and gradients disappear:

Flat-Corrected Image.

Conclusion

Just because an image isn’t perfect doesn’t mean is ruined. A synthetic flat can save it from the trash bin!