In this video we will discuss how to use MATLAB to denoise the signal using the discrete wavelet transform
Let us load a signal and plot it in MATLAB
There are two signals here
The first is the original signal and the second one is the original signal with some noise added to it
our goal here is to denoise the noisy signal using the discrete wavelet transform
Soon you will see how easy it is to do this in MATLAB
Here is an overview of the steps involved in wavelet denoising
Your first step is to obtain the approximation and the detail coefficients
Do this by performing a multi-level wavelet decomposition
Recall that the discrete wavelet transform splits up a signal into a low-pass sub band
also called as approximation level
and the high-pass sub band also called as the detail level
You can decompose the approximation sub band at multiple levels or scales for a fine scale analysis
The second step is to analyze the details and identify a suitable thresholding technique
I will cover this later in the video
The third step is to threshold the detail coefficients and reconstruct the signal
Let us first perform a multi-level wavelet decomposition using the function wave deck
We will use the same six wavelet and decompose the noisy signal down to five levels
The function outputs the fifth level approximation coefficients along with the detail coefficients from levels one through five
The first level detail coefficients captures the high frequencies of the signal
Most of the high frequency content is comprised of the noise present in the signal
However, part of the high frequency component is made up of abrupt changes in the signal
There are times when these abrupt changes carry meaning and you would want to retain this information while removing the noise
Let us take a closer look at the detail sub band
To extract the coefficients you can use the Det Co F function and plot the coefficients for each level
I am using a helper function to extract and plot the coefficients
What you are seeing here is the original signal along with the details plotted for levels 1 through 5
Notice that the activity in the details reduces drastically as the scale or the level increases
So we will focus on the level 1 details and ignore the rest for now
Our aim here is to retain the sharp changes while getting rid of the noise
One way to do this is by scaling the detail coefficients by a threshold
There are four main techniques available in MATLAB to help you compute the threshold
The universal threshold is the simplest to compute and is computed using this formula
Manually computing the threshold for the other three denoising techniques is not as straightforward
Instead you can use MATLAB for this so that you can focus on using the threshold value without worrying about how it is computed
There are two thresholding operations soft thresholding and hard thresholding
In both cases the coefficients with magnitude less than the threshold are set to zero
The difference between these two thresholding operations lies in how they deal with coefficients that are greater in magnitude than the threshold
In the case of soft thresholding, the coefficients greater in magnitude than the threshold are shrunk towards zero by subtracting the threshold value from the coefficient value
Whereas in hard thresholding the coefficients greater in magnitude than the threshold are left unchanged
Coming back to our example
Let us denoise our noisy signal using sure shrink with the soft thresholding technique
The entire process of thresholding the coefficients and reconstructing the signal from the new coefficients can be done using a single function as shown here
The first parameter F is the noisy signal
The second parameter specifies the thresholding technique
In this case, sure shrink "s" denotes soft thresholding and the parameter "sln" indicates threshold rescaling using a single estimate of noise based on the first level coefficients
"level" indicates the wavelet decomposition level
and the last parameter specifies the wavelet which is Simsek in this case
The function "wden" performs a multi level decomposition of the input signal
computes and applies the threshold to the detail coefficients
reconstruct the signal with the new detail coefficients and provides it as an output
Let us now use the plot command to compare the noisy signal with the denoised signal which was the output of the previous step
Clearly the denoised version has less noise
You can also compare the performance of the denoising technique we discussed earlier with other denoising techniques such as savitsky Goulet filtering or the moving average technique
You can see that the wavelet denoising method outperforms other denoising techniques
In this way the benefits of using wavelet techniques to denoise a signal are clear