% % some useful matlab commands for your wavelet project % check out conv2-- this is the only *signal processing* command used in all of the following. % You should implement your compression scheme without using any commands from the wavelet toolbox. % % define the data matrix A=[3 4 5 6 7 9 8 1; 10 11 6 18 9 7 9 88; 23 1 88 7 77 66 55 9; 12 13 23 24 2 4 5 6; 22 22 22 22 22 33 33 33; 1 1 1 2 3 4 5 6; 44 5 5 5 5 5 5 5; 9 8 7 6 5 5 5 5] % define the LP and HP filters h=[-0.5 0.5] l = [0.5 0.5] %filter along the rows first and sub-sample. HH band Ah=conv2(A,h) Ah2=Ah(:,2:2:8) %Filter along the columns next and subsample Ah2h=conv2(Ah2',h) Ah2h2=Ah2h(:,2:2:8) Ah2h2=Ah2h2' % % % High-Low band; Ah2l=conv2(Ah2',l) Ah2l2=Ah2l(:,2:2:8) Ah2l2=Ah2l2' % % define the RECONSTRUCTION FILTERS % ht=[1 -1] lt=[1 1] % % Low Pass along rows % Al=conv2(A,l) Al2=Al(:,2:2:8) %% LH BAND Al2h=conv2(Al2',h) Al2h2=(Al2h(:,2:2:8))' % % LL BAND % Al2l=conv2(Al2',l) Al2l2=(Al2l(:,2:2:8))' % %-- 9:04 AM 2/20/01 --% % For upsampling, need to add zeros in between. % Create a zeros matrix % Z=zeros(4,8) al2l=Z; al2l(:,2:2:8)=Al2l2' al2=conv2(al2l,lt) al2=al2' al=zeros(9,8);al(:,2:2:8)=al2; a=conv2(al,lt); ALL=a; %____________________ % al2h=zeros(4,8); al2h(:,2:2:8)=Al2h2'; al2=conv2(al2h,ht); al2=al2'; al=zeros(9,8);al(:,2:2:8)=al2; a=conv2(al,lt); ALH=a %__________________________ % ah2l=Z; ah2l(:,2:2:8)=Ah2l2';ah2=conv2(ah2l,lt); ah2=ah2' ah=zeros(9,8);ah(:,2:2:8)=ah2; a=conv2(ah,ht); AHL=a %__________________________ % ah2h=Z; ah2h(:,2:2:8)=Ah2h2';ah2=conv2(ah2h,ht); ah2=ah2' ah=zeros(9,8);ah(:,2:2:8)=ah2; a=conv2(ah,ht); AHH=a % % Now add all subband reconstructed signals to get the original back % AREC=ALL+ALH+AHL+AHH _______________________________________ A = 3 4 5 6 7 9 8 1 10 11 6 18 9 7 9 88 23 1 88 7 77 66 55 9 12 13 23 24 2 4 5 6 22 22 22 22 22 33 33 33 1 1 1 2 3 4 5 6 44 5 5 5 5 5 5 5 9 8 7 6 5 5 5 5 >> Al2l2 Al2l2 = 7.0000 8.7500 8.0000 26.5000 12.2500 35.5000 37.2500 18.7500 11.5000 11.7500 15.5000 19.2500 16.5000 5.7500 5.0000 5.0000 >> Al2h2 Al2h2 = -3.5000 -3.2500 0 -22.0000 -0.2500 12.0000 34.2500 13.2500 10.5000 10.2500 12.0000 13.7500 8.0000 -0.7500 0 0 >> Ah2l2 Ah2l2 = -0.5000 -3.2500 0 -18.0000 5.2500 20.0000 2.2500 11.2500 0 -0.2500 -3.0000 -0.2500 10.0000 0.2500 0 0 >> Ah2h2 Ah2h2 = 0 2.7500 -1.0000 21.5000 5.7500 20.5000 3.2500 11.7500 0 0.2500 -2.5000 0.2500 9.5000 -0.2500 0 0 >> >> ALL ALL = 0 0 0 0 0 0 0 0 0 0 7.0000 7.0000 8.7500 8.7500 8.0000 8.0000 26.5000 26.5000 0 7.0000 7.0000 8.7500 8.7500 8.0000 8.0000 26.5000 26.5000 0 12.2500 12.2500 35.5000 35.5000 37.2500 37.2500 18.7500 18.7500 0 12.2500 12.2500 35.5000 35.5000 37.2500 37.2500 18.7500 18.7500 0 11.5000 11.5000 11.7500 11.7500 15.5000 15.5000 19.2500 19.2500 0 11.5000 11.5000 11.7500 11.7500 15.5000 15.5000 19.2500 19.2500 0 16.5000 16.5000 5.7500 5.7500 5.0000 5.0000 5.0000 5.0000 0 16.5000 16.5000 5.7500 5.7500 5.0000 5.0000 5.0000 5.0000 >> ALH ALH = 0 0 0 0 0 0 0 0 0 0 -3.5000 -3.5000 -3.2500 -3.2500 0 0 -22.0000 -22.0000 0 3.5000 3.5000 3.2500 3.2500 0 0 22.0000 22.0000 0 -0.2500 -0.2500 12.0000 12.0000 34.2500 34.2500 13.2500 13.2500 0 0.2500 0.2500 -12.0000 -12.0000 -34.2500 -34.2500 -13.2500 -13.2500 0 10.5000 10.5000 10.2500 10.2500 12.0000 12.0000 13.7500 13.7500 0 -10.5000 -10.5000 -10.2500 -10.2500 -12.0000 -12.0000 -13.7500 -13.7500 0 8.0000 8.0000 -0.7500 -0.7500 0 0 0 0 0 -8.0000 -8.0000 0.7500 0.7500 0 0 0 0 >> AHL AHL = 0 0 0 0 0 0 0 0 0 0 -0.5000 0.5000 -3.2500 3.2500 0 0 -18.0000 18.0000 0 -0.5000 0.5000 -3.2500 3.2500 0 0 -18.0000 18.0000 0 5.2500 -5.2500 20.0000 -20.0000 2.2500 -2.2500 11.2500 -11.2500 0 5.2500 -5.2500 20.0000 -20.0000 2.2500 -2.2500 11.2500 -11.2500 0 0 0 -0.2500 0.2500 -3.0000 3.0000 -0.2500 0.2500 0 0 0 -0.2500 0.2500 -3.0000 3.0000 -0.2500 0.2500 0 10.0000 -10.0000 0.2500 -0.2500 0 0 0 0 0 10.0000 -10.0000 0.2500 -0.2500 0 0 0 0 >> AHH AHH = 0 0 0 0 0 0 0 0 0 0 0 0 2.7500 -2.7500 -1.0000 1.0000 21.5000 -21.5000 0 0 0 -2.7500 2.7500 1.0000 -1.0000 -21.5000 21.5000 0 5.7500 -5.7500 20.5000 -20.5000 3.2500 -3.2500 11.7500 -11.7500 0 -5.7500 5.7500 -20.5000 20.5000 -3.2500 3.2500 -11.7500 11.7500 0 0 0 0.2500 -0.2500 -2.5000 2.5000 0.2500 -0.2500 0 0 0 -0.2500 0.2500 2.5000 -2.5000 -0.2500 0.2500 0 9.5000 -9.5000 -0.2500 0.2500 0 0 0 0 0 -9.5000 9.5000 0.2500 -0.2500 0 0 0 0 >> AREC AREC = 0 0 0 0 0 0 0 0 0 0 3 4 5 6 7 9 8 1 0 10 11 6 18 9 7 9 88 0 23 1 88 7 77 66 55 9 0 12 13 23 24 2 4 5 6 0 22 22 22 22 22 33 33 33 0 1 1 1 2 3 4 5 6 0 44 5 5 5 5 5 5 5 0 9 8 7 6 5 5 5 5 >>