You are on page 1of 31

Digital image processing Digital image transforms

4. DIGITAL IMAGE TRANSFORMS


4.1. Introduction
4.2. Unitary orthogonal two-dimensional transforms
Separable unitary transforms
4.3. Properties of the unitary transforms
Energy conservation
Energy compaction; the variance of coefficients
De-correlation
Basis functions and basis images
4.4. Sinusoidal transforms
The 1-D discrete Fourier transform (1-D DFT)
Properties of the 1-D DFT
The 2-D discrete Fourier transform (2-D DFT)
Properties of the 2-D DFT
The discrete cosine transform (DCT)
The discrete sine transform (DST)
The Hartley transform
4.5. Rectangular transforms
The Hadamard transform = the Walsh transform
The Slant transform
The Haar transform
4.6. Eigenvectors-based transforms
The Karhunen-Loeve transform (KLT)
The fast KLT
The SVD
4.7. Image filtering in the transform domain
4.8. Conclusions
Digital image processing Digital image transforms
4.1 INTRODUCTION

Definition: Image transform = operation to change the default representation


space of a digital image (spatial domain -> another domain) so that:
(1) all the information present in the image is preserved in the
transformed domain, but represented differently;
(2) the transform is reversible, i.e., we can revert to the spatial domain

Generally: in the transformed domain -> image information is represented in a


more compact form => main goal of the transforms: image compression.

Other usage: image analysis - a new type of representation of different types


of information present in the image.

Note: Most image transforms = “generalizations” of frequency transforms => the


representation of the image by a DC component and several AC components.

Definition: “original representation space” of the image U[M×N] = a MN-


dimensional space:
- each coordinate of the space = a spatial location (m,n) in the digital
image;
- the value of the coordinate of U on an axis = the grey level in U in this
spatial location (m,n).
x1=(0,0); x2=(0,1); x3=(0,2); ... xMN=(M-1,N-1).

=> A unitary transform of the image U = a rotation of the MN-dimensional space,


defined by a rotation matrix A in MN-dimensions.
x2 x’2
x’2
v2 v2 U
l2=u(0,1)

v1=0 v1 l1=u(0,0) x1

x’1

x’1
Digital image processing Digital image transforms

{u(n), 0  n  N  1} ; A – unitary matrix, A 1  A*T


N 1
v  Au , or v(k)   a(k,n)u(n), 0  k  N  1 (4.1)
n 0
N 1
u  A*T v *
or u(n)   a (k,n)v(k) , 0  n  N  1 (4.2)
k 0
a*k  {a (k,n) , 0  n  N  1 } ,
*

4.2 UNITARY ORTHOGONAL TWO-DIMENSIONAL TRANSFORMS


N 1 N 1
v(k,l)    a k,l (m,n)  u(m,n), 0  k,l  N  1 (4.3)
m 0 n  0
N 1 N 1
u(m,n)    a*k,l (m,n)  v(k,l), 0  k,l  N  1 (4.4)
k 0 l 0

N 1 N 1
 orthonormality: *
  a k ,l (m, n ) a k ',l' (m, n )  (k  k ' , l  l' ) (4.5)
m 0 n 0
N 1 N 1
 completeness: a
k 0 l0
k ,l ( m, n )  a k*,l ( m', n' )   ( m  m', n  n' ) (4.6)
P 1 Q 1
uP,Q (m,n)    a*k,l (m,n)  v(k,l), P  N,Q  N (4.7)
k 0 l 0

N 1 N 1
 2e    [u(m,n)  uP,Q (m,n)] 2 (4.8)
m 0 n  0

 e2  0 if PQ N
Digital image processing Digital image transforms

 Unitary separable transforms

ak ,l ( m, n)  ak ( m) b1 ( n)  a( k , m) b( l , n) (4.9)

where {ak (m),k  0,..., N  1} and {b1(n),l  0,..., N  1} are the


