%
% file:      	blocks_ex.m, (c) Matthew Roughan, Sun Oct 24 2004
% directory:   /home/mroughan/Classes/Transformations/2004/Matlab/
% created: 	Sun Oct 24 2004 
% author:  	Matthew Roughan 
% email:   	matthew.roughan@adelaide.edu.au
% 
% place help info about BLOCKS_EX here
%
%
clear;

rand('seed', 1);


opengl neverselect;
N = 2048;

sig = MakeSignal('Blocks' , N);
t = (0:(N-1))/N;

figure(1)
plot(t, sig, 'linewidth', 3);
set(gca,'linewidth',3);
set(gca,'fontsize',14);

set(gcf, 'PaperUnits', 'centimeters')
set(gcf, 'PaperOrientation', 'portrait');
set(gcf, 'PaperPosition', [0 0 21 14])
print('-depsc', 'Plots/blocks_ex_1.eps');

rho = 7;
[xblocks,yblocks] = NoiseMaker(sig,rho);


figure(2)
plot(t, yblocks, 'linewidth', 3);
set(gca,'linewidth',3);
set(gca,'fontsize',14);

set(gcf, 'PaperUnits', 'centimeters')
set(gcf, 'PaperOrientation', 'portrait');
set(gcf, 'PaperPosition', [0 0 21 14])
print('-depsc', 'Plots/blocks_ex_2.eps');

HL = 3; 
HQMF       = MakeONFilter('Haar');
[xhat,xw]  = WaveShrink(yblocks,'Visu',HL,HQMF);
yw         = FWT_PO(yblocks,HL,HQMF);

clf; scal = .05;
figure(3)
PlotWaveCoeff(yw,HL,scal); title(' 6 (c) Haar[y]')
set(gca,'linewidth',3);
set(gca,'fontsize',14);

set(gcf, 'PaperUnits', 'centimeters')
set(gcf, 'PaperOrientation', 'portrait');
set(gcf, 'PaperPosition', [0 0 21 14])
print('-depsc', 'Plots/blocks_ex_3.eps');

figure(31);
wavecoef = ShapeAsRow(yw);
[n,J] = dyadlength(wavecoef);
[y,x] = hist(wavecoef(dyad(J-1)), -15:15);
bar(x,log(y));
set(gca,'linewidth',3);
set(gca,'fontsize',14);

set(gcf, 'PaperUnits', 'centimeters')
set(gcf, 'PaperOrientation', 'portrait');
set(gcf, 'PaperPosition', [0 0 21 14])
print('-depsc', 'Plots/blocks_ex_31.eps');

figure(4);
PlotWaveCoeff(xw,HL,scal);
set(gca,'linewidth',3);
set(gca,'fontsize',14);

set(gcf, 'PaperUnits', 'centimeters')
set(gcf, 'PaperOrientation', 'portrait');
set(gcf, 'PaperPosition', [0 0 21 14])
print('-depsc', 'Plots/blocks_ex_4.eps');

figure(41);
wavecoef = ShapeAsRow(xw);
[n,J] = dyadlength(wavecoef);
[y,x] = hist(wavecoef(dyad(J-1)), -15:15);
bar(x,log(y));
set(gca,'linewidth',3);
set(gca,'fontsize',14);

set(gcf, 'PaperUnits', 'centimeters')
set(gcf, 'PaperOrientation', 'portrait');
set(gcf, 'PaperPosition', [0 0 21 14])
print('-depsc', 'Plots/blocks_ex_41.eps');

figure(5);
hold off;
plot(t, sig, 'r', 'linewidth', 2);
hold on
plot(t, xhat/3.653, 'linewidth', 3);
set(gca,'linewidth',3);
set(gca,'fontsize',14);

set(gcf, 'PaperUnits', 'centimeters')
set(gcf, 'PaperOrientation', 'portrait');
set(gcf, 'PaperPosition', [0 0 21 14])
print('-depsc', 'Plots/blocks_ex_5.eps');

QMF = MakeONFilter('Symmlet',8);
L = 5;
%
[xhblocks] = WaveShrink(yblocks,  'Visu',L,QMF);
figure(10)
hold off;
plot(t, sig, 'r', 'linewidth', 2);
hold on
plot(t, xhblocks/3.653, 'linewidth', 3);
set(gca,'linewidth',3);
set(gca,'fontsize',14);

set(gcf, 'PaperUnits', 'centimeters')
set(gcf, 'PaperOrientation', 'portrait');
set(gcf, 'PaperPosition', [0 0 21 14])
print('-depsc', 'Plots/blocks_ex_10.eps');


