Haar wavelet (2x2)
From ScienceZero
The two-dimensional Haar wavelet is useful for transforming data into 4 bands where b0 contains the DC level of each block while b1-b3 contains higher frequency components.
By recursively applying the transformation on b0 until b0 reaches a size of 1 we get frequency information about different areas in the picture at different scales. After the transformations most values will have a low value (assuming that the input data is a normal photograph), by using quantization and setting very low values to zero the data will compress very well using fairly simple compression algorithms like Huffman.
Input block of 2x2 pixels p0 p1 p2 p3
Forward transformation b0 = (p0 + p1) + (p2 + p3) b1 = (p0 - p1) + (p2 - p3) b2 = (p0 + p1) - (p2 + p3) b3 = (p0 - p1) - (p2 - p3)
Reverse transformation p0 = ((b0 + b1) + (b2 + b3)) / 4 p1 = ((b0 - b1) + (b2 - b3)) / 4 p2 = ((b0 + b1) - (b2 + b3)) / 4 p3 = ((b0 - b1) - (b2 - b3)) / 4