Sign in
Log inSign up
Removing stars from deep sky images using GANs

Removing stars from deep sky images using GANs

Free and open source tool for star removal in astronomy images.

Ashish Patil's photo
Ashish Patil
·Oct 23, 2021·

3 min read

Image of Andromeda galaxy on left, the same image after star removal (on right) using my tool !

📥 Download the tool here : https://github.com/code2k13/starreduction

When you look at the images of galaxy and nebulae on the internet, you won't realize that stars are generally absent or very dim. In reality that is not the case. There are tons of stars surrounding these objects. Special tools are used to remove these stars and make the images look pretty. Starnet is one of the popular tools for star removal available online. Being familiar with AI/ML I decided to write my own neural network based tool for star removal. You can download the tool here : github.com/code2k13/starreduction

Here are some more samples generated by my tool: Original and starless image of area around WR 102 Original and starless image of area around WR 102

Original and starless image of Blue Horsehead Nebula Original and starless image of Blue Horsehead Nebula

These days I have found a new hobby for myself "post processing astronomical" images. I have always been fond of astronomy. In fact I even own a small telescope, but I don’t have access to open areas and time to do anything with an actual telescope. So I subscribed to https://telescope.live from where I can choose which object I want to observe and get high quality raw data from telescopes. Post processing refers to the activity of turning 'almost black' looking raw telescope images to colorful images like the above ones.

There are many tools available for post processing, my favourites are GIMP and G'MIC (GREYC's Magic for Image Computing), because they are open source and have lots of great features.

One big challenge which I faced when writing my star removal tool was the lack of training data. I simply used two freely available images, one for background and one for star mask, to create hundreds of fake training images. I am still working on improving my training data generation logic and training process, but the results look promising even with what I have today. Here is an image showing couple of training data images:

Samples from training data Samples from training data

The 'Expected' images were generated by superimposing random crops from a starless image and star mask (with transparency) on each other. The training code is available as a python notebook on Kaggle : https://www.kaggle.com/finalepoch/star-removal-from-astronomical-images-with-pix2pix

I have also been able to dockerize my tool so that you should be able to run it on any platform supporting docker. You can simply run the tool using the below command

docker run   -v $PWD:/usr/src/app/starreduction/data  \
-it code2k13/starreduction \
/bin/bash -c "./removestars.py ./data/example.jpg  ./data/example_starless.jpg"

$PWD refers to your current working directory. In the above example it is assumed that the file example.jpg resides in your current working directory. This directory is mounted as a volume with the path /usr/src/app/starreduction/data inside the docker container. The output image example_starless.jpg will also be written to same directory.

If you are into astrophotograpy, do checkout my tool and share your feedback. The source code for application, training script and weights of models are available for free on github.