# Denosing signal using soft and hard thresholding

Let us consider following code:

fs=100;
N=1000;
t=0:1/fs:N-1;
y=10*sin(2*pi*100*t)+0.5*randn(size(t));
plot(y)
plot(t,y)


I have applied following threshold methods:

thr = 0.4;
% Perform hard thresholding.
ythard = wthresh(y,'h',thr);


But I can't see any difference, also soft threshold method,codes are below:

ythard = wthresh(y,'h',thr);
plot(ythard)
ytsoft = wthresh(y,'s',thr);
plot(ytsoft)


So what is wrong? I have also done thresholding time domain without calculation of the wavelet coefficients. Are they equal to each other? I mean if I will generate wavelet coefficients and threshold this coefficients, will they give me same result?

• Wait, are trying to denoise your random signal by performing hard/soft thresholding of its amplitude? – jojek Jul 3 '14 at 7:05
• no like wavelet is doing,according it's coefficients – dato datuashvili Jul 3 '14 at 7:17

Where exactly is wavelet calculation in your code? Code you posted is some kind of strange thresholding of amplitude. For example what you are doing for 'hard' case, is zeroing of all samples lower than 0.4 (zoom in your plots):

This operation is pointless (unless you really want to do so) and has nothing to do with thresholding of wavelet coefficients and they are not equal. Extract the wavelet coefficients, threshold them and reconstruct a signal.

If you have the wavelet toolbox in Matlab you can immediately try: [XD,CXD,LXD] = wden(X,TPTR,SORH,SCAL,N,'wname') returns a de-noised version XD of input signal X obtained by thresholding the wavelet coefficients.

Conceptual explanantion: think of decomposing the signal 'y = x + e' in frequency domain only. In order to attenuate 'e', you must attenuate the coefficients in the frequency spectrum that correspond to 'e' while preserving the coefficients taht correspond to 'x'. When you reconstruct the signal, the contribution of 'e' is reduced.

In real world signals, there is always some overlap between coefficients of x and e in the frequency domain. Therefore is not possible to eliminate 'e' without also losing 'x'. i.e. further reduction of noise 'e' comes hand in hand with loss of information 'x'. The strategy here is to use soft-thresholding in the zone where coefficients of 'x' and 'e' overlap so as to achieve the best tradeoff between noise reduction and information preservation.

Wavelets improves on frequency domain analysis by using a joint time-frequency (or scale-space) decomposition of the signal. But the core concept of denoising using thresholding remains the same: transform signal into domain where signal and noise a best seperated and then find optimal threshold value that achieve best reconstruction (measured in terms of SNR for example).

• it does not work.when you will be here please let us discuss it – dato datuashvili Feb 17 '15 at 4:56