# Imperial College London

Department of Electrical and Electronic Engineering
Digital Image Processing
PART I
IMAGE TRANSFORMS
Dr. Tania STATHAKI
Room 811b
Ext. 46229
Email: t.stathaki@ic.ac.uk
http://www.commsp.ee.ic.ac.uk/~tania/
Abstract
Transform theory plays a fundamental role in image processing, as working with the
transform of an image instead of the image itself may give us more insight into the
properties of the image. Two dimensional transforms are applied to image enhancement,
restoration, encoding and description.
1. UNITARY TRANSFORMS
1.1 One dimensional signals
For a one dimensional sequence
} 1 0 ), ( { − ≤ ≤ N x x f
represented as a vector
[ ]
T
N f f f f ) 1 ( ) 1 ( ) 0 ( − · 
of size N , a transformation may be written as
1 0 , ) ( ) , ( ) (
1
0
− ≤ ≤ · ⇒ ⋅ ·

·
N u x f x u T u g f T g
N
x
where
) (u g
is the transform (or transformation) of
) (x f
, and
) , ( x u T
is the so called forward
transformation kernel. Similarly, the inverse transform is the relation

·
− ≤ ≤ ·
1
0
1 0 ), ( ) , ( ) (
N
u
N x u g u x I x f
or written in a matrix form
g T g I f ⋅ · ⋅ ·
−1
where
) , ( u x I
is the so called inverse transformation kernel.
If
T
T T I
∗ −
· ·
1
the matrix
T
is called unitary, and the transformation is called unitary as well. It can be proven
(how?) that the columns (or rows) of an N N × unitary matrix are orthonormal and therefore, form a
complete set of basis vectors in the N −dimensional vector space.
In that case

·
∗ ∗
· ⇒ ⋅ ·
1
0
) ( ) , ( ) (
N
u
T
u g x u T x f g T f
The columns of
T
T

, that is, the vectors
[ ]
T
u
N u T u T u T T ) 1 , ( ) 1 , ( ) 0 , ( − ·
∗ ∗ ∗ ∗

are called the
basis vectors of
T
.
1.2 Two dimensional signals (images)
As a one dimensional signal can be represented by an orthonormal set of basis vectors, an image can
also be expanded in terms of a discrete set of basis arrays called basis images through a two
dimensional (image) transform.
For an N N × image
f x y ( , )
the forward and inverse transforms are given below
∑ ∑

·

·
·
1
0
1
0
) , ( ) , , , ( ) , (
N
x
N
y
y x f y x v u T v u g
∑ ∑

·

·
·
1
0
1
0
) , ( ) , , , ( ) , (
N
u
N
v
v u g v u y x I y x f
where, again,
) , , , ( y x v u T
and
) , , , ( v u y x I
are called the forward and inverse
transformation kernels, respectively.
The forward kernel is said to be separable if
) , ( ) , ( ) , , , (
2 1
y v T x u T y x v u T ·
It is said to be symmetric if
1
T is functionally equal to
2
T such that
) , ( ) , ( ) , , , (
1 1
y v T x u T y x v u T ·
2
The same comments are valid for the inverse kernel.
If the kernel
) , , , ( y x v u T
of an image transform is separable and symmetric, then the transform
∑ ∑ ∑ ∑

·

·

·

·
· ·
1
0
1
1
0
1
1
0
1
0
) , ( ) , ( ) , ( ) , ( ) , , , ( ) , (
N
x
N
y
N
x
N
y
y x f y v T x u T y x f y x v u T v u g
can be written
in matrix form as follows
T
T f T g
1 1
⋅ ⋅ ·
where
f
is the original image of size N N × , and
1
T is an N N × transformation matrix with
elements
) , (
1
j i T t
ij
·
1
T is a unitary matrix then the transform is called
separable unitary and the original image is recovered through the relationship
∗ ∗
⋅ ⋅ ·
1 1
T g T f
T
1.3 Fundamental properties of unitary transforms
1.3.1 The property of energy preservation
In the unitary transformation
f T g ⋅ ·
it is easily proven (try the proof by using the relation
T T
T
− ∗
·
1
) that
2 2
f g ·
Thus, a unitary transformation preserves the signal energy. This property is called energy
preservation property.
This means that every unitary transformation is simply a rotation of the vector
f
in the N -
dimensional vector space.
For the 2-D case the energy preservation property is written as
f x y g u v
y
N
x
N
v
N
u
N
( , ) ( , )
2
0
1
0
1
2
0
1
0
1
·

·

·

·

∑ ∑ ∑ ∑
·
1.3.2 The property of energy compaction
Most unitary transforms pack a large fraction of the energy of the image into relatively few of the
transform coefficients. This means that relatively few of the transform coefficients have significant
values and these are the coefficients that are close to the origin (small index coefficients).
This property is very useful for compression purposes. (Why?)
2. THE TWO DIMENSIONAL FOURIER TRANSFORM
2.1 Continuous space and continuous frequency
The Fourier transform is extended to a function
f x y ( , )
of two variables. If
f x y ( , )
is
continuous and integrable and
F u v ( , )
is integrable, the following Fourier transform pair exists:
∫ ∫

∞ −
+ −
· dxdy e y x f v u F
vy ux j ) ( 2
) , ( ) , (
π
∫ ∫

∞ −
+
· dudv e v u F y x f
vy ux j ) ( 2
2
) , (
) 2 (
1
) , (
π
π
In general
F u v ( , )
is a complex-valued function of two real frequency variables
u v ,
and hence,
it can be written as:
) , ( ) , ( ) , ( v u jI v u R v u F + ·
3
The amplitude spectrum, phase spectrum and power spectrum, respectively, are defined as follows.
F u v R u v I u v ( , ) ( , ) ( , ) · +
2 2
]
]
]

