You are on page 1of 15

Lecture 4 - Denoising Using Wavelet Thresholding

Abstract : We have seen in lecture 2 that denoising using linear filters is not efficient for functions with discontinuities. This is due to the linear nature of this process, which forbid to estimate efficiently discontinuities. We have also seen in the first lecture that wavelet approximation using thresholding allows an adaptive representation of signal discontintuities. We will thus use wavelet thresholding to perform a non-linear denoising of 1D signals and 2D images.

Denoising of 1D signals.

Load a signal and add some noise. n = 1024; name = 'piece-regular'; % try also with 'gaussiannoise' f = load_signal(name, n); sigma = 0.06 * (max(f)-min(f)); % variance of the noise fn = f + sigma*randn(n,1); % noisy signal

Non-linear denoising by keeping coefficient above a threshold T (it's up to you to choose T). % non-linear thresholding T = ?*sigma; % set the threshold in function of sigma fwT = fw; fwT = fw .* (abs(fw)>T); fwav = perform_wavelet_transform(fwT,Jmin,-1); % inverse transform % you can try to select an optimal threshold by computing the erro ...

Denoising results with wavelet thresholding for various threshold levels T. The bottom row shows the evolution of the error and allows to find an optimal threshold.

Linear denoising using oracle Wiener filtering (see previous course). ff = fft(f); ffn = fft(fn); pf = abs(ff).^2; % spectral power % fourier transform of the wiener filter hwf = pf./(pf+ n*sigma^2); % filter in the spatial domain (just for display) hw = fftshift( ifft(hwf) ); % perform the filtering over the fourier fwien = real( ifft(ffn .* hwf) );

Display of the results. % compute the error psnr_wav = psnr(f,fwav); psnr_wien = psnr(f,fwien); clf; subplot(2,2,1); plot(f); axis tight; title('Original'); subplot(2,2,2); plot(fn); axis tight; title('Noisy'); subplot(2,2,3); plot(fwien); axis tight; title(['Wiener psnr=' num2str(psnr_wien,3)]); subplot(2,2,4); plot(fwav); axis tight; title(['Wavelet psnr=' num2str(psnr_wav,3)]);

Comparison between the linear (wiener) and non-linear denoising for a signal with discontinuities (left) and for a filtered noise. The linear denoising is optimal on average for realisations of stationary gaussian process. The wavelet denoising is minimax optimal for pointwise singularities.

Translation invariant thresholding. Conversly to the fourier transform is not invariant under translation. In order to have an invariant transform, you have to perform a redundant decomposition (ie. the result of the decomposition has more entry than what the original signal had). Using such a representation, one can still perform thresholding (since such a decomposition also come with some appropriate inverse transform, although the transform is not bijective), but you have to setup a

threshold a little bit larger (although using the same threshold as in the orthogonal case still give good results). options.ti = 1; % invariant transform fwti = perform_wavelet_transform(f,Jmin,1,options); fwtiT = fwti; fwtiT = fwti .* (abs(fwti)>T); % inverse transform fwavti = perform_wavelet_transform(fwtiT,Jmin,1,options); clf; subplot(2,1,1); plot(fwav); axis tight; title(Wavelet denoising'); subplot(2,1,2); plot(fwavti); axis tight; title('Invariant denoising');

Original translation-invariant wavelet coefficients (left), noisy coefficients (middle), denoised wavelet coefficients (right).

Comparison between denoising using an orthogonal wavelet transform (upper row), and denoising using a redundant translation invariant decomposition (lower row). Invariant denoising gives better results since it removes punctual artifact due to accidental large noise coefficients.

Images denoising

Loading an image and adding some noise. n = 256; name = 'lena'; I = load_image(name); % reduce size to speed up I = I(end/2-n/2+1:end/2+n/2,end/2-n/2+1:end/2+n/2);

I = rescale(I,15,240); % add noise sigma = 0.12 * (max(I(:))-min(I(:))); In = I + sigma*randn(n);

Orthogonal 2D wavelet transform and thresholding. % 2D wavelet transform Iw = perform_wavelet_transform(In,Jmin,+1); % compute the transform up to scale Jmin % thresholding T = ?*sigma; IwT = Iw; IwT = Iw .* (abs(Iw)>T); % inverse transform Iwav = perform_wavelet_transform(IwT,Jmin,-1);

Plotting the thresholded transform. clf; subplot(1,2,1); plot_wavelet(Iw, Jmin); subplot(1,2,2); plot_wavelet(IwT, Jmin); colormap gray(256);

Nnoisy wavelet coefficients (left) and

remaining coefficients after thresholding (right). Only large coefficient, that are present along the edges of the image, are kepts. The set of small coefficients removed correspond mostly to noise. The wavelet transform is able to separate well the signal content from the noise, which as no regularity.

Translation invariant denoising. % invariant transform Iwti = perform_wavelet_transform(In,Jmin,1, options); % seuillage IwT = Iwti; IwT = Iwti .* (abs(Iwti)>T); % inverse transform Iwavti = perform_wavelet_transform(IwT,Jmin,-1, options);

Linear (wiener) denoising (for comparison), see also previous lecture. % wiener denoising fI = fft2(I); fIn = fft2(In); pf = abs(fI).^2; % spectral power % fourier transform of the wiener filter hwf = pf./(pf+ n^2*sigma^2); % filter in the spatial domain hw = fftshift( ifft2(hwf) ); % perform the filtering over the fourier Iwien = real( ifft2(fIn .* hwf) );

Displaying the results. clf; subplot(2,2,1); imagesc(I); axis image; axis off; title('Original image'); subplot(2,2,2); imagesc(In); axis image; axis off; title('Noisy image'); subplot(2,2,3); imagesc(Iwav); axis image; axis off; title('Wavelet denoising'); subplot(2,2,4); imagesc(Iwavti); axis image; axis off;

title('Invariant denoising'); colormap gray(256);

riginal

Orthogonal wavelets

TI wavelets

Wien

Denoising of images using wavelets and linear filtering. Translation invariant denoising gives good results by atenuating Gibbs oscillations.

Copyright 2006 Gabriel Peyr