In this section, we add another dimension to the Haar Transform. Adding this dimension adds further calculations of course, but now we are able to do Haar Transforms of images. "The Haar Transform is computed by iterating the difference between even and odd sample values of the signal. Since we are in 2-D, we need to compute the average and difference in the horizontal and then in the vertical (Note: Order does not matter. Could be horizontal then vertical)." (1) The formula is given below:
and
In this section, we use a nice image of a hibiscus flower. Mr. Peyrè performs the Haar Transform in the vertical direction first, and shows the results in the plot below:
Subsequently, one can continue this process for scales. This is how the multi-resolution aspect of Wavelets is achieved. Below, the first step of the algorithm is implemented:
Next, Mr. Peyrè implements a full Haar Transofrm and and displays the last 4 stages of Haar Coefficients. The Haar Transform is very simple - it is the average of the even and odd differences of the signal. Looking at Mr. Peyrè's website in conjunction with my description is probably the most ideal way of following along. At each iteration, one overwrites a previous part of your matrix of Haar Coefficient's. For example, the first iteration, in the case of the hibiscus, one span from 1-257 (Matlab Matrix entry values), then the next iteration will overwite 1-129 with new Haar Coefficients. Next, 1-65 will be overwritten, etc. The plots Mr. Peyrè constructs are very nice to look at and craftily coded.
This is a very good example of the multi-resolution facet of Wavelets. Wavelets enable us to "zoom-in" or "zoom-out" of various representations of a signal. To complete our analysis of the Forward Haar Transform, Mr. Peyrè plots the all of the Haar Coefficients.
I hope this can help piece everything together. One is able to calculate the Haar Cofficients at different stages. This process allows one to introduce a variety of methods like filtering, sparse representations, etc. In the next part of the section, one will see the reconstruction of the hibiscus flower with Haar Wavelets.
To conclude this section, the reconstruction of the hibiscus image, as well as linear and non-linear filters will be studied. To spare me from having to input several different formulas for reconstruction, I'm linking to Mr. Peyrè's website. Go to the section titled, "Inverse 2-D Haar Transform," the formulas can be viewed there. Describing this in words, one takes their Haar Coefficients from the different resolutions they have calculated, and itertively constructs their image. As seen in the plots below, one is able to construct various stages of image reconstruction.
It is interesting to note that these various stages of reconstruction offer opportunities for image compression. I saved the j = 6, 128 x 128 hibiscus as a .jpeg file, and it was a mere 5 kb. The usual filters are then implemented. This means that all the coefficients from the resolution j = 7 are not able to be used in the reconstruction of the image. As you can see in the plot below, Mr. Peyrè cleverly cuts off more coefficients at each iteration. In the last image in the bottom right corner, one only has the first three stages of Haar Coefficients. As one might expect, the image reconstruction is quite terrible, it is rather pixelated.
The only change with the Non-Linear Filtering is that now, coefficients are filtered in two dimensions, instead of one. Mr. Peyrè sets the threshold value at T= .1, and proceeds to generate the following plot.
In an extension of Non-Linear Filtering, Mr. Peyrè decides that he wants to keep a certain number of coefficients in advance, and proceeds to determine a value for T. For compression, this method could be very useful. To do this, in each iteration, he determines how many coefficients he would like to keep. He then sorts his coefficients in ascending order, in this case, all 65536 coefficients. Once sorted, he assigns "T" to be equal to v(Coefficents he wants to keep). This gives the thresholding value. From this point, the standard Non-Linear Thresholding is implemented. This method is very nice.
I have learned many lessons through Mr. Peyrè's tutorials and they have really helped me build an intuition of the subjects in the Wavelet books that I have read. I cannot stress how helpful it is to have his codes that he distributes. It would be a great struggle for me to code these on my own, especially when I am trying to come to terms with the theory of Wavelets. Being able to link together the theory and applications of this subject is the best way to develop an understanding. Next, a more sophisticaed Wavelet is studied - the 1-D Daubechies Wavelet.
Works Cited
(1) Peyrè, Gabriel. "2-D Haar Wavelets." 2-D Haar Wavelets. CEREMADE, n.d. Web. 09 June 2014.
(2) Peyrè, Gabriel. "2-D Haar Wavelets." 2-D Haar Wavelets. CEREMADE, n.d. Web. 09 June 2014.
G. Peyré, The Numerical Tours of Signal Processing - Advanced Computational Signal and Image Processing, IEEE Computing in Science and Engineering, vol. 13(4), pp. 94-97, 2011.