·

) , (
) , (
tan ) , (
1
v u R
v u I
v u φ
P u v F u v R u v I u v ( , ) ( , ) ( , ) ( , ) · · +
2
2 2
2.2 Discrete space and continuous frequency
For the case of a discrete sequence
) , ( y x f
of infinite duration we can define the 2-D discrete
space Fourier transform pair as follows
∑ ∑

−∞ ·

−∞ ·
+ −
·
x y
vy xu j
e y x f v u F
) (
) , ( ) , (
dudv e v u F y x f
vy xu j
u v
) (
2
) , (
) 2 (
1
) , (
+
− · − ·
∫ ∫
·
π
π
π
π
π
F u v ( , )
is again a complex-valued function of two real frequency variables
u v ,
and it is periodic
with a period 2 2 π π × , that is to say
F u v F u v F u v ( , ) ( , ) ( , ) · + · + 2 2 π π
The Fourier transform of
f x y ( , )
is said to converge uniformly when
F u v ( , )
is finite and
) , ( ) , ( lim lim
1
1
2
2
2 1
) (
v u F e y x f
N
N x
N
N y
vy xu j
N N
·
∑ ∑
− · − ·
+ −
∞ → ∞ →
for all
u v ,
.
When the Fourier transform of
f x y ( , )
converges uniformly,
F u v ( , )
is an analytic function and
is infinitely differentiable with respect to u and v .
2.3 Discrete space and discrete frequency: The two dimensional Discrete Fourier
Transform (2-D DFT)
If
f x y ( , )
is an N M × array, such as that obtained by sampling a continuous function of two
dimensions at dimensions N M and on a rectangular grid, then its two dimensional Discrete
Fourier transform (DFT) is the array given by
∑ ∑

·

·
+ −
·
1
0
1
0
) / / ( 2
) , (
1
) , (
M
x
N
y
N vy M ux j
e y x f
MN
v u F
π
1 , , 0 − · M u  , 1 , , 0 − · N v 
and the inverse DFT (IDFT) is
f x y F u v e
j ux M vy N
v
N
u
M
( , ) ( , )
( / / )
·
+
·

·

∑ ∑
2
0
1
0
1
π
When images are sampled in a square array, M N · and
F u v
N
f x y e
j ux vy N
y
N
x
N
( , ) ( , )
( )/
·
− +
·

·

∑ ∑
1
2
0
1
0
1
π
f x y
N
F u v e
j ux vy N
v
N
u
N
( , ) ( , )
( )/
·
+
·

·

∑ ∑
1
2
0
1
0
1
π
It is straightforward to prove that the two dimensional Discrete Fourier Transform is separable,
symmetric and unitary.
2.3.1 Properties of the 2-D DFT
Most of them are straightforward extensions of the properties of the 1-D Fourier Transform. Advise
any introductory book on Image Processing.
4
2.3.2 The importance of the phase in 2-D DFT. Image reconstruction from amplitude or
phase only.
The Fourier transform of a sequence is, in general, complex-valued, and the unique representation of
a sequence in the Fourier transform domain requires both the phase and the magnitude of the Fourier
transform. In various contexts it is often desirable to reconstruct a signal from only partial domain
information. Consider a 2-D sequence
) , ( y x f
with Fourier transform { ¦ ) , ( ) , ( y x f v u F ℑ · so
that
) , (
) , ( } , ( { ) , (
v u j
f
e v u F y x f v u F
φ
· ℑ ·
It has been observed that a straightforward signal synthesis from the Fourier transform phase
) , ( v u
f
φ
alone, often captures most of the intelligibility of the original image
) , ( y x f
(why?).
A straightforward synthesis from the Fourier transform magnitude
) , ( v u F
alone, however, does
not generally capture the original signal’s intelligibility. The above observation is valid for a large
number of signals (or images). To illustrate this, we can synthesise the phase-only signal
) , ( y x f
p
and the magnitude-only signal ) , ( y x f
m
by
[ ]
) , (
1
1 ) , (
v u j
p
f
e y x f
φ

ℑ ·
[ ]
0 1
) , ( ) , (
j
m
e v u F y x f

ℑ ·
and observe the two results (Try this exercise in MATLAB).
An experiment which more dramatically illustrates the observation that phase-only signal synthesis
captures more of the signal intelligibility than magnitude-only synthesis, can be performed as
follows.
Consider two images
) , ( y x f
and
) , ( y x g
. From these two images, we synthesise two other
images
) , (
1
y x f
and ) , (
1
y x g by mixing the amplitudes and phases of the original images as
follows:
[ ]
) , (
1
1
) , ( ) , (
v u j
f
e v u G y x f
φ

ℑ ·
[ ]
) , (
1
1
) , ( ) , (
v u j
g
e v u F y x g
φ

ℑ ·
In this experiment
) , (
1
y x f
captures the intelligibility of
) , ( y x f
, while ) , (
1
y x g captures the
intelligibility of
) , ( y x g
(Try this exercise in MATLAB).
3. THE DISCRETE COSINE TRANSFORM (DCT)
3.1 One dimensional signals
This is a transform that is similar to the Fourier transform in the sense that the new independent
variable represents again frequency. The DCT is defined below.

·
]
]
]

+
·
1
0 2
) 1 2 (
cos ) ( ) ( ) (
N
x N
u x
x f u a u C
π
, 1 , , 1 , 0 − · N u 
with
) (u a
a parameter that is defined below.
¹
¹
¹
'
¹
− ·
·
·
1 , , 1 / 2
0 / 1
) (
N u N
u N
u a

The inverse DCT (IDCT) is defined below.

·
]
]
]

+
·
1
0 2
) 1 2 (
cos ) ( ) ( ) (
N
u N
u x
u C u a x f
π
3.2 Two dimensional signals (images)
5
For 2-D signals it is defined as
]
]
]

+
]
]
]

+
·
∑ ∑

·

· N
v y
N
u x
y x f v a u a v u C
N
x
N
y 2
) 1 2 (
cos
2
) 1 2 (
cos ) , ( ) ( ) ( ) , (
1
0
1
0
π π
]
]
]

+
]
]
]

+
·
∑ ∑

·

