Image Denoising

In this notebook you will see an example of an image denoising, using an autoencoder, inspired into Francois Chollet tutorial.

What is an image denoising?

An image denoising is an algorithm that learns what is noise (in some noisy image) and how to remove it, based into the true signal / original (image without noisy). The results are images very close to the true ones, for example, as in the image below:

Example of image denoising

Image denoising using autoencoders

Autoencoders are based on Neural Networks (NNs) and are known as Convolutional Neural Networks (CNNs or convnets). A convnet is a Deep Learning algorithm which takes an input image, assign importance (learnable weight, biases and retains spatial relationships in the data into each one of theirs layers) to various aspects/parts in the image and is able to differentiate/reconstruct the same.

The general idea behind this kind of code can be visualized here:

General autoencoder

Then, the autoencoder compreehends an encoder and a decoder. The encoder does the encoding process, i.e., transforms the image into a compressed representation at the same time that starts the noisy reduction. Then, the compressed representation goes to decoder that performs the decoder process, restoring the image to its true and recognizable shape. At the end of the process, we remove almost all noise in the image.

Libraries

Data

Here, we are using as our data the MNIST dataset.

This is a dataset of 60 000 images of size 28 $\times$ 28 grayscale images of hand written of 10 digits (0, 1, 2, 3, 4, 5, 6, 7, 8, 9), along with a test set of 10 000 images.

Importing data

This dataset is mostly used in classification problems, that is why they have the images and a second information, the labels of each image.

But, as we are going to map digits images to clean them, we are not going to use the labels.

In this way, our process is going to take the noised images and clear the same based into the true images as targets.

Pre-processing data

Because here we are doing a simple example, we will use a fraction of the complete dataset: just 1000 images, dividing if on 700 as train and 300 images as test.

We are going to normalize the images between 0 and 1 and to reshape them.

Here, we need to noisy the images, then, we apply a Gaussian noisy matrix and clip the images between 0 and 1.

Visualizing some noise images images.

Building the Autoencoder

Defining the input images for the autoencoder.

Encoder

Decoder

Autoencoder

Visualizing the autoencoder.

Compilation

Fitting

Tracking the history of the training stage

Visualizing the history of the training.

Prediction

Evaluation

Visual results

Here, we can compare our visual results looking side by side the noisy, targets and denoised images.