Vous êtes sur la page 1sur 30

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
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[MN] = 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).
x
1
=(0,0); x
2
=(0,1); x
3
=(0,2); ... x
MN
=(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 processing Digital image transforms

{u(n), 0 n N 1} s s ; A unitary matrix,
T * 1
A A =

=
s s = =
1 N
0 n
1 N k 0 , n)u(n) a(k, v(k) r o , Au v (4.1)

s s = =

=
1 N
0 k
* T *
1 N n 0 , n)v(k) (k, a u(n) or v A u (4.2)
} 1 N n 0 , n) (k, {a a
* *
k
s s = ,

4.2 UNITARY ORTHOGONAL TWO-DIMENSIONAL TRANSFORMS



v(k,l) a (m,n) u(m,n) , 0 k,l N 1
k,l
n 0
N 1
m 0
N 1
= s s
=


(4.3)

u(m,n) a (m,n) v(k,l) , 0 k,l N 1
k,l
*
l 0
N 1
k 0
N 1
= s s
=

(4.4)

- orthonormality: o =

=
1 N
0 m
1 N
0 n
*
' l , ' k l , k
) ' l l , ' k k ( ) n , m ( a ) n , m ( a (4.5)

- completeness: a m n a m n m m n n
k l k l
l
N
k
N
, ,
*
( , ) ( ' , ' ) ( ' , ' ) =
=


o
0
1
0
1
(4.6)
u (m, n) a (m,n) v(k,l) , P N,Q N
P,Q k,l
*
l 0
Q 1
k 0
P 1
= s s
=


(4.7)


o
e
2
n 0
N 1
m 0
N 1
P,Q
2
[u(m,n) u (m,n)] =
=


(4.8)

N Q P f 0
2
e
= = = i o
Digital image processing Digital image transforms
- Unitary separable transforms


a m n a m b n a k m b l n
k l k ,
( , ) ( ) ( ) ( , ) ( , ) = =
1
(4.9)


where 1} N 0,..., l (n), {b and 1} N 0,..., k (m), {a
1 k
= = are the
orthonormal sets of basis vectors.

I B B BB , I A A AA
* T *T * T *T
= = = = (4.10)

= =

=

=
1 N
0 m
1 N
0 n
r o l), a(n, n) u(m, m) a(k, l) v(k,
T
AUA V (4.11)

= =

=

=
1 N
0 n
1 N
0 l
* *
r o n), (l, a l) v(k, m) (k, a n) u(m,
* T *
VA A U (4.12)

V A UA
M N
= (4.13)


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


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

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

v v v u A A u u u u
2
*T *T *T *T
2
= = = = = =
=


v(k)
2
0
1
0
1
k
N
n
N
u n ( )
2
(4.16)
u m n v k l
k l
N
m n
N
( , ) ( , )
, ,
2 2
0
1
0
1
=

=

(4.17)
- Energy compaction and the variance of coefficients


v u
E E E = = = = [ ] [ ] [ ] v Au A u A (4.18)

R v v A u u A A R A
v v v
T
u u
T T
u
T
E E = = = [( )( ) ] ( [( )( ) ])
* * * *
(4.19)

o
v v k k u
T
k k
k
2
( ) [ ] [ ]
,
*
,
= = R AR A (4.20)

v
k
W
v
T
v u
T T
u u
n
N
k n ( ) ( )
* * *
2
0
1
2
0
1
=


= = = A A (4.21)
o o
v
k
N
u
T
u u
n
N
k n
2
0
1
2
0
1
( ) [ ] [ ] ( )
*
=


= = = Tr AR A Tr R (4.22)


| | | |
E v k E u n
n
N
k
N
( ) ( )
2 2
0
1
0
1
=
=


(4.23)

Digital image processing Digital image transforms
Energy compaction and the variance of coefficients


v u
n m
k l a k m a l n m n ( , ) ( , ) ( , ) ( , ) =

(4.24)
| |

= =
m n m n
v v
n l a m k a n m n m r n l a m k a l k l k v E l k
' '
* *
2
2
) ' , ( ) ' , ( ) ' , ' ; , ( ) , ( ) , ( ) , ( ) , ( ) , ( o
(4.25)

r m n m n r m m r n n ( , ; ' , ' ) ( , ' ) ( , ' ) =
1 2

(4.26)

| | | |
o o o
v
T
k k
T
l l
k l k l
2
1
2
2
2
1 2
( , ) ( ) ( )
*
,
*
,
= = AR A AR A where R
1
={r
1
(m,m')} and R
2
={r
2
(n,n')}.

- Decorrelation

1 0 ,
1
1
where
3 1
1 3
2
1
u
< <
|
|
.
|

\
|
=
|
|
.
|

\
|


R u v , ,


|
|
.
|

\
|

+
=
2 3 1 2
2 2 3 1
v
/ /
/ /
R

o o

v
v v
E v v
( )
[ ( ) ( )]
( ) ( )
( )
0,1
0 1
0 1
2 1
3
4
2 1/ 2
= =

, A =

|
\

|
.
|
1
2
1 1
1 1


Digital image processing Digital image transforms
- Basis functions and basis images
Basis functions (basis vectors)
Basis images (e.g.): DCT, Haar, .
KLT Haar Walsh Slant DCT
Digital image processing Digital image transforms
Imagine originala
Imagine originala
V(9,9) V(1,1)
= +
=
V(1,3)
+ + +
+ + + + + +
+ + + + +
V(1,5) V(1,7)
V(1,9)
V(1,13)
V(1,15)
V(2,1)
V(2,9)
V(3,1)
V(3,5)
V(5,1)
V(5,2)
V(5,6) V(5,8)
V(16,15)
Imagine aproximata
Keeping only 50% of coefficients
4.4 SINUSOIDAL TRANSFORMS

- The discrete Fourier transform (DFT)

1-D DFT of a sequence {u(n), n=0,..., N-1} is defined as:

v(k) u(n) W , k = 0,1,... N - 1
N
kn
n 0
N 1
=
=

(4.28)

where:
W j
N
N
=
|
\

|
.
| exp
2t
(4.29)

The inverse DFT (IDFT):
u(n)
1
N
v(k)W , n 0,1,...N 1
N
kn
k 0
N 1
= =

(4.30)



v(k)
1
u(n) W , k = 0,1,... N - 1
N
kn
n 0
N 1
=
=

N
(4.31)


u(n)
1
N
v(k) W , n 0,1,... N 1
N
kn
k 0
N 1
= =

(4.32)

F
1
N
W , 0 k,n N 1
N
kn
=


`
)
s s (4.33)
Digital image processing Digital image transforms
- DFT properties

v(k) W u(n) W (n) u k) (N v
1 N
0 n
kn
N
1 N
0 n
k)n (N
N
* *
= = =

=

=

(4.34)

v
N
2
k v
N
2
k , k 0,...,
N
2
1
*

|
\

|
.
| = +
|
\

|
.
| = (4.35)

v
N
2
k v
N
2
k
|
\

|
.
| = +
|
\

|
.
|
(4.36)

v(0), {R
e
{v(k)}, k=1,...,N/2 - 1}, {i
m
{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:


v(k,l) u(m,n) W W , 0 k,l N 1
N
km
n 0
N 1
N
ln
m 0
N 1
= s s
=


(4.38)

u(m,n)
1
N
W W v(k,l) , 0 m,n N 1
2 N
km
l 0
N 1
N
ln
k 0
N 1
= s s


(4.39)


1 N l k, 0 , W W
N
1
l) v(k,
1 N
0 m
ln
N
1 N
0 n
km
N
s s =

=

=
) n , m ( u (4.40)

u(m,n)
1
N
v(k,l) W W v(k,l), 0 m,n N 1
N
km
l 0
N 1
N
ln
k 0
N 1
= s s


(4.41)

Digital image processing Digital image transforms
Properties of 2-D DFT

- Symmetry: F F , F F
T 1
= =
*
(4.42)

- Periodicity:
l , k ) l , k ( v ) N l , N k ( v = + + (4.43)

u m N n N u m n m n ( , ) ( , ) , + + = (4.44)

- The sampled Fourier spectrum:

If 0 n) (m, u si 1 N n m, 0 n), u(m, n) (m, u = s s =
~ ~
otherwise, =>:
{ }
~
, ( , ) ( , ) U
k
N
l
N
DFT u m n v k l
2 2 t t
|
\

|
.
|
= = (4.45)

where
~
( , ) U w w
1 2
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 Nlog
2
N operations through FFT.
=> The total number of operations for 2-D DFT: N
2
log
2
N.
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:

v
N
2
k,
N
2
l v
N
2
k,
N
2
l , 0 k,l
N
2
1
*

|
\

|
.
| =
|
\

|
.
| s s (4.46)

or v(k,l) v (N k,N l), 0 k,l N 1
*
= s s (4.47)

1 (N/2 -1) N/2 N-1
l
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 processing Digital image transforms
- The discrete Cosine transform (DCT)

FDCT:

(

t +

(

t +
o o =

=

=
2N
1)l (2n
cos
2N
1)k (2m
cos n) u(m, (l) (k) l) v(k,
1 N
0 m
1 N
0 n
(4.47)

where k, l = 0, 1, ... N-1.
IDCT:

u(m,n) (k) (l) v(k,l) cos
(2m 1)k
2N
cos
(2n 1)l
2N
l=0
N 1
k=0
N 1
=
+

(
+

(


o o
t t
(4.48)

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

N k 1 or f
N
2
(k) nd
N
1
(0) s s = = o o a (4.49)


T
C u C V = (4.50)



(

t +
o =
2N
1)k (2m
cos (k) c
m k,
(4.51)
Digital image processing Digital image transforms
Digital image processing Digital image transforms
- The discrete Sine transform (DST):

v(k,l)
2
N 1
u(m,n) sin
(m 1)(k 1)
N 1
sin
(n 1)(l 1)
N 1
n 0
N 1
m 0
N 1
=
+

+ +
+

(
+ +
+

(
=


t t
(4.52)


u(m,n)
2
N 1
v(k,l) sin
(m 1)(k 1)
N 1
sin
(n 1)(l 1)
N 1
l 0
N 1
k 0
N 1
=
+

+ +
+

(
+ +
+

(
=


t t
(4.53)


s
2
N 1
sin
(m 1)(k 1)
N 1
m,k
=
+
+ +
+

(
t
(4.54)

- The Hartley transform:

v(k,l)
1
N
u(m,n)cas
2
N
(mk nl)
n 0
N 1
m 0
N 1
= +

(
=


t
(4.55)


u m n ( , ) = +

(
=


1
N
v(k,l)cas
2
N
(mk nl)
l 0
N 1
k 0
N 1
t
(4.56)

cas( ) cos( ) sin( ) 2cos( / 4) u u u u t = + = (4.57)

h
1
N
m,k
=
|
\

|
.
|

(
cas
mk
N
2t (4.58)
Digital image processing Digital image transforms
4.5 RECTANGULAR TRANSFORMS

- The Hadamard transform (= the Walsh transform; the
Walsh-Hadamard transform)


(

=
1 1
1 1
2
1
H
2
(4.59)


(

=
2 / 2 /
2 / 2 /
N N
N N
N
H H
H H
2
1
H (4.60)

H
1
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 1 1 1
1 1 1 1 1 1 1 1
0
7
3
4
1
6
2
5
8
=






(
(
(
(
(
(
(
(
(
(
(
(4. 61)
62) (4.
1
7
6
5
4
3
2
1
0
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 1 1 1
1 1 1 1 1 1 1 1
2 2
1
H
ord 8,
(
(
(
(
(
(
(
(
(
(








=
Digital image processing Digital image transforms
Basis vectors for the
Walsh-Hadamard transform
Digital image processing Digital image transforms
Original image
Digital image processing Digital image transforms
Ordered Hadamard Non-ordered Hadamard
- The Slant transform
S
1
2
1 1
1 1
2
=

(
(4.63)


(
(
(
(
(
(
(

(
(
(
(
(
(
(

1 n
1 n
1 - n
n n n n
1 - n 1 - n
n n n n
n
a b
1 0
a b
1 0
b a
0 1
b a
0 1
2
1
S
S
I I
I I
S
1 - n 0
0
0 0
0 0
0 0
0 0
(4.64)


1 4N
1 N
b and
1 4N
3N
a
2
2
1 n 2
2
1 n

=
+ +
(4.65)
- The Haar transform
k 2 q 1
p
= + (4.66)
N
1
(x) h
0
= and

< s

< s

=
therwise o , 0
2
q
x
2
1/2 q
f i , 2
2
1/2 q
x
2
1 q
f i , 2
N
1
(x) h
p p
p/2
p p
p/2
k
(4.67)
, N / i x = i=0,1,...,N-1

H
r
=


(
(
(
(
(
(
(
(
(
(
(
1
8
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
2 2 2 2 0 0 0 0
0 0 0 0 2 2 2 2
2 2 0 0 0 0 0 0
0 0 2 2 0 0 0 0
0 0 0 0 2 2 0 0
0 0 0 0 0 0 2 2
0
1
2
2
2
2
2
2
(4.68)
Digital image processing Digital image transforms
Digital image processing Digital image transforms
Digital image processing Digital image transforms
Applying the Haar transform at block level (e.g. 22 pixels blocks => Hr[22]):
Rearrange
coefficients:
Block
transform:
Applying the Haar transform at block level for a 44 pixels blocks => Hr[44]:
Block
transform:
Rearrange
coefficients:
4.6 EIGENVECTOR BASED TRANSFORMS

0
k
= I A (4.69)

Av v
k k k
= (4.70)

=
=
L
l
l
L
1
1
x m
x
(4.71)
{ }

=
= =
L
1 l
t t
l l
T
L
1
) ( ) ( E
x x x x x
m m x x m x m x C (4.72)

y A x m
x
= ( ) (4.73)


T
A C A C
x y
= (4.74)

C
y
N
=

(
(
(
(

1
0
0
(4.75)


x
T
x
1
m y A m y A x + = + =

(4.76)


~
y Bx = (4.77)


~ ~
x B y
T
= (4.78)
o
e k
N
2
=
= +

k M 1
(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 V
T
= . (4.80)

. = U AV
T
(4.81)

A =

(
(
(
(
(
(
0 1 2 1 0
1 3 4 3 1
2 4 5 4 2
1 3 4 3 1
0 1 2 1 0

AA
T
=

(
(
(
(
(
(
=

(
(
(
(
(
(
6 14 18 14 6
14 36 48 36 14
18 48 65 48 18
14 36 48 36 14
6 14 18 14 6
147,07
1,872
0,058
0
0
;


U =

(
(
(
(
(
(
0,186 0,638 0,241 0,695 0,695
0,476 0,058 0,52 0,133 0,128
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



. = =

(
(
(
(
(
(
U AU
T
12,58 0 0 0 0
0 1,142 0 0 0
0 0 0,557 0 0
0 0 0 0 0
0 0 0 0 0

A U U
T
= =

(
(
(
(
(
(
.
0 1 2 1 0
1 3 4 3 1
2 4 6 4 2
1 3 4 3 1
0 1 2 1 0


Digital image processing Digital image transforms


- KLT (PCA)
Eigenimages examples:
3 eigenimages and the individual variations on those components
Facial
image
set
Corresponding
eigenfaces
Face aproximation,
from rough to
detailed, as more
coefficients are
added
4.7 FILTERING IN THE TRANSFORM DOMAIN


transf orm Haar Its Image
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 2,83
0 0 0 0 0 0 0 2
0 0 0 0 0 0 0 2
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
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
(
(
(
(
(
(
(
(
(
(

(
(
(
(
(
(
(
(
(
(


Digital image processing Digital image transforms
DFT = sinc 2-D for the square + cst. (for noise) Original image = (white square, grey background)
+ aditive noise
DFT
LPF 2-D
IDFT
Noisy image; periodic noise as vertical lines
The 2-D spectrum of the image and the filters applied:
In the regions corresponding to the vertical lines frequencies
Image restoration through filtering
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)

Digital image processing Digital image transforms

Vous aimerez peut-être aussi