· N
v y
N
u x
v u C v a u a y x f
N
u
N
v 2
) 1 2 (
cos
2
) 1 2 (
cos ) , ( ) ( ) ( ) , (
1
0
1
0
π π
) (u a
is defined as above and 1 , , 1 , 0 , − · N v u 
3.3 Properties of the DCT transform
 The DCT is a real transform. This property makes it attractive in comparison to the Fourier
transform.
 The DCT has excellent energy compaction properties. For that reason it is widely used in
image compression standards (as for example JPEG standards).
 There are fast algorithms to compute the DCT, similar to the FFT for computing the DFT.
4. WALSH TRANSFORM (WT)
4.1 One dimensional signals
This transform is slightly different from the transforms you have met so far. Suppose we have a
function
1 , , 0 ), ( − · N x x f 
where
n
N 2 ·
and its Walsh transform
) (u W
.
If we use binary representation for the values of the independent variables
x
and
u
we need
n

bits to represent them. Hence, for the binary representation of
x
and
u
we can write:
( )
2 0 2 1 10
) ( ) ( ) ( ) ( x b x b x b x
n n

− −
·
,
( )
2 0 2 1 10
) ( ) ( ) ( ) ( u b u b u b u
n n

− −
·
with 1 or 0 ) (x b
i
for 1 , , 0 − · n i  .
Example
If
samples) 8 ( , 7 , , 0 ), (  · x x f
then 3 · n and for 6 · x ,
0 ) 6 ( , 1 ) 6 ( , 1 ) 6 ( (110) = 6
0 1 2 2
· · · ⇒ b b b
We define now the 1-D Walsh transform as
∑ ∏

·

·
]
]
]

− ·
− −
1
0
1
0
) ( ) (
1
) 1 ( ) (
1
) (
N
x
n
i
u b x b
i n i
x f
N
u W or

·
− −

·

− ·
1
0
) ( ) (
1
1
0
) 1 )( (
1
) (
N
x
u b x b
i n
n
i
i
x f
N
u W
The array formed by the Walsh kernels is again a symmetric matrix having orthogonal rows and
columns. Therefore, the Walsh transform is and its elements are of the form

·
− −
− ·
1
0
) ( ) (
1
) 1 ( ) , (
n
i
u b x b
i n i
x u T . You can immediately observe that
0 ) , ( · x u T
or 1 depending
on the values of ) (x b
i
and ) (
1
u b
i n − −
. If the Walsh transform is written in a matrix form
f T W ⋅ ·
the rows of the matrix T which are the vectors [ ] ) 1 , ( ) 1 , ( ) 0 , ( − N u T u T u T  have the form
of square waves. As the variable
u
(which represents the index of the transform) increases, the
corresponding square wave’s “frequency” increases as well. For example for 0 · u we see that
( ) ( )
2 2 0 2 1 10
0 00 ) ( ) ( ) ( ) (   · ·
− −
u b u b u b u
n n
and hence, 0 ) (
1
·
− −
u b
i n
, for any i . Thus,
6
1 ) , 0 ( · x T
and ∑

·
·
1
0
) (
1
) 0 (
N
x
x f
N
W . We see that the first element of the Walsh transform in
the mean of the original function
) (x f
(the DC value) as it is the case with the Fourier transform.
The inverse Walsh transform is defined as follows.
∑ ∏

·

·
]
]
]

− ·
− −
1
0
1
0
) ( ) (
1
) 1 ( ) ( ) (
N
u
n
i
u b x b
i n i
u W x f or

·
− −

·

− ·
1
0
) ( ) (
1
1
0
) 1 )( ( ) (
N
u
u b x b
i n
n
i
i
u W x f
4.2 Two dimensional signals
The Walsh transform is defined as follows for two dimensional signals.
∑ ∏ ∑

·

·
+

·
]
]
]

− ·
− − − −
1
0
1
0
)) ( ) ( ) ( ) ( (
1
0
1 1
) 1 ( ) , (
1
) , (
N
x
n
i
v b y b u b x b
N
y
i n i i n i
y x f
N
v u W or
∑ ∑

·
+

·
− − − −

·

− ·
1
0
)) ( ) ( ) ( ) ( (
1
0
1 1
1
0
) 1 )( , (
1
) , (
N
x
v b y b u b x b
N
y
i n i i n i
n
i
y x f
N
v u W
The inverse Walsh transform is defined as follows for two dimensional signals.
∑ ∏ ∑

·

·
+

·
]
]
]

− ·
− − − −
1
0
1
0
)) ( ) ( ) ( ) ( (
1
0
1 1
) 1 ( ) , (
1
) , (
N
u
n
i
v b y b u b x b
N
v
i n i i n i
v u W
N
y x f or
∑ ∑

·
+

·
− − − −

·

− ·
1
0
)) ( ) ( ) ( ) ( (
1
0
1 1
1
0
) 1 ( ) , (
1
) , (
N
u
v b y b u b x b
N
v
i n i i n i
n
i
v u W
N
y x f
4.3 Properties of the Walsh Transform
 Unlike the Fourier transform, which is based on trigonometric terms, the Walsh transform
consists of a series expansion of basis functions whose values are only 1 − or 1 and they have
the form of square waves. These functions can be implemented more efficiently in a digital
environment than the exponential basis functions of the Fourier transform.
 The forward and inverse Walsh kernels are identical except for a constant multiplicative
factor of
N
1
for 1-D signals.
 The forward and inverse Walsh kernels are identical for 2-D signals. This is because the array
formed by the kernels is a symmetric matrix having orthogonal rows and columns, so its inverse
array is the same as the array itself.
 The concept of frequency exists also in Walsh transform basis functions. We can think of
frequency as the number of zero crossings or the number of transitions in a basis vector and we
call this number sequency. The Walsh transform exhibits the property of energy compaction as
all the transforms that we are currently studying. (why?)
 For the fast computation of the Walsh transform there exists an algorithm called Fast Walsh
Transform (FWT). This is a straightforward modification of the FFT. Advise any introductory
5.1 Definition
7
In a similar form as the Walsh transform, the 2-D Hadamard transform is defined as follows.
Forward
∑ ∏ ∑

·

·
+

·
]
]
]

