1. Code a simple wavelet transform We propose to study and implement the Haar wavelet transformation: 

This transformation splits a discrete signal x(k) of size m into two parts y_{1}(k) and y_{2}(k) of size m/2. For splitting an image, the same decomposition is applied first on columns, then on rows. In this session, we assume that the image is square and that its size is a power of 2.
1.1 Analysis
The wavelet transform is implemented using 3 methods:
The methods analysis() and split() are already written. Your assignment is to code the method split_1D() in the file Code.java.
Test your work on mire.tif and aletsch.tif using the plugin Image Transform: check "Transform", uncheck "Processing" and "Inverse" and select n=3 in the dialog box. Select the output in "True Values" or in "Scaled Values" in which case the coefficients of the wavelet transform are rescaled between 0 to 255.
1.2 Synthesis filter and implementation
Write the synthesis filter in matrix form to reconstruct back the original signal x(k) form its subparts y_{1}(k) and y_{2}(k); fill in the report.
Your assignment is to code the three methods that perform the inverse wavelet transform.
Test your work on mire and aletsch.tif, check "Transform" and "Inverse", uncheck "Processing".
1.3 Check the transformation and reconstruction process
We propose to compare the reconstruction of 4 transformations on the image aletsch.tif
Compute the SNR between the original image and the reconstructed image (transform+inverse). Using the plugin SNR. Conclude and fill in the report.
2. Modifying subband wavelet coefficients
The wavelet coefficients are stored according to the arrangement shown on the right figure where n is the total number of scales.
Write the routines keepHighpassSubBand(coef, n) that only preserves coefficients of 3 highpass subbands (HL_{n}, HH_{n}, LH_{n}) at level n and sets to 0 the other coefficients, and keepLowpassSubBand(coef, n) that only preserves the coefficients of the lowpass (LLn) subband at level n. Choose the "Keep 3 Highpass subband" or "Keep 1 Lowpass subband" as processing in the plugin.
Make the following experience on the aletsch.tif image:
Comment on the wavelet family and on the effect of the parameter n and fill in report.doc.
3. Comparison of the transform in term of compression
Simple data compression is achieved by applying a hard threshold to the coefficients of the wavelet transform (used in JPEG2000) or the DCT (used in JPEG). Note that this is only a rudimentary form of compression. A true coder would further quantize the wavelet coefficients which induces additional errors. The resulting coefficient map would also need to be encoded efficiently using, for example, the EZW algorithm (Embedded Zerotree Wavelet coding).
To apply the compression function, check "Transform", "Processing" and "Inverse" , select "Hard threshold" and the rate (percentage of nonzero coefficients). If the rate is 10%, the image will be reconstructed using the 10% largest transform coefficients.
Compute the SNR between the original image (aletsch.tif) and the compressed image to assess the quality of the compression for the 3 transformations "Haar Wavelet, 6 scales", "Spline Wavelet, 6 scales" and "DCT 8x8" and for the rate = 2% and rate = 10%. Insert in the report the best obtained image for the rate = 2% and rate = 10% and fill in report.doc.
4. Detection of infocus areas
We propose to design a simple detector of sharp (i.e infocus) areas based on the wavelet transform. The sharp areas are characterized by larger coefficients (highenergy) in highpass subbands. The algorithm is the following:
4.1. Coding
Write the routine detectSharpArea() which implements the described algorithm. The parameters n and T are given through the dialog box.
4.2 Experimentation
Report the result of your experiences in the report.doc for the 3 images: roadrunner.tif, papertext.tif and retina.tif.