Lecture 1 - Linear and Non-Linear Wavelet Approximation

5
Lecture 1 - Linear and Non-Linear 1D Wavelet Approximation Abstract : The goals of this lecture is to manipulate wavelet transforms of 1D signals. We will thus learn how to apply this transform and to discover its structures. At last, we will perform linear and non-linear approximation by keeping only a few coefficients. Computation and visualization of wavelet transforms. 1D wavelet transform (download functions perform_wavelet_transform.m et load_signal.m ) % loading a 1D signal n = 256; f = load_signal('Piece-Regular', n); % 1D wavelet transform (you can use other wavelet filters by looking at the 'options' field) Jmin = 4; % minimum scale of the transform fw = perform_wavelet_transform(f,Jmin,+1); % computation of the transform until scale Jmin % draw the original image clf; subplot(2,1,1); plot(f); axis tight; title('Original signal'); % draw the transformed coefficients (try to understand their structure) subplot(2,1,2); plot(fw); axis tight; title('Transformed coefficients'); Lecture 1 - Linear and Non-Linear Wavelet Approximation http://www.ceremade.dauphine.fr/~peyre/teaching/wavelets/tp1.html 1 de 5 31/08/2011 12:21 a.m.

Transcript of Lecture 1 - Linear and Non-Linear Wavelet Approximation

Page 1: Lecture 1 - Linear and Non-Linear Wavelet Approximation

Lecture 1 - Linear and Non-Linear

1D Wavelet Approximation

Abstract : The goals of this lecture isto manipulate wavelet transforms of 1Dsignals. We will thus learn how to applythis transform and to discover itsstructures. At last, we will performlinear and non-linear approximation bykeeping only a few coefficients.

Computation and visualization of wavelet transforms.

1D wavelet transform (download functions perform_wavelet_transform.m et

load_signal.m)

% loading a 1D signaln = 256;f = load_signal('Piece-Regular', n);% 1D wavelet transform (you can use other wavelet filtersby looking at the 'options' field)Jmin = 4; % minimum scale of the transformfw = perform_wavelet_transform(f,Jmin,+1); % computationof the transform until scale Jmin% draw the original imageclf;subplot(2,1,1); plot(f); axis tight; title('Originalsignal');% draw the transformed coefficients (try to understandtheir structure)subplot(2,1,2); plot(fw); axis tight; title('Transformedcoefficients');

Lecture 1 - Linear and Non-Linear Wavelet Approximation http://www.ceremade.dauphine.fr/~peyre/teaching/wavelets/tp1.html

1 de 5 31/08/2011 12:21 a.m.

Page 2: Lecture 1 - Linear and Non-Linear Wavelet Approximation

Examples of piecewise regular signal together with its transformed coefficients.Large coefficients are located, at each scale, near the discontinuities of the signal.Moreover, coefficients become larges at coarser scales (on the left). Finer scale areon the right, and the finest scale represent the n/2 coefficients on the right side of

the transform.

Inverse transforms

f1 = perform_wavelet_transform(fw,Jmin,-1); % shouldrecover the same signal

Linear and non-linear wavelet approximation.

Approximation by setting to 0 the last coefficients.

% keep only the M first coefficientsM = 80;fwM = fw; fwM(M+1:end) = 0;% reconstructionfM = perform_wavelet_transform(fwM,Jmin,-1);

Non linear approximation using thresholding.

% you have to find the threshold in order to keep only theM highest coefficientsT = ???;% perform the thresholdingfwT = fw .* (abs(fw)>T);% reconstructionfT = perform_wavelet_transform(fwT,Jmin,-1);

Display approximated signals

Lecture 1 - Linear and Non-Linear Wavelet Approximation http://www.ceremade.dauphine.fr/~peyre/teaching/wavelets/tp1.html

2 de 5 31/08/2011 12:21 a.m.

Page 3: Lecture 1 - Linear and Non-Linear Wavelet Approximation

clf;subplot(3,1,1); plot(f); axis tight; title('Originalsignal');subplot(3,1,2); plot(fM); axis tight; title( ['Linearapproximation with ' num2str(M) ' coefficients.']);subplot(3,1,3); plot(fT); axis tight; title( ['Non-linearapproximation with ' num2str(M) ' coefficients.']);

Comparison of linear and non-linear approximation. Linear wavelet approxomation isnot efficient beceause of the discontinuities in the original signal. One can see

oscillation near discontinuities because we did not keep enough fine scalecoefficients in order to reconstruct well these step discontinuities. The non-linear

approximation performs better because it adapts itself to the signal by keeping onlyhigh coefficients, that are localised near the steps.

Comparaison of the approximation errors |f-fM|^2; for both methods.

% linearv_lin = cumsum( fw(end:-1:1).^2 );v_lin = v_lin(end:-1:1);% non-linearv = sort( abs(fw) );v_nl = cumsum( v.^2 );v_nl = v_nl(end:-1:1);% log/log plot of the errorsclf; loglog( 1:length(v_lin), v_lin, 1:length(v_lin), v_nl);legend('linear', 'non-linear');axis([1 length(v_lin) 1e-5 max(v_lin) ]);

Lecture 1 - Linear and Non-Linear Wavelet Approximation http://www.ceremade.dauphine.fr/~peyre/teaching/wavelets/tp1.html

3 de 5 31/08/2011 12:21 a.m.

Page 4: Lecture 1 - Linear and Non-Linear Wavelet Approximation

Decreasing of the approximation errors. The theory predicts that the linear errorshould decrease like M^-1, whereas the non-linear approximation should decreaselike M^-alpha, where alpha is the exponent of regularity of the function outside thesteps. Everything happens as if the non-linear approximation allows us to "forget"

the discontinuities.

Comparison with the Fourier transform.

Computation of the Fourier transform and linear approximation in 1D

% 1D Fourier transformff = fft(f);% approximationff = fftshift(ff);M = 80;ffM = ff; ffM(1:end/2-M/2) = 0; ffM(end/2+M/2+1:end) = 0;ff = fftshift(ff); ffM = fftshift(ffM);% reconstructionfM = real(ifft(ffM)); % inverse% displayclf;subplot(3,1,1);plot(f); axis tight; title('Original');subplot(3,1,2);plot(-length(ff)/2+1:length(ff)/2, fftshift(abs(ff)));axis tight; title('Fourier')subplot(3,1,3);plot(fM); axis tight; title(['Linear approx. with 'num2str(M) ' coefficients']);

Lecture 1 - Linear and Non-Linear Wavelet Approximation http://www.ceremade.dauphine.fr/~peyre/teaching/wavelets/tp1.html

4 de 5 31/08/2011 12:21 a.m.

Page 5: Lecture 1 - Linear and Non-Linear Wavelet Approximation

Linear approximation in Fourier basis performs poorly because of discontinuities.Non-linear approximation does not improve on this because Fourier basis is not

localized in space. Spectrum of such a function decays like 1/frequency.

Copyright © 2006 Gabriel Peyré

Lecture 1 - Linear and Non-Linear Wavelet Approximation http://www.ceremade.dauphine.fr/~peyre/teaching/wavelets/tp1.html

5 de 5 31/08/2011 12:21 a.m.