Discrete Wavelets with Applications

081 (5,3) Biorthogonal Spline Filter Pair

Helmut  Knaust - Department of Mathematical Sciences, University of Texas at El Paso, hknaust@utep.edu
4/14/2022

SetDirectory[NotebookDirectory[]];
<<DW.m
SetDirectory["Images\\Grayscale"];

(5,3): Filter Conditions for the short Lowpass Filter

The short LP filter will have the form (j1,j0, j1).

Clear[t];
lps[t_]={j1,j0,j1}.Table[Exp[k I t],{k,-1,1}]

We need to impose the filter condition 
		lps[π] = 0  :

lps[π]
F1=lps[π]==0//FullSimplify

We will also impose the condition lps[0]= (Sqrt[2]).

lps[0]
F1=lps[0]==(Sqrt[2])//FullSimplify

Solving for the coefficents yields

solsh=Solve[{j0-2j1==0,j0+2j1==(Sqrt[2])}]

FourierFilterPlot[{j1,j0,j1}/.solsh[[1]]]

(5,3): Filter Condition for the long Lowpass Filter and the orthogonality conditions

The long LP filter will have the form (h2,h1,h0,h1,h2).

Clear[t];
lpl[t_]={h2,h1,h0,h1,h2}.Table[Exp[k I t],{k,-2,2}]

We need to impose the filter condition 
		lpl[π] = 0  :

lpl[π]
F1=lpl[π]==0//FullSimplify

Here are the orthogonality conditions:

j0 h0+2j1 h1==1

j0 h0+2j1 h1==1/.solsh[[1]]

...and...

j0 h2 +j1 h1==0

j0 h2 +j1 h1==0/.solsh[[1]]

This yields the following coefficients of the long LP filter:

sollg=Solve[{h0+2 h2==2 h1, (h0/(Sqrt[2]))+(h1/(Sqrt[2]))==1, (h1/(2 (Sqrt[2])))+(h2/(Sqrt[2]))==0}]

FourierFilterPlot[{h2,h1,h0,h1,h2}/.sollg[[1]]]

The Low Pass Matrices

Clear[j0,j1,h0,h1,h2,J,H]

J[n_]:=SparseArray[{{1,1}->j0,{1,2}->j1, {1,n}->j1,{i_,k_}/;k==2i-1->j0,{i_,k_}/;k==2i->j1,{i_,k_}/;k==2i-2->j1},{n/2,n}];
Normal[J[12]]

{j0,j1}={j0,j1}/.{j0->(1/(Sqrt[2])),j1->(1/(2 (Sqrt[2])))}

J[n_]:=SparseArray[{{1,1}->j0,{1,2}->j1, {1,n}->j1,{i_,k_}/;k==2i-1->j0,{i_,k_}/;k==2i->j1,{i_,k_}/;k==2i-2->j1},{n/2,n}];
Normal[J[12]]

H[n_]:=SparseArray[{{1,n-1}->h2,{1,n}->h1,{i_,k_}/;k==2i-3->h2,{i_,k_}/;k==2i-2->h1,{i_,k_}/;k==2i-1->h0,{i_,k_}/;k==2i->h1,{i_,k_}/;k==2i+1->h2, {n/2,1}->h2},{n/2,n}];
Normal[H[12]]

{h0,h1,h2}={h0,h1,h2}/.sollg[[1]]

H[n_]:=SparseArray[{{1,n-1}->h2,{1,n}->h1,{i_,k_}/;k==2i-3->h2,{i_,k_}/;k==2i-2->h1,{i_,k_}/;k==2i-1->h0,{i_,k_}/;k==2i->h1,{i_,k_}/;k==2i+1->h2, {n/2,1}->h2},{n/2,n}];
Normal[H[12]]

J[20].H[20]\[Transpose]//Normal

The High Pass Matrices and Checking

Print["W = ",{{J},{G}}]
Print["Wt = ",{{H},{K}}]
Print["Need: ", {{JH,JK},{GH,GK}}," =" ,{{ID,0},{0,ID}}]

K[n_]:=SparseArray[{{i_,k_}/;k==2i->j0,{i_,k_}/;k==2i-1->-j1,{i_,k_}/;k==2i+1->-j1,{n/2,1}->-j1},{n/2,n}];
Normal[K[8]]

{j0,j1}={j0,j1}/.{j0->(1/(Sqrt[2])),j1->(1/(2 (Sqrt[2])))}

K[n_]:=SparseArray[{{i_,k_}/;k==2i->j0,{i_,k_}/;k==2i-1->-j1,{i_,k_}/;k==2i+1->-j1,{n/2,1}->-j1},{n/2,n}];
Normal[K[8]]

J[10]//Normal
K[10]//Normal
J[10].K[10]\[Transpose]//Normal

G[n_]:=SparseArray[{{1,n}->h2,{i_,k_}/;k==2i-2->h2,{i_,k_}/;k==2i-1->-h1,{i_,k_}/;k==2i->h0,{i_,k_}/;k==2i+1->-h1,{i_,k_}/;k==2i+2->h2, {n/2,1}->-h1,{n/2,2}->h2},{n/2,n}];
Normal[G[10]]

{h0,h1,h2}={h0,h1,h2}/.sollg[[1]]

G[n_]:=SparseArray[{{1,n}->h2,{i_,k_}/;k==2i-2->h2,{i_,k_}/;k==2i-1->-h1,{i_,k_}/;k==2i->h0,{i_,k_}/;k==2i+1->-h1,{i_,k_}/;k==2i+2->h2, {n/2,1}->-h1,{n/2,2}->h2},{n/2,n}];
Normal[G[10]]

J[20].K[20]\[Transpose]//Normal

G[20].K[20]\[Transpose]//Normal

W[n_]:=N[Join[J[n],G[n]]]

W[10]//Normal

Wt[n_]:=N[Join[H[n],K[n]]]

Wt[10]//Normal

W[10].Wt[10]\[Transpose]//Normal//Chop

Image transformation

pic=Import["train.png","Data"];

ImagePlot[pic]
Dimensions[pic]

TF=Wt[512].pic.W[768]\[Transpose];
ImagePlot[TF,Scaled->False]

RI=W[512]\[Transpose].TF.Wt[768];
ImagePlot[RI]
PSNR[pic,RI]