» Image Compression «

Description

Image compression in this project was implemented using Discrete Cosine Transform (DCT). This transform interpolates data, using basis functions that are all cosine functions, and involves only real computations. Its orthogonality characteristics make least squares approximation simple.
Covers image compression principles used in the JPEG method.

Implementation

I used the two-dimensional DCT to compress the images below. Each of the images has the following dimensions: 4928x3280.
Since 2D DCT is used to compress small blocks of an image I iterated through blocks of 8x8 pixels until I reached the limit.

Original Image 1 Original Image 2
Image_1 Image_2

The key feature of the DCT is that it helps organize the information so that the ignored information (or loss parameter p) from the blocks of an image is the one that the human eye is least sensitive to. In other words, the DCT will show is how to interpolate the data with a set of basis functions that are in a descending order of importance as fas a the human visual system is concerned.

After experimenting with p values, mentioned photos appeared to lose quality when p was increasing. So, by the time I reached the value 5 the images were barely usable.

Here are the images with loss parameter 7:

Loss Parameter 7 Image 1 Loss Parameter 7 Image 2
Image_1 Image_2

If you take a closer look at these images you will notice that they turned out very lossy:

Closeup p=7 Image 1 Closeup p=7 Image 2
Image_1 Image_2

When the images with p=1 turned out very well:

Closeup p=1 Image 1 Closeup p=1 Image 2
Image_1 Image_2

*The difference is pretty clear. You can also find this project on my GitHub and test it yourself.