Discrete Cosine Transform

In this project the DCT image compression algorithm was developed in Matlab. The performance of the algorithm is analyzed and studied by reconstructing the original image using different quantity of coefficient. 

The algorithm behave as follows: First the original image is transformed into an 8 by 8 block and then using X quantity of coefficients the image is reconstructed. Afterwards, the error for the reconstructed image is calculated and displayed.

Introduction

Discrete Cosine Transform (DCT) is a technique for converting a signal into elementary frequency components, i.e. this mathematical function transforms the digital image data from the spatial domain to the frequency domain. While one-dimensional DCT is useful for signals like sound waves, two-dimensional DCT is used in image compression. 

Image compression is a type of data compression applied to digital images, to reduce their cost for storage or transmission. Of course, general-purpose compression programs can be used to compress images, but the overall result is not optimal. One of the best-known case that use this encoding for compression is JPEG format. 

Results

The Discrete Cosine Transform helps to separate the image into spectral subbands of unequal importance (with respect to the visual quality of the image). A discrete cosine transform expresses a sequence of a finite number of data in terms of a sum of cosine functions that oscillate at different frequencies. Using cosine instead of sine functions is critical in compression applications, because cosine functions are more efficient. 

1 Coefficient Reconstruction

Original Image

Reconstructed Image

Error

45 Coefficient Reconstruction

Original Image

Reconstructed Image

Error

64 Coefficient Reconstruction

Original Image

Reconstructed Image

Error

Filter

After reconstructing the image, filters may be applied to reduce the blocking effect and obtain better visual results as seen in the image.

This image was reconstructed using just 1 coefficient, afterwards two filter were applied. The first one is a Gaussian filter to reduce the blocking effect but the image becomes a little blurred. So a contrast enhancement filter is applied next, which “focuses” the image and reduces blur.

Conclusions

DCT type II is the most common type of the discrete cosine transform and one of the main problems of this transform is the blocking effect. When DCT is applied, the image is divided into blocks of 8x8 or 16x16 or larger, thus when higher compression rates are used these blocks become visible. Thus,  filters should be applied to reduce the blocking effect and obtain better results.

The  error observed in the images depends directly on the number of coefficients used. As more coefficients are used less is the error. However, it is not necessary to use a large number of coefficients to obtain a well reconstructed image, just a few are enough, this is the characteristic that makes DCT so popular and useful.