This project explores using the Discrete Cosine Transform (DCT) alongside a method of quantization to reduce the number of bits required to store a distinguishable image. In other words, the aim of this project will be to develop a method of image compression with information loss acceptable to the human eye. In particular, we will use the Discrete Cosine Transform and quantization to perform the compression. When we refer to the YQ matrix, we are refering to the quantitized transformed matrix. For more information on the DCT and its application, click here.
As requested, we begin by observing a single 8x8 block before and after the compression. See here.
The compression was then carried out for the entire grayscale image. See here.
The same sort of compression was also carried out for the individual R,G, and B channels and then recombined to produce a complete image. See here.
\(p=1\):
\[ \left( \begin{matrix} 34 & -11 & 0 & 0 & 0 & 0 & 0 & 1\\ 4 & -4 & -1 & 1 & 0 & 0 & 0 & 0\\ -2 & -1 & 0 & 0 & 0 & 0 & 0 & 0\\ 1 & -1 & 0 & 0 & 1 & 0 & 0 & 0\\ -1 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \end{matrix} \right) \]
\(p=2\):
\[ \left( \begin{matrix} 17 & -6 & 0 & 0 & 0 & 0 & 0 & 0\\ 2 & -2 & -1 & 0 & 0 & 0 & 0 & 0\\ -1 & -1 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & -1 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \end{matrix} \right) \]
\(p=4\):
\[ \left( \begin{matrix} 8 & -3 & 0 & 0 & 0 & 0 & 0 & 0\\ 1 & -1 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \end{matrix} \right) \]
Uncompressed
Baseline JPEG Compression
The code used can be found here.
All told, the 2D-DCT was effectively used to carry out the compressions. The heavier the compression, the easier it is to store the data, but the more information is lost. However, the JPEG baseline applies a heavy compression with less human perceptive loss.