orthonormal sets of basis vectors.

AA*T  AT A*  I, BB*T  BTB*  I (4.10)

N 1 N 1
v(k,l)    a(k,m) u(m,n) a(n, l), or V  AUA T (4.11)
m  0 n 0

N 1 N 1
u(m,n)    a* (k,m) v(k,l) a* (l, n), or U  A*T VA* (4.12)
n 0 l 0

V  A M UA N (4.13)

U  A*T *T
M VA N (4.14)

V  AUA T , V T  A[AU]T (4.15)


Digital image processing Digital image transforms
4.3 PROPERTIES OF UNITARY TRANSFORMS
 Energy conservation

N 1 N 1
v   v(k)  v  v  u A  A  u  u  u   u( n )  u
2 2 *T *T *T *T 2 2
(4.16)
k 0 n 0
N 1 N 1

  u( m, n)    v( k , l )
2 2
(4.17)
m, n  0 k ,l  0

 Energy compaction and the variance of coefficients

 v  E[v ]  E[Au ]  A E[u ]  A u (4.18)

R v  E[( v   v )( v   v )*T ]  A( E[( u   u )( u   u )*T ])A*T  A  R u  A*T (4.19)

 2v ( k )  [R v ]k ,k  [AR u A *T ]k ,k (4.20)
W 1 N 1

 ( k )     v    A  A u    u ( n )
2 *T *T *T 2
v v u (4.21)
k 0 n 0
N 1 N 1


k 0
2
v ( k )  Tr[AR u A *T ]  Tr[R u ]    2u ( n )
n 0
(4.22)

 E v( k )    E u(n) 
N 1 N 1
2 2
(4.23)
k 0 n 0
Digital image processing Digital image transforms

Energy compaction and the variance of coefficients

 v ( k , l )    a( k , m)  a( l , n )   u ( m, n ) (4.24)

 
m n

 v2 (k , l )  E v(k , l )  v (k , l )   a(k , m)a(l , n) r (m, n; m' , n' )  a* (k , m' )a* (l , n' )
2

m n m' n'
(4.25)

r ( m, n; m', n' )  r1 ( m, m' )  r2 ( n, n' )


(4.26)


 2v ( k , l )   12 ( k )   22 ( l )  AR1A *T  AR A 
k ,k 2
*T
l ,l
where R1r1(m,m') and R2r2(n,n').

 Decorrelation

1 3 1  1 
v  u, where R u   ,0    1 ,
2   1 3   1 

 1  3 / 2  / 2 
Rv  
 / 2 1  3 / 2 

E[v ( 0 ) v (1)]  1 1 1 
 v ( 0,1)   , A  
 v ( 0 )  v (1) 2 (1 
3 2 1/ 2
 ) 2  1 1
4
Digital image processing Digital image transforms

 Basis functions and basis images


KLT Haar Walsh Slant DCT

Basis functions (basis vectors)

Basis images (e.g.): DCT, Haar, ….


Imagine originala V(1,1) V(9,9)
= +

Imagine originala
V(1,3) V(1,5) V(1,7) V(1,9)
= + + +

V(2,1) V(2,9) V(3,1) V(3,5)


V(1,13) V(1,15)
+ + + + + +

V(5,1) V(5,2) V(5,6) V(5,8) V(16,15)


+ + + + … +
Imagine aproximata

Keeping only 50% of coefficients


Digital image processing Digital image transforms

4.4 SINUSOIDAL TRANSFORMS

 The discrete Fourier transform (DFT)


1-D DFT of a sequence u(n), n0,..., N-1 is defined as:
N 1
v(k)   u(n) W
n 0
N
kn
, k = 0,1,...N - 1 (4.28)

where:
 2 
WN  exp  j  (4.29)
 N

The inverse DFT (IDFT):


N 1
1
u(n) 
N
 v(k)W
k 0
N
 kn
