Image Compression

Jason Lasseigne


Introduction

Using the 2D Discrete Cosine Transform we can compress small blocks of an image. These can be compiled to recreate the image. The compression is lossy, meaning some information from the block is ignored. The key is that the part that is ignored is the part that the human eye is least sensitive to.

11.2.3

We were asked to obtain a grayscale image, and make sure its dimensions are multiples of 8.

The image I chose whose dimensions are 240x240:

We needed to extract an 8x8 pixel block, apply the 2D-DCT, quantize, and reconstruct the block. Code for the DCT, quantizing, and dequantizing: a-d code

My original 8x8 block (left) DCT matrix (right):

My reconstructed 8x8 blocks with their YQ matrices p=1(top), p=2(middle), p=4(bottom):

Now reconstructing the entire image using 8x8 blocks: Image reconstruction

p=1 (left) p=2 (middle) p=4 (right):


11.2.4

Next we were asked to repeat but with the JPEG-suggested matrix with p=1. The only change in the code was the Q matrix.

My original 8x8 pixel block is the same as above, and my reconstructed pixel block, DCT matrix, and YQ matrix are:

My reconstructed entire image:


11.2.5

The next part required us to obtain a color image and repeat the process. The color image I chose:

The 8x8 color pixel block with code for the following parts: Color code

The DCT matrices or R, G and B respectively are:

The YQ matrices for quantinization for p=1 are (for R, G and B respectively):

For p=2:

For p=4

The reconstructed 8x8 pixel blocks (for R, G and B respectively):

The entire reconstructed image from combining R G and B with p = 1,2,4 respectively: Code given here: Reconstructed color


11.2.6

We were now asked to repeat the steps with the color image but now transforming the RGB values into luminance/color difference coordinates and using the JPEG quantinization.

The same 8x8 color pixel block from above will be used.

The YQ matrices for Y, U, and V respectively are:

The reconstruction of the 8x8 pixel block for Y, U, V respectively are (with code given here): Luminance/color difference

Combining Y, U and V together to reconstruct the picture yielded for p=1,2,4 respectively (with code given here): Luminance reconstruction