## Software

The zip file, hddwt.zip, contains the programs to design the wavelet filters and to implement the transform.

The MATLAB ToolBox contains programs to implement the higher-density discrete wavelet transform (HD-DWT). The HD-DWT is a particular type of over-complete (expansive) wavelet transform. For some sets of filters, the inverse transform is the transpose of the forward transform, and therefore it satisfies Parseval's energy property (the frame is 'tight').

We use cell arrays in MATLAB to store the wavelet coefficients because it simplifies the programs and it also makes it easy to access the wavelet coefficients corresponding to a specific subband. A cell array can be used to store a set of vectors, each vector having possibly different lengths. Because there are a different number of wavelet coefficients at each scale, a cell array is convenient for organizing the wavelet coefficients.

The basic building block of the discrete wavelet transform is the analysis and synthesis filter banks. The analysis filter bank is implemented with the program afb. The program returns three subband signals obtained by filtering the input signal with each of three filters and down-sampling the first two signals by two. The three subband signals are called lo, bp, and hi for lowpass, bandpass, and highpass. The synthesis filter bank is implemented with the program sfb.

We can check the perfect reconstruction conditions using the following MATLAB code fragment:

```>> [af, sf] = filters('3vm');
>> x = rand(1,64);
>> [lo, bp, hi] = afb(x, af);
>> y = sfb(lo, bp, hi, sf);
>> err = x - y;
>> max(abs(err))

ans =

2.0206e-14
```

The main program for computing the HD-DWT is hddwt. The program simply calls the analysis filter bank program afb iteratively - each time reassigning the input signal x as the lowpass subband signal and storing the bandpass and highpass subband signals in a cell array.

```for j = 1:J
[x, w{j}{1} w{j}{2}] = afb(x, af);
end
w{J+1} = x;
```

To clarify the way in which the wavelet coefficients are organized in the cell array, lets take a 3-stage HD-DWT of a length 128 signal:

```>> x = rand(1,128);
>> w = hddwt(x,3,af)

w =

{1x2 cell}    {1x2 cell}    {1x2 cell}    [1x16 double]
```

The cell w{1} contains the wavelet coefficients coming from the first stage.

```>> w{1}

ans =

[1x64 double]    [1x128 double]
```

The vector w{1}{1} contains the 64 wavelet coefficients coming from the bandpass subband at the first stage, and w{1}{2} contains the 128 wavelet coefficients coming from the highpass subband at the first stage. Similarly:

```>> w{2}

ans =

[1x32 double]    [1x64 double]

>> w{3}

ans =

[1x16 double]    [1x32 double]
```

We can check the perfect reconstruction property of hddwt using the following MATLAB code fragment:

```>> [af, sf] = filters('3vm');
>> x = rand(1,64);
>> w = hddwt(x, 3, af);
>> y = ihddwt(w, 3, sf);
>> err = x - y;
>> max(abs(err))

ans =

4.7018e-14
```