{'fraction_non_alphanumeric': 0.020562560620756547, 'fraction_numerical': 0.01037827352085354, 'mean_word_length': 4.622137404580153, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Image Denoising Using Convolutional Autoencoder

With the inexorable digitalisation of the modern world, every subset in the field of technology goes through major advancements constantly. One such subset is digital images which are ever so popular. Images can not always be as visually pleasing or clear as you would want them to be and are often distorted or obscured with noise. A number of techniques to enhance images have come up as the years passed, all with their own respective pros and cons. In this paper, we look at one such particular technique which accomplishes this task with the help of a neural network model commonly known as an autoencoder. We construct different architectures for the model and compare results in order to decide the one best suited for the task. The characteristics and working of the model are discussed briefly knowing which can help set a path for future research.


I. INTRODUCTION
Image denoising refers to the process of removing distortions otherwise known as "noise" from a given input image in order to produce a clearer image. But what is noise exactly and where does it originate from?
Noise refers to random variations in brightness/intensity or color information present on a digital image. Noise has several modes of occurring which include during acquisition, noise caused by analog-to-digital converter errors, bit errors in transmission,statistical quantum fluctuations, faults in the image sensor and many more [1]. This noise can render many images useless unless techniques exist to eradicate it.
Image denoising therefore becomes an important challenge which has still not been perfected. More and more new methods come up everyday, each having particular use cases, but none of these techniques have ever been able to perfectly restore an image to its original form.
This paper implements the use of a fully connected, dense autoencoder as well as a convolutional autoencoder for the task. A convolutional autoencoder is a deep learning model built with neural network layers, convolutional layers in specific. Both models are compared with each other to determine the more accurate one. The following sections will speak in detail about autoencoders and their workings along with their implementation for this problem statement.

II. THE AUTOENCODER
The term autoencoder first came about in the 1980s to address the problem of "backpropagation without a teacher", which is countered by using the input data as the expected output. Along with hebbian learning rules [2], autoencoders became rudimentary in the field of unsupervised learning.
The autoencoder [3] is a type of neural network which learns to encrypt/code a given unlabelled input into a dimensional space which may or may not be of the same order as the input, it generally maps the input into a lower dimensional space(latent space). This encoding is then used to reconstruct the original image.
Throughout this process, the model learns the mapping of different input images to specific points in the latent space by training and during this training, the autoencoder is taught to ignore discrepancies or noise present in the input.
Autoencoders are used in a variety of tasks such as image classification, generative modeling, facial detection and so on.

A. Basic Architecture
An autoencoder generally consists of 2 parts[4]: 1) An encoder which maps input into the latent space and 2) A decoder which decodes points on the latent space to reconstruct the input.
Instead of just blatantly duplicating the input, an autoencoder is made to deconstruct and reconstruct the input and hence learns to recognise only important parts of the data. A general schema of an autoencoder can be seen in Fig. 1. Let the encoder and decoder of the autoencoder be defined as transitions Φ and ψ respectively Given an input X For the case of there being only a single hidden layer, the encoder takes an input x ∈ R 2 = X and creates a mapping to h is referred to as the coded latent expression of the input, σ is a rectified linear unit activation function, W is a weight matrix and b is the bias vector. The weight matrix and bias vector of a neural network is generally randomly assigned and morph their values via backpropagation during training. Finally, the decoder decodes h to a reconstructed version of x denoted as x , having the same dimensions as x where σ a rectified linear unit activation function and W and b are the weight matrix and bias for the decoder and aren't usually related to W and b of the encoder.
The loss of the autoencoder is calculated by how much the input and output differ in terms of individual pixel values. An example is the mean squared error loss.
where x is averaged over each training batch.

B. Denoising Autoencoder
A denoising autoencoder(DAE) [5] is quite similar in architecture to a standard autoencoder except that it introduces noise to the input images present in the dataset during training and validation. The noise introduced is random in nature.
Given a random noise generating function T , an input x is given to it which it then converts to a noisy version of x denoted as T (x). This T (x) is then used as input to the neural network.
T :X −→ T (X) An effective DAE must manage to process any noisy image and reconstruct the original image while eradicating the noise.
A smart way of going about creating the model will involve the use of Convolutional layers in the neural network instead of Dense layers. This is done because convolutional layers are known to learn really good representations and features of images via their working while full connected layers fail to do so.