, n  0,1,...N  1 (4.30)

N 1
1
v(k) 
N
 u(n) W
n 0
N
kn
, k = 0,1,...N - 1 (4.31)

N 1
1
u(n) 
N
 v(k) W
k 0
 kn
N , n  0,1,...N  1 (4.32)

 1 
F WNkn , 0  k,n  N  1 (4.33)
 N 
Digital image processing Digital image transforms

 DFT properties
N 1 N 1
v* (N  k)   u* (n) WN(N  k)n   u(n) WNkn  v(k) (4.34)
n 0 n 0

N  N  N
v   k   v *   k  , k  0,...,  1 (4.35)
2  2  2

N  N 
v  k   v  k  (4.36)
2  2 

v(0), Re v(k), k1,...,N/2 - 1, imv(k), k1,...,N/2 - 1, v(N/2)


(4.37)
(Conjugate symmetry – the DFT of a real sequence is conjugate
symmetric about N/2).
 The 2-D DFT:

N 1 N  1
v(k,l)    u(m,n) WNkm WNln , 0  k,l  N  1 (4.38)
m 0 n  0

N 1 N 1
1
u(m,n) 
N2
 W
k 0 l 0
 km
N  WN ln  v(k,l) , 0  m,n  N  1 (4.39)

1 N 1 N 1 km ln
v(k,l)    WN WN u (m, n ) , 0  k,l  N  1 (4.40)
N m0 n 0
N 1 N 1
1
u(m,n) 
N
  v(k,l) W
k 0 l 0
 km
N WN ln  v(k,l), 0  m,n  N  1 (4.41)
Digital image processing Digital image transforms

Properties of 2-D DFT

 Symmetry: F T  F , F 1  F * (4.42)

 Periodicity:
v(k  N, l  N)  v(k, l)k, l (4.43)

u( m  N , n  N )  u( m, n ) m, n (4.44)

 The sampled Fourier spectrum:

If u~(m,n)  u(m,n),0  m,n  N  1 si u~(m,n)  0 otherwise, =>:


~ 2k 2l 
U ,   DFT u( m, n )  v ( k , l ) (4.45)
 N N 

~
where U ( w1 , w2 ) is the Fourier transform of u(m,n).

 Fast Fourier transform (FFT): since 2-D DFT is separable => equations (4.40)
and (4.41) are equivalent to 2N 1-D DFTs; each of them can be
computed in Nlog2N operations through FFT.
=> The total number of operations for 2-D DFT: N2log2N.
Digital image processing Digital image transforms

Properties of 2-D DFT (continued)

 Conjugate symmetry: the 2-D DFT and unitary 2-D DFT of a real image
exhibit conjugate symmetry:
N N  N N  N
v   k,  l   v *   k,  l  , 0  k,l   1 (4.46)
2 2  2 2  2

or v(k,l)  v* (N  k,N  l), 0  k,l  N  1 (4.47)

l
1 (N/2 -1) N/2 N-1
0

(N/2)-1
N/2

N-1
N/2
Fig. 4.2 The conjugate symmetry of the 2-D DFT coefficients
Digital image processing Digital image transforms
Digital image processing Digital image transforms

 The discrete Cosine transform (DCT)

FDCT:
N 1 N 1  (2m  1)k   (2n  1)l 
v(k,l)  (k)  (l)   u(m,n)  cos   cos  2N  (4.47)
m 0 n 0  2N   

where k, l  0, 1, ... N-1.


IDCT:
N 1 N 1
 (2m  1)k   (2n  1)l 
u(m,n)     (k)   (l)  v(k,l)  cos  cos  (4.48)
k=0 l=0  2N   2N 

where m, n  0, ... N-1, and the coefficients are:

1 2
 (0)  and  (k)  for 1  k  N (4.49)
N N

V  CuCT (4.50)

 (2m  1)k 
c k,m  (k)  cos   (4.51)
 2N 
