Image Compression

This project was done by Anna-Rose Wolff.

The Discrete Cosine Trasform (DCT) is a transform which interpolates data using basis functions that are all cosine functions. The one dimensional DCT of order n is a \( n \times n \) matrix C whose entries are \( C_{ij} = \frac{\sqrt{2}}{\sqrt{n}}a_i \cos \frac{i(2j+1) \pi}{2n} \) where \(a_i = \begin{cases} 1/\sqrt{2} & \text{if } i = 0 \\ 1 & \text{if } i = 1, \ldots,n-1 \end{cases} \). The two dimensional DCT is the one dimensional DCT applied in two dimensions. So for a matrix \( X \), the two dimensional DCT is \(Y = CXC^T \). The inverse of the two dimensional DCT is \( X = C^TYC \).

The two dimensional DCT can be used to interpolate or approximate data given on a two dimensional grid. This is used in image compression to compress small blocks of an image, such as \(8 \times 8 \) pixels. This compression ignores some of the information in each block. However, a key feature of DCT is that it helps organize the information so that the ignored part is the part that the human eye is the least sensitive to. So to compress an image, the DCT is run on each \( 8 \times 8 \) pixel block and then the data is quantized. In other words, the less important information is assigned fewer bits of storage space.

This project carried out various forms of image compression on the following image.


Compression of a Grayscale Image

The first part of this project was to run two different types of compression on a grayscaled jpg image. The first form of compression used the quantization matrix Q defined by \( q_{kl} = 8p(k+l+1) \) for \(0 \leq k,l \leq 7 \) where p, a constant, is the loss parameter. The image in question was translated to grayscale outside of Matlab and then compressed and decompressed using the code found here. Applying compression to just one block of the image gives the following results.


The original color block.
p=1p=2
p=4p=6

Compressing the entire grayscale image with \(p =1,2,4,6 \) gave the following images.

p=1p=2
p=4p=6

The second form of quantization used the suggested jpg matrix which can be found in the code above. Compressing and decompressing a \(8 \times 8 \) block with \(p=1 \) gave the following result.

Originalp=1

Compressing and decompressing the entire image with \( p = 1 \) gave the followin results.


Compression of a Color Image

The next part of this project was to run compression on a color jpg image. The form of compression used the quantization matrix Q defined by \( q_{kl} = 8p(k+l+1) \) for \(0 \leq k,l \leq 7 \) where p, a constant, is the loss parameter. The image in question was compressed and decompressed in Matlab using the code found here. Applying compression to just one block of the image gives the following results.


The original color block.
p=1p=2
p=4p=6

Compressing the entire image with \(p =1,2,4,6 \) gave the following images.

p=1p=2
p=4p=6

Compression of a Color Image Using Luminance

The last part of this project was to run compression on a color jpg image after transforming the RGB values to luminance/color difference coordinates. Again, the compression used the jpg quantization matrix and p, a the loss parameter. The image in question was compressed and decompressed in Matlab using the code found here. Applying compression to just one block of the image gives the following results.


The original color block.
p=1p=2
p=4p=6

Compressing the image with \(p =1,2,4,6 \) gave the following images.

p=1p=2
p=4p=6