− ·
1
0
1
0
)) ( ) ( ) ( ) ( (
1
0
) 1 ( ) , (
1
) , (
N
x
n
i
v b y b u b x b
N
y
i i i i
y x f
N
v u H ,
n
N 2 ·
or
∑ ∑

·
+

·

·
− ·
1
0
)) ( ) ( ) ( ) ( (
1
0
1
0
) 1 )( , (
1
) , (
N
x
v b y b u b x b
N
y
i i i i
n
i
y x f
N
v u H
Inverse
∑ ∏ ∑

·

·
+

·
]
]
]

− ·
1
0
1
0
)) ( ) ( ) ( ) ( (
1
0
) 1 ( ) , (
1
) , (
N
u
n
i
v b y b u b x b
N
v
i i i i
v u H
N
y x f etc.
5.2 Properties of the Hadamard Transform
 Most of the comments made for Walsh transform are valid here.
 The Hadamard transform differs from the Walsh transform only in the order of basis functions.
The order of basis functions of the Hadamard transform does not allow the fast computation of it
by using a straightforward modification of the FFT. An extended version of the Hadamard
transform is the Ordered Hadamard Transform for which a fast algorithm called Fast
Hadamard Transform (FHT) can be applied.
 An important property of Hadamard transform is that, letting
N
H represent the matrix of order
N , the recursive relationship is given by the expression
]
]
]

·
N N
N N
N
H H
H H
H
2
6. KARHUNEN-LOEVE (KLT) or HOTELLING TRANSFORM
The Karhunen-Loeve Transform or KLT was originally introduced as a series expansion for
continuous random processes by Karhunen and Loeve. For discrete signals Hotelling first studied
what was called a method of principal components, which is the discrete equivalent of the KL series
expansion. Consequently, the KL transform is also called the Hotelling transform or the method of
principal components. The term KLT is the most widely used.
6.1 The case of many realisations of a signal or image (Gonzalez/Woods)
The concepts of eigenvalue and eigevector are necessary to understand the KL transform.
If
C
is a matrix of dimension n n × , then a scalar λ is called an eigenvalue of
C
if there is a
nonzero vector
e
in
n
R
such that
e e C λ ·
The vector
e
is called an eigenvector of the matrix
C
corresponding to the eigenvalue λ.
(If you have difficulties with the above concepts consult any elementary linear algebra book.)
Consider a population of random vectors of the form
8
]
]
]
]
]
]

·
n
x
x
x
x

2
1
The mean vector of the population is defined as
{ ¦ x E m
x
·
The operator E refers to the expected value of the population calculated theoretically using the
probability density functions (pdf) of the elements
i
x and the joint probability density functions
between the elements
i
x and j
x
.
The covariance matrix of the population is defined as
{ ¦
T
x x x
m x m x E C ) )( ( − − ·
Because
x
is
n
-dimensional,
x
C and
T
x x
m x m x ) )( ( − − are matrices of order n n × . The
element
ii
c of
x
C is the variance of
i
x , and the element ij
c
of
x
C is the covariance between
the elements
i
x and j
x
. If the elements
i
x and j
x
are uncorrelated, their covariance is zero and,
therefore,
0 · ·
ji ij
c c
.
For M vectors from a random population, where M is large enough, the mean vector and
covariance matrix can be approximately calculated from the vectors by using the following
relationships where all the expected values are approximated by summations

·
·
M
k
k x
x
M
m
1
1
T
x x
T
k
M
k
k x
m m x x
M
C − ·

·1
1
Very easily it can be seen that
x
C is real and symmetric. In that case a set of
n
orthonormal (at
this point you are familiar with that term) eigenvectors always exists. Let
i
e and
i
λ,
n i , , 2 , 1  · , be this set of eigenvectors and corresponding eigenvalues of
x
C , arranged in
descending order so that
1 +

i i
λ λ for 1 , , 2 , 1 − · n i  . Let A be a matrix whose rows are
formed from the eigenvectors of
x
C , ordered so that the first row of A is the eigenvector
corresponding to the largest eigenvalue, and the last row the eigenvector corresponding to the
smallest eigenvalue.
Suppose that A is a transformation matrix that maps the vectors
s x'
into vectors
s y'
by using
the following transformation
) (
x
m x A y − ·
The above transform is called the Karhunen-Loeve or Hotelling transform. The mean of the
y

vectors resulting from the above transformation is zero (try to prove that)
0 ·
y
m
the covariance matrix is (try to prove that)
T
x y
A C A C ·
and y
C
is a diagonal matrix whose elements along the main diagonal are the eigenvalues of
x
C
(try to prove that)
]
]
]
]
]
]

·
n
y
C
λ
λ
λ
0
0
2
1

9
The off-diagonal elements of the covariance matrix are 0 , so the elements of the
y
vectors are
uncorrelated.
Lets try to reconstruct any of the original vectors
x
from its corresponding
y
. Because the rows of
A
are orthonormal vectors (why?), then
T
A A ·
−1
, and any vector
x
can by recovered from its
corresponding vector
y
by using the relation
x
T
m y A x + ·
Suppose that instead of using all the eigenvectors of
x
C we form matrix
K
A from the K
eigenvectors corresponding to the K largest eigenvalues, yielding a transformation matrix of order
n K × . The
y
vectors would then be K dimensional, and the reconstruction of any of the original
vectors would be approximated by the following relationship
x
T
K
m y A x + · ˆ
The mean square error between the perfect reconstruction
x
and the approximate reconstruction