III. MODEL ARCHITECTURE
The architecture designed for both, a fully connected autoencoder as well as a convolutional autoencoder are described below.

A. fully connected autoencoder
This model takes in an input of dimension 28*28*1 (grayscale image) and flattens it to an array of dimension 784 which now becomes the input. This input is passed onto a Dense layer consisting of 64 neurons which needless to say, fully connected to the input. The output of this Dense layer is passed onto another Dense layer consisting of 784 neurons. The number 784 is chosen so as to reshape the output back into a 28*28 pixel image. The output of the second Dense layer is reshaped back into a 28*28*1 dimensional array, the same shape as the input, which marks the final output of the encoder.
The architecture can be visualised easier using Fig. 2.

B. Convolutional Autoencoder
A convolutional autoencoder employs the same principle as that of a conventional autoencoder with the only difference being that convolutional layers are used instead of Dense layers. The architecture is inspired from [6].
An input of dimension 28*28*1 is passed through 2 sets of 2D convolutional layers(32 filters, 3*3 weight matrix, relu activation) and encode the input into a latent space of dimension 7*7*32. The latent coordinates are then used as input for Conv2D Transpose layers(32 filters, 3*3 weight matrix, relu activation) in order to upscale the image back into its original shape.
The details of each layer are present in Table 1 Detailed architecture of this network is depicted in Fig. 3. Table 2 shows the total number of trainable parameters for each model.

A. Dataset
The dataset used for training and testing is the MNIST handwritten digits(grayscale images) dataset [7] consisting of 60,000 examples in the training set and 10,000 examples in the test set each of shape 28*28*1 pixels. A few examples from the training set are shown in Fig. 4. Since the dataset we require for the task at hand requires noisy images, we define a functions to add random gaussian noise to the dataset elements. The new dataset now consists of noisy images and can be visualised in Fig. 4. The neural networks are modelled according to the ones shown in Fig. 2 and Fig. 3 using tensorflow and keras libraries. The training is done on Google Colab's Tesla K80 Graphics card having 2496 CUDA cores with 12GB of GDDR5 VRAM.

C. training details
Each model is trained for a total of 20 epochs and the training loss and validation loss is displayed at the end of each epoch Both models utilise the Adam optimizer and the loss function used is "binary crossentropy".
Training time for each model amounted to about 100 seconds each due to the input images being of small size and hence not requiring too much processing power.

D. discussions
The final values for validation loss for each model is depicted in Table 3.
Although the loss of both models don't seem to be that drastically different in value, the predictions of each model tell us a different story. The predictions made by the fully connected autoencoder is shown in Fig. 6 along with the corresponding inputs. As it's evident from Fig. 6, the fully connected autoencoder which consists of only Dense layers does not do a good job at denoising, instead it seems to make the input even more noisier. This is due to the fact that Dense layers don't do a very good job at learning the features and representations for image related tasks.
Whereas, the predictions along with input for the convolutional autoencoder and shown in Fig. 7. The difference in the predictions made by the two models in terms of output is vast, it's blatant from Fig. 7 of how much better the convolutional autoencoder is at denoising. Almost all the noise from the input is removed resulting in an almost noise-free, clear image. This is because of the convolutional layer's incisive ability to store meaningful representations of input during training and hence alienating any noise when mapping the image to a latent space.

V. CONCLUSION
The task of image denoising 28*28 pixel, greyscale images using autoencoders is hence visualised. Distinctions between two different autoencoder architectures, namely a Dense autoencoder and a convolutional autoencoder are drawn with which we can ascertain that the use the convolutional layers is very important in the case of image denoising using deep learning. More complex denoising involving RGB images can hence be done by creating a deeper model and more apt latent space dimension. Future research may include creating a model to denoise images of a higher calibre and those which contain multiple channels.