Our Code - Discussion and Procedure

The user compresses an image by calling compress.m. S/he then inputs an image and chooses which mask to be used (the image is read in using freadbin.m and mask is found using findmask.m). The first thing the code does is splits the images into 8x8 blocks and takes the DCT of each by using functions process.m, blkproc2out.m (standard blkproc code was modified to allow two outputs),and dctus.m (as well as dctus2.m-the 2-D DCT).

After the individual blocks have been transformed, the code then applies the mask and quantizes the blocks according to how many bits are allocated to each pixel. This part uses functions chunk.m, maskdecode.m, and quant.m. We then code the quantization levels (also in the process.m code). We then write the bits out to a binary file, each pixel with its own number of allocated bits. This is done in writebits.m using fwritebin.m. The mask number is written out as the first three bits of the bitstream.

Then, to decode the image, the user inputs the name of the file to be decompressed (using freadbin.m and uncompress.m). We call readbits.m which contains the information about the mask and therefore how many bits each pixel has. This information tells us what the quantization level was of the original image. This information is then decoded using ichunk.m and inverse transformed with idctus.m and idctus2.m in order to recover the original image.


Mask Numbers

Mask 1: 76 bits total for 8x8. MSB has 4 bits
Mask 2: 175 bits total for 8x8. MSB has 8 bits
Mask 3: 282 bits total for 8x8. MSB has 12 bits
Mask 4: 313 bits total for 8x8. MSB has 16 bits
Mask 5: 549 bits total for 8x8. MSB has 32 bits