The following experiment performs a one-level (scale one) forward and inverse wavelet transform. It is based on Daubechies filters (wavelets). In addition, a simple experiment of data compression is carried out by only utilizing the low-pass wavelet decomposition for image reconstruction. This can be seen as transmitting only this portion of the data through a communications channel with a 1:4 compression ratio.
The forward and inverse Daubechies filter coefficients are shown below. Two sets of filters are used for the forward and inverse transformation. Observe that the filters are 1D. This ascii files are located in the $DIP/data subdirectory.
daub2hd.ascii - (-0.1294095225512604, -0.2241438680420134, 0.8365163037378079, -0.4829629131445341)
daub2ld.ascii - (0.4829629131445341, 0.8365163037378079, 0.2241438680420134, -0.1294095225512604)
daub2hi.ascii - (-0.4829629131445341, 0.8365163037378079, -0.2241438680420134, -0.1294095225512604)
daub2li.ascii - (-0.1294095225512604, 0.2241438680420134, 0.8365163037378079, 0.4829629131445341)
The result of the forward wavelet transform algorithm is shown below.
Observe the decomposition performed. In clockwise order and starting from the upper left corner of the image we have: 1) low-pass decomposition, 2) high-pass decomposition in the width direction (horizontal details), 3) high-pass decomposition in the height direction (vertical details), and 4) high-pass decomposition in both width and height directions. This is the usual manner to store and display wavelet transforms.
In order to better visualize each decomposition, the four quadrants have been extracted and displayed alone. This is depicted below
The inverse wavelet transform and the difference between the original are shown below
We extract the low-pass decompostion and use it to reconstruct the original image. NOTE: in doing so we can achieve a 1:4 compression ratio. The low-pass image is
The reconstruction using the inverse wavelet transform yields the image below. The difference between the original image and the reconstructed is also displayed: