This preview shows pages 1–3. Sign up to view the full content.
Image Compression Using the Discrete
Cosine Transform
Andrew B. Watson
NASA Ames Research Center
Abstract
The discrete cosine transform (DCT) is a technique for converting a signal into elementary
frequency components. It is widely used in image compression. Here we develop some simple
functions to compute the DCT and to compress images.
These functions illustrate the power
of
Mathematica
in the prototyping of image processing
algorithms.
The rapid growth of digital imaging applications, including desktop publishing, multimedia,
teleconferencing, and highdefinition television (HDTV) has increased the need for effective and
standardized image compression techniques. Among the emerging standards are JPEG, for
compression of still images [Wallace 1991]; MPEG, for compression of motion video [Puri
1992]; and CCITT H.261 (also known as Px64), for compression of video telephony and
teleconferencing.
All three of these standards employ a basic technique known as the discrete cosine transform
(DCT). Developed by Ahmed, Natarajan, and Rao [1974], the DCT is a close relative of the
discrete Fourier transform (DFT). Its application to image compression was pioneered by Chen
and Pratt [1984]. In this article, I will develop some simple functions to compute the DCT and
show how it is used for image compression. We have used these functions in our laboratory to
explore methods of optimizing image compression for the human viewer, using information
about the human visual system [Watson 1993]. The goal of this paper is to illustrate the use of
Mathematica
in image processing and to provide the reader with the basic tools for further
exploration of this subject.
The OneDimensional Discrete Cosine Transform
The discrete cosine transform of a list of
n
real numbers
s
(
x
),
x
= 0, .
..,
n
1, is the list of length
n
given by:
Mathematica Journal, 4(1), 1994, p. 8188
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
( 29 =
2 n
C u
( 29
s x
( 29
cos
2x
+
1
(
29
u
π
2n
x
=
0
n

1
ε
u
=
0,.
..,n
where
C u
( 29 =
2

1 2
for u
=
0
=
1
otherwise
Each element of the transformed list
S(u)
is the inner (dot) product of the input list
s(x)
and a
basis vector
. The constant factors are chosen so that the basis vectors are orthogonal and
normalized. The eight basis vectors for
n
= 8 are shown in Figure 1. The DCT can be written as
the product of a vector (the input list) and the
n
x
n
orthogonal matrix whose rows are the basis
vectors. This matrix, for
n
= 8, can be computed as follows:
DCTMatrix =
Table[ If[ k==0,
Sqrt[1/8],
Sqrt[2/8] Cos[Pi (2j + 1) k/16] ],
{k, 0, 7}, {j, 0, 7}] // N;
We can check that the matrix is orthogonal:
DCTMatrix . Transpose[DCTMatrix] // Chop // MatrixForm
1.
0
0
0
0
0
0
0
0
1.
0
0
0
0
0
0
0
0
1.
0
0
0
0
0
0
0
0
1.
0
0
0
0
0
0
0
0
1.
0
0
0
0
0
0
0
0
1.
0
0
0
0
0
0
0
0
1.
0
0
This is the end of the preview. Sign up
to
access the rest of the document.
This note was uploaded on 01/10/2012 for the course EE 216 taught by Professor Harris,j during the Fall '09 term at Stanford.
 Fall '09
 Harris,J
 Frequency

Click to edit the document details