Digital image processing Digital image transforms
Digital image processing Digital image transforms

 The discrete Sine transform (DST):

2 N 1 N 1   (m  1)(k  1)    (n  1)(l  1) 
v(k,l)   
N  1 m 0 n  0
u(m,n)  sin 
 N 1  sin  N 1  (4.52)

2 N 1 N 1   (m  1)(k  1)    (n  1)(l  1) 
u(m,n)   
N  1 k 0 l 0
v(k,l)  sin 
 N 1  sin  N 1  (4.53)

2   (m  1)(k  1) 
sm,k  sin   (4.54)
N 1  N 1

 The Hartley transform:

 2
N 1 N 1
1 
v(k,l) 
N
  u(m,n)cas  N
m 0 n  0
(mk  nl)

(4.55)

 2
N 1 N 1
1 
u( m, n ) 
N
  v(k,l)cas  N
k 0 l 0
(mk  nl)

(4.56)

cas(  )  cos(  )  sin(  )  2cos(    / 4) (4.57)

1   mk  
hm,k  cas 2 N   (4.58)
N  
Digital image processing Digital image transforms

4.5 RECTANGULAR TRANSFORMS

 The Hadamard transform (= the Walsh transform; the


Walsh-Hadamard transform)

1 1 1 
H2    (4.59)
2 1  1

1 H N / 2 HN / 2 
HN   (4.60)
2 H N / 2  H N / 2 

1 1 1 1 1 1 1 1 0
1 1 1 1 1 1 1 1 1 0
 1 1  1 1  1   1 7 1
  1 1 1 - 1  1  1  1 1
1 1  1  1 1 1  1  1 3  
  1 1 1 1 -1 -1 1 1 2
1 1 1 1 1 1 1 1 1 4  
H8  (4. 61) 1 1 1  1 - 1 1 1  1 - 1 3
2 21 1 1 1  1  1  1  1 1 H 8,ord  (4. 62)
  2 21 -1 -1 1 1 1 1 1 4
1 1 1 1 1 1 1 1 6  
1  1 - 1 1  1 1 1 - 1 5
1 1 1 1 1 1 1 1 2
  1 -1 1  1  1 1 -1 1 6
 1  1  1 1  1 1 1  1 5  
1  1 1 - 1 1 - 1 1  1 7
Digital image processing Digital image transforms

Basis vectors for the


Walsh-Hadamard transform
Digital image processing Digital image transforms

Original image Ordered Hadamard Non-ordered Hadamard


Digital image processing Digital image transforms
 The Slant transform
1 1 1 
S2  1 1 (4.63)
2  

 1 0 1 0  S n 1 0 
a b 0 0  
 n n  an bn   
1  0 I n-1 0 I n -1   
(4.64)
Sn   
2 0 1 0 1 
 0 0  
 bn an bn an  
 0 I n -1 0 
I n -1  0 S n 1 

3N 2 N2 1
an 1  and bn 1  (4.65)
4N 2  1 4N 2  1
 The Haar transform
k  2p  q 1 (4.66)
 p/2 q 1 q  1/2
2 , if 2 p  x  2 p
h0 (x) 
1
and 1 
 p/2 q  1/2 q (4.67)
hk (x)    2 , if p
x p
N N 2 2
 0, otherwise


x  i / N, i=0,1,...,N-1
 1 1 1 1 1 1 1 1  0
 
 1 1 1 1 1 1 1 1  1


2 2  2  2 0 0 0 0 

2 (4.68)
1  0 0 0 0 2 2  2  2 2
Hr  
8 2 2 0 0 0 0 0 0  2
 
 0 0 2 2 0 0 0 0  2
 0 0 0 0 2 2 0 0  2

 0 0 0 0 0 0 2 2  2
Digital image processing Digital image transforms
Digital image processing Digital image transforms

Applying the Haar transform at block level (e.g. 2×2 pixels blocks => Hr[2×2]):

