The Haar Wavelet Transform has given us an image with well localized energy. We want to quantize the upper left quadrant with a high number of bits, such as eight, whereas the lower right quadrant can be quantized with one or no bits. For different compression factors, various quantization levels were assigned to the upper right and lower left quadrants.
Depending on the number of bits assigned to quantize a block, a set of sub- intervals was set up between the maximum and minimum value in each block. The higher the number of quantization bits, the larger the number of intervals.
where I is the number of intervals and b is the number of quantization bits for that block. Each interval is assigned a code. Smaller number of intervals (small b) will have smaller codes. Each value in a block is assigned a code based on the interval it falls in. Then the code is mapped to a bit stream. A header containing the maximum and minimum value of each block is also added to the bit stream.
For decoding, we convert the bit stream back to integers. The intervals are recreated using the maximum and minimal values for each block that we saved in our header. Each integer is mapped to its corresponding interval based on the code and assigned the center value of the interval (uniform quantizer). Then the entire image is taken through the inverse Haar Wavelet Transform and checked for it Mean Square Error.