is given by the expression
∑ ∑ ∑
+ · · ·
· − ·
n
K j
j
K
j
j
n
j
j ms
e
1 1 1
λ λ λ
.
By using
K
A
for the KL transform we achieve compression of the available data.
6.2 The case of one realisation of a signal or image
The derivation of the KLT for the case of one image realisation assumes that the two dimensional
signal (image) is ergodic. This assumption allows us to calculate the statistics of the image using
only one realisation. Usually we divide the image into blocks and we apply the KLT in each block.
This is reasonable because the 2-D field is likely to be ergodic within a small block since the nature
of the signal changes within the whole image. Let’s suppose that
f
is a vector obtained by
lexicographic ordering of the pixels
) , ( y x f
within a block of size M M × (placing the rows of
the block sequentially).
The mean vector of the random field inside the block is a scalar that is estimated by the approximate
relationship

·
·
2
1
2
) (
1
M
k
f
k f
M
m
and the covariance matrix of the 2-D random field inside the block is
f
C
where
2
1
2
) ( ) (
1
2
f
M
k
ii
m k f k f
M
c − ·

·
and
2
1
2
) ( ) (
1
2
f
M
k
j i ij
m j i k f k f
M
c c − − + · ·

·

After knowing how to calculate the matrix f
C
, the KLT for the case of a single realisation is the
same as described above.
6.3 Properties of the Karhunen-Loeve transform
Despite its favourable theoretical properties, the KLT is not used in practice for the following
reasons.
 Its basis functions depend on the covariance matrix of the image, and hence they have to
recomputed and transmitted for every image.
 Perfect decorrelation is not possible, since images can rarely be modelled as realisations of
ergodic fields.
 There are no fast computational algorithms for its implementation.
10
REFERENCES
[1] Digital Image Processing by R. C. Gonzales and R. E. Woods, Addison-Wesley Publishing
Company, 1992.
[2] Two-Dimensional Signal and Image Processing by J. S. Lim, Prentice Hall, 1990.
11

that is. y ) the forward and inverse transforms are given below g (u . N −1) N −1 u =0 The columns of T . x. In that case −1 ∗T f =T ∗T ∗T ⋅ g ⇒ f ( x ) = ∑ T ∗ (u . y ) 2 . 0 ≤ u ≤ N − 1 x=0 N −1 where g (u ) is the transform (or transformation) of f ( x ) . and T (u .2 [ ∗ ] T are called the Two dimensional signals (images) As a one dimensional signal can be represented by an orthonormal set of basis vectors. y ) f ( x. y ) It is said to be symmetric if T1 is functionally equal to T2 such that T (u . x )T1 (v. x. x. 1. y ) = T1 (u . 1.0) T ∗ (u . y ) x =0 y =0 N −1 N −1 f ( x. v. v.1 For a UNITARY TRANSFORMS One dimensional signals one dimensional as a vector T sequence { f ( x ). Two dimensional transforms are applied to image enhancement. form a complete set of basis vectors in the N − dimensional vector space. again. y . v) u =0 v =0 N −1 N −1 where. v ) g (u . a transformation may be written as g = T ⋅ f ⇒ g (u ) = ∑ T (u . encoding and description. u ) is the so called inverse transformation kernel.Transform theory plays a fundamental role in image processing. x ) is the so called forward transformation kernel. It can be proven the matrix (how?) that the columns (or rows) of an N × N unitary matrix are orthonormal and therefore. 1. u ) g (u ). If I =T =T T is called unitary. Similarly. x )T2 (v. y ) and I ( x. and the transformation is called unitary as well. v ) are called the forward and inverse transformation kernels. v.1)  T ∗ (u . u . y ) =T1 (u . respectively. x) f ( x). The forward kernel is said to be separable if T (u . v) = ∑ ∑T (u . u . 0 ≤ x ≤ N −1 u =0 N −1 or written in a matrix form f =I ⋅ g = − ⋅ g T 1 where I ( x. the vectors basis vectors of T . For an N × N image f ( x . x. the inverse transform is the relation f ( x) = ∑ I ( x. y ) = ∑ ∑ I ( x. 0 ≤ x ≤ N −1} represented f =[ f (0) f (1)  f ( N −1) ] of size N . y. v. restoration. as working with the transform of an image instead of the image itself may give us more insight into the properties of the image. T (u . x ) g (u ) T∗ u = T (u . an image can also be expanded in terms of a discrete set of basis arrays called basis images through a two dimensional (image) transform.

1 THE TWO DIMENSIONAL FOURIER TRANSFORM Continuous space and continuous frequency The Fourier transform is extended to a function f ( x . v ) is integrable.The same comments are valid for the inverse kernel. a unitary transformation preserves the signal energy. v and hence. then the transform g (u .3. v ) 3 .3. y ) can be written x =0 y =0 x =0 y =0 N −1 N −1 N −1 N −1 in matrix form as follows g = T 1 ⋅ f ⋅ T 1T where f is the original image of size N × N . v. x. y ) = ∑ ∑ g ( u. v. in addition. T 1 is a unitary matrix then the transform is called separable unitary and the original image is recovered through the relationship ∗T ∗ f = T1 ⋅ g ⋅ T1 1. v ) u =0 v =0 2 N −1 N −1 2 1. y ) = 1 ( 2π ) 2 ∞ ∫ ∫ F (u . y ) f ( x. If f ( x .1 The property of energy preservation In the unitary transformation g = ⋅f T T it is easily proven (try the proof by using the relation T −1 = T ∗ ) that g 2 =f 2 Thus. v)e −∞ j 2π ( ux +vy ) dudv In general F ( u. y ) of an image transform is separable and symmetric. v ) + jI (u . If the kernel T (u . j ) . This property is called energy preservation property. x. the following Fourier transform pair exists: F (u . it can be written as: F (u . y ) of two variables. This property is very useful for compression purposes. v ) = ∫ ∫ f ( x. 2. For the 2-D case the energy preservation property is written as N −1 N −1 x =0 y =0 ∑ ∑ f ( x .2 The property of energy compaction Most unitary transforms pack a large fraction of the energy of the image into relatively few of the transform coefficients. v ) = R (u . y ) is continuous and integrable and F ( u. v ) is a complex-valued function of two real frequency variables u. This means that every unitary transformation is simply a rotation of the vector f in the N dimensional vector space. y ) = ∑ ∑T1 (u . y )e − j 2π ( ux +vy ) dxdy −∞ ∞ f ( x. and T 1 is an N × N transformation matrix with elements tij =T1 (i . v ) = ∑ ∑T (u . If. x )T1 (v. y ) f ( x.3 Fundamental properties of unitary transforms 1. This means that relatively few of the transform coefficients have significant values and these are the coefficients that are close to the origin (small index coefficients). (Why?) 2.

v = 0. v ) = R 2 ( u. v ) = F ( u + 2π. v ) +I 2 ( u. y )e N x =0 y =0 1 N −1 N −1 j 2π ( ux + vy )/ N f ( x. y ) = ∑ ∑ F ( u. F ( u. v) = and the inverse DFT (IDFT) is 1 M −1 N −1 ∑ ∑ f ( x. Advise any introductory book on Image Processing.  . symmetric and unitary.1 Properties of the 2-D DFT Most of them are straightforward extensions of the properties of the 1-D Fourier Transform. y )e − j ( xu +vy ) x =− y =− ∞ ∞ ∞ ∞ f ( x. v ) +I 2 ( u. v ) is an analytic function and is infinitely differentiable with respect to u and v . v )e j ( xu +vy ) dudv lim lim ∑ N1 ∑ f ( x . v ) = F ( u. F ( u. When the Fourier transform of f ( x . such as that obtained by sampling a continuous function of two dimensions at dimensions M and N on a rectangular grid.3 Discrete space and discrete frequency: The two dimensional Discrete Fourier Transform (2-D DFT) If f ( x . 2. N −1 f ( x . y ) converges uniformly. v ) is finite and N1 →∞ N 2 →∞ x = − N y = − N 1 2 u =−π v =−π ∫ π ∫ F (u. 2. y ) is an M × N array.2 Discrete space and continuous frequency For the case of a discrete sequence f ( x . v + 2π) The Fourier transform of f ( x . v ) for all u.  . 4 . v )e j 2π ( ux / M + vy / N ) When images are sampled in a square array. v ) = ∑ ∑ f ( x . that is to say F ( u. M −1 . M = N and F ( u. v ) −  I (u . phase spectrum and power spectrum. y )e N2 − j ( xu + vy ) = F (u. v )   = R 2 ( u. v . v ) = tan P( u. v ) = F ( u. v )e N u =0 v = 0 It is straightforward to prove that the two dimensional Discrete Fourier Transform is separable.The amplitude spectrum.3. v ) 2    R (u . v ) 1 φ(u . y ) is said to converge uniformly when F ( u. y )e − j 2π (ux / M +vy / N ) MN x =0 y =0 M −1 N −1 u=0 v =0 u = 0. y ) = 1 ( 2π ) 2 π F ( u. v ) is again a complex-valued function of two real frequency variables u. respectively. v ) 2. y ) of infinite duration we can define the 2-D discrete space Fourier transform pair as follows F (u. v ) = 1 N −1 N −1 − j 2π ( ux + vy )/ N ∑ ∑ f ( x . y ) = ∑ ∑ F ( u. v and it is periodic with a period 2π × 2π . are defined as follows. then its two dimensional Discrete Fourier transform (DFT) is the array given by F (u .

N −1  ( 2 x +1)uπ  f ( x) = ∑ a (u )C (u ) cos   2N u =0   3. Consider two images f ( x . Consider a 2-D sequence f ( x . To illustrate this. v) e { jφ f ( u . v ) alone.  1/ N  a (u ) =   2/ N  u =0 u =1. A straightforward synthesis from the Fourier transform magnitude F (u . y ) and g 1 ( x. v ) jφg ( u . y ) = ℑ−1 G (u . does not generally capture the original signal’s intelligibility. y ) = ℑ 1 F (u .2 Two dimensional signals (images) 5 . y ) and g ( x. y} = F (u . The DCT is defined below. In various contexts it is often desirable to reconstruct a signal from only partial domain { information. y )} so that F (u .  .1. y ) (why?). y ) captures the intelligibility of g ( x. y ) = ℑ 1 1e − f m ( x. y ) (Try this exercise in MATLAB). and the unique representation of a sequence in the Fourier transform domain requires both the phase and the magnitude of the Fourier transform. v ) It has been observed that a straightforward signal synthesis from the Fourier transform phase φf (u . v ) e jφ f ( u . From these two images. . The above observation is valid for a large number of signals (or images). we synthesise two other images f 1 ( x. N −1 The inverse DCT (IDCT) is defined below. y ) by − f p ( x.1 THE DISCRETE COSINE TRANSFORM (DCT) One dimensional signals This is a transform that is similar to the Fourier transform in the sense that the new independent variable represents again frequency. v ) ] ] In this experiment f 1 ( x. 3. in general. we can synthesise the phase-only signal f p ( x. v) e g1 ( x. v ) alone. complex-valued. u = 0. often captures most of the intelligibility of the original image f ( x . Image reconstruction from amplitude or phase only. An experiment which more dramatically illustrates the observation that phase-only signal synthesis captures more of the signal intelligibility than magnitude-only synthesis. y ) . v ) ] ] f1 ( x. y ) . v ) = ℑ f ( x. y ) and the magnitude-only signal f m ( x. y ) with Fourier transform F (u. y ) captures the intelligibility of f ( x . y ) = ℑ−1 [ [ F (u .2. while g 1 ( x. however.3. The Fourier transform of a sequence is. N −1 2N x =0   with a (u ) a parameter that is defined below. 3. v ) e j 0 and observe the two results (Try this exercise in MATLAB). v) = ℑ f ( x.2 The importance of the phase in 2-D DFT. y ) by mixing the amplitudes and phases of the original images as follows: [ [ jφ f ( u . N −1  (2 x +1)uπ  C (u ) = a (u ) ∑ f ( x) cos   . can be performed as follows.

W (u ) = 1 N −1 n −1 b ( x )b (u )  ∑ f ( x ) ∏ (−1) i n −1−i  or N x =0 i =0  1 ∑ f ( x )( −1) i =0 N x =0 N −1 W (u ) = ∑bi ( x )bn −1−i ( u ) n −1 The array formed by the Walsh kernels is again a symmetric matrix having orthogonal rows and columns. Suppose we have a function f ( x ).1 WALSH TRANSFORM (WT) One dimensional signals This transform is slightly different from the transforms you have met so far. (8 sam ples) If 6 = (110) 2 ⇒ b2 (6) = 1. x = 0. 4.1. v) cos   cos   2N 2N u =0 v =0     a (u ) is defined as above and u .For 2-D signals it is defined as N −1 N −1  ( 2 x +1)uπ   ( 2 y +1)vπ  C (u . Hence. y ) cos   cos   2N 2N x =0 y =0     N −1 N −1  (2 x +1)uπ   (2 y +1)vπ  f ( x. b0 (6) = 0 We define now the 1-D Walsh transform as then n =3 and for x =6 . Example f ( x ). the Walsh transform is and its elements are of the form T (u . N −1)] have the form of square waves. As the variable u (which represents the index of the transform) increases. This property makes it attractive in comparison to the Fourier transform. If we use binary representation for the values of the independent variables x and u we need n bits to represent them. for any i . W = ⋅f T 6 . (u )10 = ( bn −1 (u )bn −2 (u )  b0 (u ) ) 2 with bi (x ) 0 or 1 for i = 0. n −1 . x = 0. y ) = ∑ ∑ a(u )a (v)C (u .  .3  Properties of the DCT transform The DCT is a real transform.  The DCT has excellent energy compaction properties. x ) = ∏(−1)bi ( x ) bn−1−i (u ) .0) T (u . N −1 where N = 2 n and its Walsh transform W (u ) .1)  T (u . b1 (6) = 1. bn −1−i (u ) = 0 . Thus.  . For example for u = 0 we see that (u )10 = ( bn −1 (u )bn −2 (u )  b0 (u ) ) 2 = ( 00  0 ) 2 and hence. x) =0 or 1 depending i =0 n −1 on the values of bi ( x ) and bn −1−i (u ) . similar to the FFT for computing the DFT.  .  There are fast algorithms to compute the DCT. 4. for the binary representation of x and u we can write: ( x )10 = ( bn −1 ( x )bn −2 ( x)  b0 ( x ) ) 2 . v = 0. For that reason it is widely used in image compression standards (as for example JPEG standards). v) = a (u ) a (v ) ∑ ∑ f ( x. . the corresponding square wave’s “frequency” increases as well. You can immediately observe that T (u .7. N −1 3. Therefore. If the Walsh transform is written in a matrix form the rows of the matrix T which are the vectors [T (u .

We can think of frequency as the number of zero crossings or the number of transitions in a basis vector and we call this number sequency. the Walsh transform consists of a series expansion of basis functions whose values are only −1 or 1 and they have the form of square waves.  The forward and inverse Walsh kernels are identical except for a constant multiplicative 1 factor of for 1-D signals. This is a straightforward modification of the FFT. y ) = ∑ ∑W (u. N −1 n −1  f ( x ) = ∑W (u ) ∏ ( −1) bi ( x )bn −1−i (u )  or u =0 i =0  ∑bi ( x ) bn −1−i ( u ) f ( x) = ∑W (u )( −1) i =0 N −1 u =0 n −1 4. so its inverse array is the same as the array itself. which is based on trigonometric terms. v ) = 1 N −1 N −1 n −1  f ( x. We see that the first element of the Walsh transform in N x =0 the mean of the original function f ( x ) (the DC value) as it is the case with the Fourier transform. N  The forward and inverse Walsh kernels are identical for 2-D signals. (why?) For the fast computation of the Walsh transform there exists an algorithm called Fast Walsh Transform (FWT).T (0. f ( x. y ) = 1 N −1 N −1 n −1 (b ( x )b ( u ) +bi ( y ) bn −1−i ( v ))  ∑ ∑W (u.1 HADAMARD TRANSFORM (HT) Definition 7 . y ) ∏( −1) ( bi ( x ) bn−1−i ( u ) +bi ( y ) bn−1−i ( v ))  or ∑ ∑ N x =0 y =0 i =0  n −1 ∑(bi ( x ) bn −1−i ( u ) +bi ( y ) bn −1−i ( v )) 1 N −1 N −1 W (u. The Walsh transform exhibits the property of energy compaction as all the transforms that we are currently studying.   5.3  Properties of the Walsh Transform Unlike the Fourier transform. 5. The inverse Walsh transform is defined as follows. v ) ∏( −1) i n−1−i  or N u =0 v =0 i =0  n −1 ∑(bi ( x ) bn −1−i ( u ) +bi ( y ) bn −1−i ( v )) 1 N −1 N −1 f ( x. x ) =1 and W ( 0) = 1 N −1 ∑ f ( x ) . v ) = ∑ ∑ f ( x.2 Two dimensional signals The Walsh transform is defined as follows for two dimensional signals. These functions can be implemented more efficiently in a digital environment than the exponential basis functions of the Fourier transform. This is because the array formed by the kernels is a symmetric matrix having orthogonal rows and columns. The concept of frequency exists also in Walsh transform basis functions. Advise any introductory book for your own interest. y )( −1) i =0 N x =0 y =0 The inverse Walsh transform is defined as follows for two dimensional signals. v )( −1) i=0 N u =0 v =0 4. W (u.

y ) = 5.In a similar form as the Walsh transform. letting H N represent the matrix of order N . the KL transform is also called the Hotelling transform or the method of principal components. v ) = 1 N −1 N −1 n −1 ( b ( x ) b ( u ) +bi ( y ) bi ( v ))  n ∑ ∑ f ( x.) Consider a population of random vectors of the form C e =λ e 8 . v ) ∏ ( −1) i i  etc. The Hadamard transform differs from the Walsh transform only in the order of basis functions. then a scalar λ is called an eigenvalue of C if there is a nonzero vector e in R n such that The vector e is called an eigenvector of the matrix C corresponding to the eigenvalue λ . Forward H ( u. the 2-D Hadamard transform is defined as follows. y ) ∏ ( −1) i i  . An extended version of the Hadamard transform is the Ordered Hadamard Transform for which a fast algorithm called Fast Hadamard Transform (FHT) can be applied. y )( −1) i =0 N x =0 y =0 Inverse f ( x. v ) = ∑ ∑ f ( x. which is the discrete equivalent of the KL series expansion.2   1 N −1 N −1 n −1 ( b ( x ) b ( u ) +bi ( y ) bi ( v ))  ∑ ∑ H (u. If C is a matrix of dimension n × n . For discrete signals Hotelling first studied what was called a method of principal components.1 The case of many realisations of a signal or image (Gonzalez/Woods) The concepts of eigenvalue and eigevector are necessary to understand the KL transform. An important property of Hadamard transform is that. The term KLT is the most widely used. N u =0 v =0 i =0  Properties of the Hadamard Transform Most of the comments made for Walsh transform are valid here. (If you have difficulties with the above concepts consult any elementary linear algebra book. The order of basis functions of the Hadamard transform does not allow the fast computation of it by using a straightforward modification of the FFT. KARHUNEN-LOEVE (KLT) or HOTELLING TRANSFORM The Karhunen-Loeve Transform or KLT was originally introduced as a series expansion for continuous random processes by Karhunen and Loeve. the recursive relationship is given by the expression  H H 2N =  N H N HN  − HN   6. 6. N = 2 or N x =0 y =0 i =0  n −1 ∑(bi ( x ) bi ( u ) +bi ( y ) bi ( v )) 1 N −1 N −1 H ( u. Consequently.

 x1  x  x =  2      xn  The mean vector of the population is defined as m x = E { x} The operator E refers to the expected value of the population calculated theoretically using the probability density functions (pdf) of the elements x i and the joint probability density functions between the elements xi and x j . their covariance is zero and. therefore. In that case a set of n orthonormal (at this point you are familiar with that term) eigenvectors always exists. C x and ( x − m x )( x − m x )T are matrices of order n × n .2. ordered so that the first row of A is the eigenvector corresponding to the largest eigenvalue. The element cii of C x is the variance of x i . and the last row the eigenvector corresponding to the smallest eigenvalue. . the mean vector and covariance matrix can be approximately calculated from the vectors by using the following relationships where all the expected values are approximated by summations C x = E ( x − m x )( x − m x )T { } mx = Cx = 1 M ∑ xk M k =1 1 M T T ∑ xk xk − m x m x M k =1 Very easily it can be seen that C x is real and symmetric. cij = c ji = 0 . i i =1. The mean of the vectors resulting from the above transformation is zero (try to prove that) m y =0 y the covariance matrix is (try to prove that) C y = AC x A T and C y is a diagonal matrix whose elements along the main diagonal are the eigenvalues of C x (try to prove that) λ1  Cy =    0 λ2  0     λn  9 . Let A be a matrix whose rows are formed from the eigenvectors of C x . where M is large enough. n . arranged in descending order so that λi ≥ λi +1 for i =1. For M vectors from a random population. be this set of eigenvectors and corresponding eigenvalues of C x .2. Let e i and λ . and the element cij of C x is the covariance between the elements x i and x j . The covariance matrix of the population is defined as Because x is n -dimensional. n −1 . . If the elements x i and x j are uncorrelated. Suppose that A is a transformation matrix that maps the vectors x' s into vectors y' s by using the following transformation y = A( x −m x ) The above transform is called the Karhunen-Loeve or Hotelling transform.

since images can rarely be modelled as realisations of ergodic fields. y ) within a block of size M × M (placing the rows of the block sequentially). so the elements of the y vectors are uncorrelated. yielding a transformation matrix of order K × n . The mean vector of the random field inside the block is a scalar that is estimated by the approximate relationship 1 M m f = 2 ∑ f (k ) M k =1 and the covariance matrix of the 2-D random field inside the block is C f where 2 1 M cii = 2 ∑ f (k ) f (k ) − m 2 f M k =1 and 2 1 M cij =c i − j = 2 ∑ f (k ) f ( k + i − j ) − m 2 f M k =1 After knowing how to calculate the matrix C f . the KLT for the case of a single realisation is the same as described above.3 Properties of the Karhunen-Loeve transform Despite its favourable theoretical properties. 6.  Perfect decorrelation is not possible. The y vectors would then be K dimensional. and the reconstruction of any of the original vectors would be approximated by the following relationship T ˆ x = AK y + m x ˆ The mean square error between the perfect reconstruction x and the approximate reconstruction x is given by the expression ems = ∑ λ j − ∑ λ j = ∑ λ j . j =1 j =1 j = K +1 n K n By using A K instead of A for the KL transform we achieve compression of the available data.  There are no fast computational algorithms for its implementation.The off-diagonal elements of the covariance matrix are 0 . 10 . Lets try to reconstruct any of the original vectors x from its corresponding y . 2 6. This assumption allows us to calculate the statistics of the image using only one realisation. and hence they have to recomputed and transmitted for every image. Because the rows of A are orthonormal vectors (why?). This is reasonable because the 2-D field is likely to be ergodic within a small block since the nature of the signal changes within the whole image.  Its basis functions depend on the covariance matrix of the image. Usually we divide the image into blocks and we apply the KLT in each block.2 The case of one realisation of a signal or image The derivation of the KLT for the case of one image realisation assumes that the two dimensional signal (image) is ergodic. Let’s suppose that f is a vector obtained by lexicographic ordering of the pixels f ( x. then A −1 = AT . the KLT is not used in practice for the following reasons. and any vector x can by recovered from its corresponding vector y by using the relation x =A y +m x T Suppose that instead of using all the eigenvectors of C x we form matrix A K from the K eigenvectors corresponding to the K largest eigenvalues.

Gonzales and R. 11 . [2] Two-Dimensional Signal and Image Processing by J. 1990. Lim. E. Addison-Wesley Publishing Company. Prentice Hall. Woods. S. 1992. C.REFERENCES [1] Digital Image Processing by R.