# Digital image transforms

```Digital image transforms
Digital image processing
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 transforms
Digital image processing
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 MNdimensional 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.
Digital image transforms
Digital image processing
0  n  N  1} ; A – unitary matrix, A1  A*T
{u(n),
v  Au , or
u  A*T v
N 1
v(k)   a(k,n)u(n), 0  k  N  1
n 0
N 1
*
(4.1)
or u(n)  a (k,n)v(k), 0  n  N  1
k 0
*
(4.2)
a*k  {a (k, n) , 0  n  N  1 } ,
4.2 UNITARY ORTHOGONAL TWO-DIMENSIONAL TRANSFORMS
N 1 N 1
v(k,l)    ak,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
 orthonormality:
 completeness:
N 1 N 1
*
  a k,l (m, n) a k ',l' (m, n)  (k  k' , l  l' )
m 0 n 0
N 1 N 1
a
k ,l
( m, n )  ak*,l ( m', n' )   ( m  m', n  n' )
(4.5)
(4.6)
k 0 l 0
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
m 0 n  0
 e2  0 if
PQ N
(4.8)
Digital image transforms
Digital image processing
 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
N 1 N 1
v(k,l)    a(k,m)u(m,n) a(n,l),or V  AUAT
m0 n 0
N 1N 1
u(m,n)    a* (k,m) v(k,l) a* (l,n), or U  A*TVA*
n 0 l 0
(4.10)
(4.11)
(4.12)
V  A M UA N
(4.13)
*T
U  A*T
M VA N
(4.14)
V  AUA T , V T  A[AU]T
(4.15)
Digital image transforms
Digital image processing
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
2
*T
k 0
2
(4.16)
n 0
N 1
  u( m, n)
2
N 1
  v( k , l )

m, n  0
2
(4.17)
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
 2v ( k )  [R v ]k ,k  [AR u A*T ]k ,k
W 1
  (k )
v
k 0
N 1

k 0
2
v
2
    v    A  A u    u ( n )
k 0
*T
u
*T
(4.20)
2
(4.21)
n 0
N 1
( k )  Tr[AR u A *T ]  Tr[R u ]    2u ( n )
 E v( k )
N 1
N 1
*T
v
(4.19)
(4.22)
n 0
2
   E u(n) 
N 1
n 0
2
(4.23)
Digital image transforms
Digital image processing
Energy compaction and the variance of coefficients
 v ( k , l )    a( k , m)  a( l , n)   u ( m, n)
m
n

(4.24)

 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 
*T
2
k ,k
l ,l
where R1r1(m,m') and R2r2(n,n').
 Decorrelation
v
1 3

2   1
1 
u,
3 
1
where R u  


,0    1 ,
1 
 1  3 / 2
 / 2 
Rv  
 / 2
1  3 / 2 

 v (0,1) 
E[v(0) v(1)]

 v (0) v (1)

2(1 
3 2 1/ 2
 )
4
,
A
1 1 1 


2  1 1
Digital image transforms
Digital image processing
 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,5)
V(1,3)
=
V(1,13)
+
+
+
+
+
+
V(5,8)
+
V(3,5)
V(3,1)
V(2,9)
V(5,6)
V(5,2)
V(5,1)
+
+
V(1,9)
+
V(2,1)
V(1,15)
+
+
V(1,7)
+
V(16,15)
…
+
Imagine aproximata
Keeping only 50% of coefficients
Digital image transforms
Digital image processing
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) WNkn , k = 0,1,...N - 1
(4.28)
n 0
where:
 2 
WN  exp  j 

N
(4.29)
The inverse DFT (IDFT):
1
N
u(n) 
v(k) 
u(n) 
1
N
N 1
 v(k)W
 kn
N
, n  0,1,...N  1
(4.30)
k 0
1
N
N 1
 u(n) W
kn
N
, k = 0,1,...N - 1
(4.31)
n 0
N 1
 v(k) W
 kn
N
, n  0,1,...N  1
(4.32)
k 0
 1

F
WNkn , 0  k,n  N  1
 N

(4.33)
Digital image transforms
Digital image processing
 DFT properties
N 1
N 1
v* (N  k)   u* (n)WN( Nk)n   u(n)WNkn  v(k)
n0
n0
N
N

N

v  k   v*   k  , k  0,...,  1
2

2

2
(4.34)
(4.35)
N

N

v  k   v  k 
2

2

(4.36)
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
 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
u(m,n) 
1
N2
v(k,l) 
N 1 N 1
 W
 km
N
 WN ln  v(k,l), 0  m,n  N  1
(4.39)
k 0 l 0
1 N 1 N 1 km ln
  WN WN u(m, n) , 0  k,l  N  1
N m0 n0
u(m,n) 
1
N
N 1 N 1
  v(k,l) W
k 0 l 0
 km
N
WN ln  v(k,l), 0  m,n  N  1
(4.40)
(4.41)
Digital image transforms
Digital image processing
Properties of 2-D DFT
 Symmetry:
F T  F , F 1  F *
 Periodicity:
v(k  N, l  N)  v(k, l)k, l
u( m  N , n  N )  u( m, n) m, n
(4.42)
(4.43)
(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 )
 N N 
(4.45)
~
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 transforms
Digital image processing
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
2
2
2 
2 
2
or
(4.46)
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
k
(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 transforms
Digital image processing
 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 
2N

 

m0 n 0
(4.47)
where k, l  0, 1, ... N-1.
IDCT:
 (2m  1)k 
 (2n  1)l 
u(m,n)     (k)   (l)  v(k,l)  cos
cos


2N


 2N

k=0 l=0
N 1 N 1
where m, n  0,
 (0) 
(4.48)
... N-1, and the coefficients are:
1
N
and  (k) 
2
for 1  k  N
N
V  CuCT
(2m  1)k 
ck,m  (k)  cos

2N


(4.49)
(4.50)
(4.51)
Digital image processing
Digital image transforms
Digital image transforms
Digital image processing
 The discrete Sine transform (DST):
2 N 1 N 1
  (m  1)(k  1)    (n  1)(l  1) 
v(k,l) 
u(m,n) sin 


 sin 

N  1 m0 n 0
N 1
N 1

u(m,n) 
2 N 1 N 1
  (m  1)(k  1)    (n  1)(l  1) 
v(k,l)  sin 


 sin 

N  1 k 0 l 0
N 1
N 1

sm,k 
2
  (m  1)(k  1) 
sin 

N 1
N 1

(4.52)
(4.53)
(4.54)
 The Hartley transform:
1
v(k,l) 
N
u( m, n ) 
N 1 N 1
 2

 2

  u(m,n)cas  N (mk  nl)
(4.55)
m 0 n  0
1
N
N 1 N 1
  v(k,l)cas  N (mk  nl)
(4.56)
k 0 l 0
cas( )  cos( )  sin( )  2cos(   / 4)
hm,k 
1
N
  mk  
cas 2 N  


(4.57)
(4.58)
Digital image transforms
Digital image processing
4.5 RECTANGULAR TRANSFORMS
H2 
HN 
1
1

1

1 1
H8 
2 21

1
1

 1
1
1
1
1
1
1
1
1
1
1
1
1
1 1
1 1
1 1
1 1
1

1
1
1 1 1 1 1 1
1 1 1 1 1 1
1 1 1 1 1 1
1 1 1 1 1 1
1 0
 1 7

 1 3

1 4
 1 1

1 6
1 2

 1 5
(4. 61)
(=
the
Walsh
1 1 1 


2 1  1
1 H N / 2

2 H N / 2
H 8,ord
transform;
the
(4.59)
HN / 2 
 H N / 2 
1
1

1

1 1

2 21

1
1

1
1
1
1
1
-1
1
-1
1
(4.60)
1
1
1
1
-1
-1
1
1
1
1
1
-1
1
1
1
-1
1
-1
-1
1
1
1
1
1
1
1
-1
1
1
1
1
-1
1
1
1
1
1
1
-1
1
1 0
 1 1

1 2

- 1 3
1 4

- 1 5
1 6

 1 7
(4. 62)
Digital image processing
Basis vectors for the
Digital image transforms
Digital image transforms
Digital image processing
Original image
Digital image transforms
Digital image processing
 The Slant transform
S2 
 1 0
 a b
 n n
1 
0
Sn 
0
1
2

 bn an
0

1
0
1
2
0
I n -1
(4.63)
0 
 S n 1

0 




I n -1  




0 


I n -1   0
S n 1 

0
 an bn
0
0 1
bn an
0
I n -1
1 1 
1 1


3N 2
N2 1
and
b

n 1
4N 2  1
4N 2  1
an1 
(4.64)
(4.65)
 The Haar transform
(4.66)
k  2p  q 1
h0 (x) 
x  i / N,
1
N
q 1
q  1/2
 p/2
 2 , if 2 p  x  2 p
1 
q  1/2
q

p/2
hk (x) 
x p
  2 , if
p
2
2
N
0, otherwise



and
(4.67)
i=0,1,...,N-1
Hr 
1
8












1
1
1
1
1
1
1
1
2
1
2
1
 2
1
 2
1
0
1
0
1
0
0
2
0
0
0
0
2
0
0
0
0
0
2
0
0
0
0
2
0
0
2
0
0
2
0
2
0
0
2
0
 2
0
0
0
2
1 

1 
0 

 2
0 

0 
0 
2 
0
1
2
2
2
2
2
2
(4.68)
Digital image processing
Digital image transforms
Digital image transforms
Digital image processing
Applying the Haar transform at block level (e.g. 2×2 pixels blocks => Hr[2×2]):
Block
transform:
Rearrange
coefficients:
Applying the Haar transform at block level for a 4×4 pixels blocks => Hr[4×4]:
Block
transform:
Rearrange
coefficients:
Digital image transforms
Digital image processing
4.6 EIGENVECTOR BASED TRANSFORMS
A  k    0
(4.69)
Av k   k v k
(4.70)
mx 
1 L
 xl
L l 1


C x  E ( x  m x )( x  m x )T 
(4.71)
1 L
x l x tl  m x m tx

L l 1
(4.72)
y  A (x  m x )
(4.73)
Cy  ACx AT
(4.74)
 1

Cy  

 0
0 



 N 
x  A 1 y  m x  A T y  m x
(4.76)
~
y  Bx
(4.77)
~
x  BT  ~
y
 2e 
(4.75)
N

k  M 1
k
(4.78)
(4.79)
Digital image transforms
Digital image processing
 The Karhunen – Loeve transform (KLT = PCA)
 The fast KLT
 The SVD transform (singular values decomposition)
A  U  VT
(4.80)
  U T AV
0
1

A  2

1
0
1
3
4
3
2
4
5
4
1
3
4
3
1
2
1
0
1

2

1
0 
6
14

AA T  18

14
 6
0,186 0,638
0,476 0,058

U   0,691 0,422

0,476 0,058
0,186 0,638
0
0
0
12,58
 0
1,142
0
0

T
0
0,557 0
  U AU   0

0
0
0
 0
 0
0
0
0
(4.81)






0 
0
0
0
0
14
36
48
36
18
48
65
48
14
18
14 6 
36 14 

48 18 

36 14 
14 6 
147,07 
 1,872 


;    0,058 


 0 
 0 
0,241 0,695 0,695
0,52 0,133 0,128

0,587
0
0 

0,52 0,133 0,128 
0,241 0,695 0,695 
A  U  UT
0
1

 2

1
0
1
3
4
3
2
4
6
4
1
3
4
3
1
2
1
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
Digital image transforms
Digital image processing
4.7 FILTERING IN THE TRANSFORM DOMAIN
1
1

0

0
0

0
0

0
1 1 1 1 1 1 1  2
1 1 1 1 1 1 1  2
 
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
Im age
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
Its Haar transform
DFT
Original image = (white square, grey background)
DFT = sinc 2-D for the square + cst. (for 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 transforms
Digital image processing
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
- 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)
```

– Cards

– Cards