This program displays the subband of the rational-dilation wavelet transform. The test signal is a speech signal sampled at a rate of 8000 samples/second.
x = load('data/yes.txt'); % Load variable 'yes' x = x(:)'; % Ensure x is a row vector fs = 8000; % Sampling rate (samples/second) N = length(x); x = x/max(abs(x)); % Normalize so maximum value is 1 figure(1) clf subplot(2,1,1) plot((1:N)/fs,x) box off xlim([0 N/fs]) ylim([-1.5 1.5]) title('TEST SIGNAL') xlabel('TIME (SECONDS)')
p = 5; q = 6; s = 2; % Parameters J = 19; % Number of levels red = 1/s * 1/(1-p/q); % Redundancy % Add path to functions addpath radwt_functions_v2 % use _v1 or _v2 addpath extra_functions
subplot(2,1,2) Plot_FreqResps(p,q,s,J,fs); orient landscape print -dpdf figures/demo3_fig1
Display the wavelets for several levels.
figure(2) J1 = 6; J2 = 19; PlotWavelets(N,p,q,s,J1,J2,fs); orient landscape print -dpdf figures/demo3_fig2
w = radwt(x, J, p, q, s);
y = iradwt(w,p,q,s); % Inverse overcomplete rational WT y = real(y(1:N)); % Reconstructed signal e = max(abs(x - y)); % Error should be zero disp(e)
2.2204e-15
It can be useful to know how the energy of a signal is distributed accross the subbands. We compute the energy in each subband and display using a bar graph. Because the transform has the Parseval property (meaning that the signal energy is equal to the total energy in the transform domain) the distribution of the energy accross the subbands reflects the frequency content of the signal.
e = zeros(1,J+1); for j = 1:J+1 e(j) = sum(abs(w{j}).^2); end figure(3) b = bar(100*e/sum(e)); set(b,'facecolor','w') xlabel('SUBBAND') ylabel('SUBBAND ENERGY (% OF TOTAL)') title('DISTRIBUTION OF SIGNAL ENERGY ACROSS SUBBANDS') box off xlim([0 J+2]) orient landscape print -dpdf figures/demo3_fig3
We normalize each subband signal for the purpose of display, otherwise, some of the subband signal would be too small to see. However, to indicaate the relative energy of each subband we display the fraction of subband energy to total subband energy as a percentage.
figure(4) PlotSubbands(x,w,p,q,s,8,J,fs,'e') title('RATIONAL-DILATION WAVELET REPRESENTATION OF A SPEECH SIGNAL') orient landscape print('-dpdf','figures/demo3_fig4');
These signals computed in this way add up exactly to the original signal x.
figure(5) y = PlotReconSubbands(x, w, p, q, s, fs); orient landscape print('-dpdf','figures/demo3_fig5');