Galaxy Image Denoising
Contents
Note
Click here to download the full example code or to run this example in your browser via Binder
Galaxy Image Denoising#
Code author: Samuel Farrens <samuel.farrens@cea.fr>
In this tutorial we will remove the noise from an example galaxy image using the PySAP-Astro plug-in.
Import dependencies#
Import functions from PySAP and ModOpt.
import numpy as np
import matplotlib.pyplot as plt
from pysap.data import get_sample_data
from astro.denoising.denoise import denoise
from modopt.signal.noise import add_noise
Clean image#
First, we load the image of galaxy NGC2997 from the PySAP sample data sets.
galaxy = get_sample_data('astro-ngc2997')
Then we can show the clean galaxy image that we will attempt to recover.
Out:
/volatile/Chaithya/actions-runner/_work/pysap/pysap/examples/pysap-astro/plot_galaxy_denoising.py:36: UserWarning: FigureCanvasAgg is non-interactive, and thus cannot be shown
plt.show()
Generate a noisy observation#
To simulate an observation of NGC2997 we add random Gaussian noise with
standard deviation 100
using the
ModOpt add_noise
function.
obs_data = add_noise(galaxy.data, sigma=100)
Now we can show the noisy galaxy image.
Out:
/volatile/Chaithya/actions-runner/_work/pysap/pysap/examples/pysap-astro/plot_galaxy_denoising.py:52: UserWarning: FigureCanvasAgg is non-interactive, and thus cannot be shown
plt.show()
Note
\(\sigma=100\) is quite excesive, but we can more easily visualise the noise added to the image in this example.
Denoise#
We will use the denoise
function
from PySAP-Astro to denoise the noisy image. We set the number of wavelet
scales to 4
.
denoised_data = denoise(obs_data, n_scales=4)
We can show the denoised galaxy image.
Out:
/volatile/Chaithya/actions-runner/_work/pysap/pysap/examples/pysap-astro/plot_galaxy_denoising.py:74: UserWarning: FigureCanvasAgg is non-interactive, and thus cannot be shown
plt.show()
Residual#
Next, we calculate the residual of our denoised image to get a measure of how well the denoising process performed.
Finally, we can show the residual.
Out:
/volatile/Chaithya/actions-runner/_work/pysap/pysap/examples/pysap-astro/plot_galaxy_denoising.py:89: UserWarning: FigureCanvasAgg is non-interactive, and thus cannot be shown
plt.show()
Tip
Typically for a denoising problem we are aiming for a residual without any structure, i.e. just noise.
Total running time of the script: ( 0 minutes 4.162 seconds)