# In image compression using transforms, how to deal with the transformed coefficients as they are not integers?

I am new to the field of image compression. While going through various texts, I read about how transforming the image to another domain using, for example, the wavelet transform, or the DCT, makes it suitable for lossy compression.

I have been trying to play around with wavelet transforms on a sample bmp in MATLAB. Using the MATLAB library function, I created transform coefficients using Daubechies wavelets.

Now a given pixel when read from bmp is in uint8 format, i.e., it uses up 1 byte of memory. This is because in most image formats the range of values a pixel can take is from 0 to 255. After wavelet transformation however, one gets double precision floating point for each element of the transformed matrix. This would typically consume about 4 bytes for each element.

My goal was to try out some very basic compression using quantization and entropy coding of quantized elements. Quantizing the low magnitude values of the transformed elements to zero does give good compression. But trouble is I have to still use double precision floating point. The moment I convert all the wavelet coefficients to some integer format, the reconstructed image becomes very poor in quality as compared to the original.

In standard compression techniques, how are the transformed coefficients handled, given that they are not integer in format? Each transformed coefficient, due to its double precision nature, takes up more bytes than the original. Can you point out resources where this issue has been explained?

• Why you have to use double precision floating point after compression? – Premnath D Nov 17 '13 at 12:52
• Double precision is 8 bytes (64 bits); single precision is 4 bytes (32 bits). At least, that's the normal IEEE 754 definition. – MSalters Nov 18 '13 at 15:22

It's often possible to come up with a scale factor such that the largest coefficient has the value 255. You'd need to store this scale factor once per set of coefficients. This saves 3 bytes per coefficient. Usually you can live without coefficients smaller than 1/255th of the largest.