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.