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.