Block Rearrange
transform: coefficients:

Applying the Haar transform at block level for a 4×4 pixels blocks => Hr[4×4]:

Rearrange
Block coefficients:
transform:
Digital image processing Digital image transforms

4.6 EIGENVECTOR BASED TRANSFORMS

A  k    0 (4.69)

Av k   k v k (4.70)

1 L
mx   xl
L l 1
(4.71)


C x  E ( x  m x )( x  m x )T   1 L

L l 1
x l x tl  m x m tx (4.72)

y  A (x  m x ) (4.73)

C y  ACx AT (4.74)
 1 0 
 
Cy    (4.75)
 
 0  N 

x  A 1 y  m x  A T y  m x (4.76)
~
y  Bx (4.77)
~
x  BT  ~
y (4.78)
N
 2e  
k  M 1
k (4.79)
Digital image processing Digital image transforms

 The Karhunen – Loeve transform (KLT = PCA)


 The fast KLT
 The SVD transform (singular values decomposition)
A  U  VT (4.80)
  U T AV (4.81)

0 1 2 1 0 6 14 18 14 6  147,07 
1 1 14

3 4 3
 36 48 36 14   1,872 
   
A  2 4 5 4 2 AA T  18 48 65 48 18  ;    0,058 
     
1 3 4 3 1 14 36 48 36 14   0 
0 1 2 1 0   6 14 18 14 6   0 

0,186 0,638 0,241 0,695 0,695


0,476 0,058 0,52 0,133 0,128
 
U   0,691 0,422 0,587 0 0 
 
0,476 0,058 0,52 0,133 0,128 
0,186 0,638 0,241 0,695 0,695 

12,58 0 0 0 0  0 1 2 1 0
 0  1

1,142 0 0 0
 3 4 3 1
 
  U AU   0
T
0 0,557 0 0  A  U  UT  2 4 6 4 2
   
 0 0 0 0 0  1 3 4 3 1
 0 0 0 0 0  0 1 2 1 0 
 KLT (PCA)
Eigenimages – examples:

Facial
image
set

Corresponding
“eigenfaces”

3 eigenimages and the individual variations on those components Face aproximation,


from rough to
detailed, as more
coefficients are
added
Digital image processing Digital image transforms

4.7 FILTERING IN THE TRANSFORM DOMAIN

1 1 1 1 1 1 1 1  2 0 0 0 0 0 0 0
1 1 1 1 1 1 1 1  2 0 0 0 0 0 0 0
   
0 0 0 0 0 0 0 0   2,83 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 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
Image Its Haar transform
DFT

Original image = (white square, grey background) DFT = sinc 2-D for the square + cst. (for noise)
+ aditive noise LPF 2-D

IDFT
The 2-D spectrum of the image and the filters applied:
Noisy image; periodic noise as vertical lines In the regions corresponding to the vertical lines frequencies

Image restoration through filtering


Digital image processing Digital image transforms

4.8 CONCLUSIONS

 DFT
- Fast transform; very useful in digital signal processing, convolution, filtering, image
analysis
- Good energy compaction; however – requires complex computations
 DCT
- Fast transform and requires only real number operations
- The optimal alternative to the KLT for highly correlated images
- Used in compression and image restoration by Wiener filtering
- Excellent energy compaction
 Hadamard
- Faster than sinusoidal transforms since it only implies sums and subtractions
- Used for hardware implementation of some digital image processing algorithms
- Applied in image compression, filtering, coding
- Good energy compaction
 Haar
- Very fast transform
- Useful for feature extraction (like horizontal or vertical lines), image coding, image
analysis
- Average energy compaction performance
 KLT
- Optimal transform as: energy compaction; decorrelation
- Does not have a fast algorithm
- Generally used for small sized vectors and to evaluate the performances of other
transforms, but also for image analysis and recognition (PCA)

You might also like