0% found this document useful (0 votes)
5 views86 pages

Image Transformation

The document discusses image transforms, focusing on mathematical mappings used in image analysis and processing to extract spatial frequency content. It explains the concept of orthogonal functions and the Fourier Transform, detailing how images can be represented in frequency space and the importance of transforms in obtaining additional information from signals. Additionally, it covers various properties of Fourier Transforms, including linearity, separability, and convolution, along with examples and applications in image processing.

Uploaded by

Supratick Mondal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views86 pages

Image Transformation

The document discusses image transforms, focusing on mathematical mappings used in image analysis and processing to extract spatial frequency content. It explains the concept of orthogonal functions and the Fourier Transform, detailing how images can be represented in frequency space and the importance of transforms in obtaining additional information from signals. Additionally, it covers various properties of Fourier Transforms, including linearity, separability, and convolution, along with examples and applications in image processing.

Uploaded by

Supratick Mondal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 86

Image Transforms

B C Dhara
Department of Information Technology
Jadavpur University
Introduction and Overview
 A transform is essentially a mathematical
mapping
 Used in image analysis and processing to
provide information regarding the rate at
which the gray levels change within an
image – the spatial frequency content of
an image

2
 A transform maps image data into a
different mathematical space via a
transformation equation
 Most of the discrete transforms map the
image data from the spatial domain to the
frequency domain (also called the spectral
domain), where all the pixels in the input
(spatial domain) contribute to each value
in the output (frequency domain)

3
Why do we need a transform?
Mathematical transformation are applied to
the signals to obtain a further information
from the signal that is not readily available in
the raw signal.

4
Discrete Transforms

5
Representation of functions
using orthogonal functions
Consider the problem of points
representation in 2D?
distance between every pair
Consider a pair of axis
Orthogonal/non-orthogonal
What about the representation of
functions?

6
7
Orthogonal functions
A collection of functions {Φi | I=1,2,…}
Is said to be orthogonal if

Any function f(x) can be represented by the


projections of the function f onto the
orthogonal functions, {c1,c2,c3, ….} where

8
Orthogonal functions

9
 The general form of the transformation equation,
assuming an N x N image, is given by:

where
u and v are the frequency domain variables,
k is a constant that is transform dependent,
T(u, v) are the transform coefficients,
and B(r, c; u, v) correspond to the basis images

10
 Basis images should be orthogonal and
orthonormal

Orthogonal basis images


 Have vector inner products equal to zero
 Have nothing in common
 Are uncorrelated
 Remove redundant information

Orthonormal basis images


• Are orthogonal and have magnitudes of one

11
 The lowest spatial frequency, called the
zero frequency term ( DC term),
corresponds to an image with a constant
value

 The notation B(r, c; u, v) defines a set of


basis images, corresponding to each
different value for u and v, and the size of
each is r by c

12
13
 The transform coefficients, T(u,v), are the
projections of I(r,c) onto each B(u,v)

 These coefficients tell us how similar the


image is to the basis image; the more alike
they are, the bigger the coefficient

 This transformation process amounts to


decomposing the image into a weighted
sum of the basis images, where the
coefficients T(u,v) are the weights

14
15
Example
Let I(r,c) =

and let

B(u,v;r,c) =

16
Then T(u,v) =

17
 To obtain the image from the transform
coefficients we apply the inverse transform
equation:

18
Example

19
Is this correct?
No, since I(r,c) =

• Comparing our results we see that we


must multiply our answer by ¼

• It also tells us that the transform pair,


B(u,v;r,c) and B-1(u,v;r,c) are not properly
defined, we need to be able to recover our
original image to have a proper transform
pair
20
• We can solve this by letting k’ = ¼, or by
letting k = k’ = ½
• ½ will normalize the magnitude of the
basis images to 1
• The magnitude of the basis vector is:

• Therefore, to normalize the magnitude to


1, we need to divide by 2, or multiply by ½

21
What is Fourier Transform?
Any function that periodically repeats itself can
be expressed as the sum of sines and/or
cosines of different frequencies, each multiplied
by a different coefficients.
This representation is called Fourier series.
No matter how complex is the function.
Even functions that are not periodic can be
expressed as the integral of sines and/or
cosines multiplied by a weighting function. This
formulation is known as Fourier Transform

22
Note
A function expressed either by Fourier
series/ transform, can be reconstructed
(recovered) computing by inverse
process, without any loss.

23
x(t)=cos(2pi10t) + cos(2pi25t) + cos(2pi50t) + cos(2pi100t)

24
Fourier Transform

25
Fourier Transform
The FT of a function is the set of
coordinates representing the function in
an infinite dimensional space spanned
by orthogonal basis vector {e-j2Πux | -α
< u < α} and mathematically,

26
Inverse Fourier Transform

These pair of transformation is called


Fourier Transform Pair
f(x) may be real function, but F(u) is a
complex function.
27
Notes
F(u) = R(u) + j I(u)
F(u) = |F(u)|ejΦ(u)
(ej theta = cos(theta) + j
sin(theta))
|F(u)| = [R2(u) + I2(u)]½
Phase angle Φ(u) = tan-1|I(u)/R(u)|
Energy spectrum E(u) = |F(u)|2, u is
frequency variable
f(x) = A, for 0<=x <=X, find the F(u).
28
Fourier Transform Example

a) The one-dimensional rectangle function


b) the Fourier transform of the 1-D rectangle function

29
Fourier Transform Example

30
2D- Fourier Pair
F(u,v) = ∫∫ f(x,y) e-j2Π(ux + vy) dx dy
f(x,y) = ∫∫ F(u,v) ej2Π(ux + vy) du dv

31
Discrete Fourier Transform (DFT)
Consider N sample points:
x0, x0+Δx , x0+2Δx , …, x0+(N-1)Δx; Δx sampling
rate
f(i) = f(x0+ i Δx)
f(0), f(1), f(2)….,f(N-1)
F(u) = 1/N Σ[f(x). e-j2Πux/N]; u= 0,1,…,N-1
f(x) = Σ[F(u). e j2Πux/N]; x=0,1,…,N-1
F(u) = F(u Δu); and N sample points in one
period then the relation is Δu = 1/(N. Δx)
f(0)=2, f(1)=3, f(2)=4, f(3)=4?
F(0) = 1/N Σ[f(x). e-j2Π0x/N] = 1/N Σf(x) 32
Example of FT (1-D)
Twice the width of the function
Double the area under the curve
peak value is twice the previous one
Number of zeros in transform is just double

33
Example: Given I(c) = [3,2,2,1], corresponding to the brightness values
of one row of a digital image. Find F (v) in rectangular and exponential form

F(v) =[2, ¼[1-j ], ½, ¼[1+j ] ]

34
2D- DFT
F(u,v) = 1/(MN) Σ Σ f(x,y) e-j2Π (ux/M + vy/N)

f(x,y) = Σ Σ F(u,v) e j2Π (ux/M + vy/N)

Normally, in Image Processing N=M

35
Notes
Fourier Spectrum
|F(u,v)| =(R2(u,v) + I2(u,v))½
Phase Angle
Φ(u,v) = tan-1|I(u,v)/R(u,v)|
Power spectra
P(u,v) = |F(u,v)|2

36
Fourier Transform Example (contd)

c) Two-dimensional rectangle d) Magnitude of Fourier spectrum


function as an image of the 2-D rectangle

37
• Linearity
 The Fourier transform is a linear operator
and is shown by the following equations:

where a and b are constants

38
Separability
F(u,v) = 1/N Σ Σ f(x,y) e-j2Π (ux/N + vy/N)
= 1/N [Σ[ N/N Σ f(x,y) e-j2Π vy/N ] e-j2Π ux/N ]
= 1/N [Σ F(x,v) e-j2Π ux/N ]

Where F(x,v) = N/N Σ f(x,y) e-j2Π vy/N


Row transform followed by Column transform,
and finally adjust the multiplying factor.

39
Translation
g(x,y) = f(x,y) ej2 Π (u0x + u0y)/N

G(U,V) = 1/N Σ Σ g(x,y) e-j2Π (ux/N + vy/N)


= 1/N Σ Σ [f(x,y) ej2 Π (u0x + v0y)/N]e-j2Π (ux/N + vy/N)
= 1/N Σ Σ [f(x,y) e-j2Π ((u-u0)x/N + (v-v0)y/N)]
= F(u-u0, v-v0)
u0 = v0 = N/2 => f(x,y) (-1)(x+y) = F(u-N/2, v-N/2)
ie. F(0,0) located at u=N/2, v=N/2
and conversely
Similarly, f(x-x0, y-y0) => F(u,v) e-j2Π (ux0/N + vy0 /N)

40
Periodicity
DFT, IDFT are periodic with period N
ie.,
F(u,v) = F(u+N,v) = F(u,v+N) = F(u+N,
v+N)

F(u+N) = 1/N ∫ f(x) e –j2Πx(u+N)/N


= 1/N ∫ f(x) e –j2Π(ux/N + 1)
= 1/N ∫ f(x) e –j2Πux/N

41
Conjugate Symmetry
F(u,v) = F*(-u,-v), if f(x,y) real

F(-u,-v) = e-j2Π(-ux –vy)/N


= ej2Π(ux +vy)/N

42
Inverse Transform using
Forward
F(u) = 1/N Σ f(x) e –j2Πxu/N ; u=0,1,…,N-1
f(x) = Σ[F(u). ej2Πux/N]; x=0,1,…,N-1

Consider complex conjugate and divide by N


1/N f*(x) = 1/NΣ[F*(u). e-j2Πux/N];
F*(u) given as input to forward FT function
Complex conjugate of the result, and multiplied by N

43
Rotation
x = r cos(θ), y = r sin(θ)
u = w cos(Ф), v= w sin(Ф)

f(x,y) ↔ F(u,v)
f(r, θ) ↔ F(w, Ф)
f(r, θ+ θ0 ) ↔ F(w, Ф + θ0)

44
Distributivity & Scaling
FT(f(x,y) + g(x,y)) = FT(f(x,y)) + FT(g(x,y))

FT(f(x,y) . g(x,y))  FT(f(x,y)) . FT(g(x,y))

a.f(x,y)  a.F(x,y)

f(ax,by)  1/|ab| F(u/a, v/b)


45
Convolution
The convolution between two functions f
and g, denoted as f*g =

f(α) = 1 , 0 ≤ α ≤ 1
g(α) = ½ , 0 ≤ α ≤ 1, find the convolution
between them.

46
Convolution

0 1
f 0 1
g

-1 0
-g 47
Example of convolution

-1 0 x
g(x-α)

48
Convolution
Value is 0

-1 0 1
g At f
x=0

49
Convolution
Value is x/2

-1 0 x 1
At
0≤x≤1

50
Convolution
Value is 0

0 1 x=2
At x=2

51
Convolution
Value is 1- x/2

-1 0 1 x
At
1≤x≤2
Length is 1-(x-1)

52
Convolution Theorem
f(x) → F(u)
g(x) → G(u)

f(x) * g(x) ↔ F(u) G(u) and


f(x) g(x) ↔ F(u) * G(u)

53
2-D convolution
f(x,y) * g(x,y) =

Convolution theorem
f(x,y) * g(x,y) ↔ F(u,v) G(u,v)
f(x,y) g(x,y) ↔ F(u,v) * G(u,v)

54
Discrete Convolution
f(x) * g(y) =

f(x,y) * g(x,y) =

55
Correlation
Continues 
f ( x)  g ( x)   f * ( ) g ( x   ) d

M 1
Discrete 1
f ( x)  g ( x)  
M m 0
f ( m) g ( x  m)

for x  0,1,2,..., M  1

56
2D-Correlation (cont.)
 
f ( x , y )  g ( x, y )    f * ( ,  ) g ( x   , y   ) d d
  

1 M 1 N 1
f ( x, y )  g ( x, y )  
MN m 0 n 0
f (m, n) g ( x  m, y  n)

for x  0,1,2,..., M  1 and y  0,1,2,..., N  1

57
Correlation Theorem
f ( x, y )  g ( x, y )  F * (u, v)G (u, v)
and
f * ( x, y )  g ( x, y )  F (u, v)G (u, v)

58
Fast Fourier Transform
F(u) = 1/N Σ[f(x). e-j2Πux/N]; u=
0,1,…,N-1

Number of multiplications and additions


are proportional to N2

Target : rewrite so that operations


reduced to N log2 N

59
Fast Fourier Transform
F(u) = 1/N Σ[f(x). e-j2Πux/N]
= 1/N Σ[f(x). e-j2Π/N . ux]
ux
= 1/N Σ[f(x). wN ]
we assume N = 2n , n > 0, N = 2M
ux
F(u) = 1/2M Σ[f(x). w2M ]
u2x
= ½{ 1/M Σ[f(2x). w2M ] +
u(2x+1)
1/M Σ[f(2x+1). w2M ]}

ux u2x
wN = e-j2Π/N . ux w2M = (e-j2Π/2M)2ux
60
Fast Fourier Transform
u2x
w2M = (e-j2Π/2M)2ux
ux
=e -j2Πux/M = (e-j2Π/M ) = wM
ux

u2x
F(u) = ½{ 1/M Σ[f(2x). w2M ] +
u(2x+1)
1/M Σ[f(2x+1). w2M ]}
ux
= ½{1/M Σ[f(2x). wM ] + 1/M
2ux u
Σ[f(2x+1). w2M w2M ]
u
= ½ [Feven (u) + Fodd (u). w2M ]
61
Fast Fourier Transform
u
F(u) = ½ [Feven (u) + Fodd (u). w2M ]
F(u + M) = ½ [Feven (u) - Fodd (u).
u u+M u
w2M ] (prove it, hints: wM = wM
u+M u
w2M = -w2M )
For u=0,1….,M-1 F(u) and F(u+M)
covers all

62
Complexity analysis
n=1, i.e., two sample points F(0) and F(1)
Feven(0) = with only sample point at x=0
Fodd(0) = with only sample point at x=1
no multiplication, no addition
F(0) requires one multiplication [Fodd(0) by w20 ]
and one addition
F(1) need only one addition (subtraction)
m(1) =1 and a(1) =2

63
Complexity analysis
In n=2, 4 sample points
Feven contains 2 even points {x0, x2}
Similarly, Fodd contains 2 even points {x1, x3}
Two points requires m(1) and a(1)
So, 2m(1) and 2a(1)
F(0) and F(1) needs two multiplications and
two additions
F(2), and F(3): two subtraction (addition)
m(2) =2 m(1)+2 and a(2) = 2a(1)+4

64
Complexity analysis
Similarly, m(3) = 2 m(2) + 4 and a(3)
= 2 a(2) + 8
In general, m(n) =2 m(n-1) + 2n-1 and
a(n) = 2 a(n-1) + 2n where a(1)=2 and
m(1)=1
Prove that, m(n) = (n. 2n)/2 and a(n) =
n. 2n

65
Discrete Cosine Transform
(DCT)
 Uses sinusoidal basis functions like the
Fourier transform
 Cosine Transform has following properties
unlike Fourier Transform:
• Basis functions are not complex
• Uses only cosine functions, and not sine
functions
• Requires only real arithmetic

66
 The two-dimensional discrete cosine
transform (DCT) equation for an N x N
image is given by:

where

67
 The DCT has been used historically in
image compression, such as JPEG

 In computer imaging we often represent


the basis matrices as images, called basis
images, where we use various gray
values to represent the different values in
the basis matrix

 The basis images are separable

68
69
2D basis function of DCT

70
 The inverse cosine transform is given by:
C-1[C(u,v)] = I(r,c) =

71
2D-DCT
image block
55 36  34 25 66 35 4 37
55 25  12 48 59 38 2 41

 51 40 43 54 51 42 3 39 
49 49 51 49 51 37 3 39 
50 50 51 48 54 36 2 43
 
 51 52 52 51 55 41 4 41 DC component
 51 51 52 54 55 42 1 45
 
 52 51 53 51 53 42 2 41

2D-DCT low high


frequency frequency

low frequency
 313 56  27 18 78  60 27  27
 38  27 13 44 32  1  24  10 

  20  17 10 33 21  6  16  9 
  10 8 9 17 9  10  13 1 
 6 1 6 4 3 7 5 5 
 
 2 3 0 3 7 4 0 3 
 4 4 1  2  9 0 2 4 
 
 3 1 0  4  2 1 3 1 
high frequency
DCT block
72
WALSH-HADAMARD
TRANSFORM (WHT)
 Basis functions are not sinusoids
 The basis functions are based on square
or rectangular waves with peaks of +(-)1
 Rectangular wave refers to any function
of this form, where the width of the pulse
may vary
 Computations are very simple

73
74
 The WHT equation is given by: n 1

1 N 1  bi ( x ) pi (u )
WH (u ) 
N

x 0
f ( x)( 1) i0
n 1

1 N 1  bi ( x ) pi (u )
f ( x) 
N
 WH
x 0
(u )( 1) i 0

where
N = 2n, the exponent on the (-1) is performed in
modulo 2 arithmetic, and
bi (r) is found by considering r as a binary
number, and finding the ith bit

75
EXAMPLE
n = 3 (3 bits, so N = 8), and r = 4
r in binary is 100, so b2(r) = 1, b1(r) = 0,
and b0(r) = 0

EXAMPLE
n = 4, (4 bits, so N = 16), and r = 2
r in binary is 0010, so b3(r) = 0, b2(r) = 0,
b1(r) = 1, and b0(r) = 0

76
 pi (u) is found as follows:

 The sums are performed in modulo 2


arithmetic, and the values for bi (c) and
pi (v) are found in a similar manner

77
 Walsh-Hadamard transform cannot be
called a frequency transform, as the basis
functions do not exhibit the frequency
concept in the manner of sinusoidal
functions
 Therefore instead of frequency terms, we
have sequency terms
 Sequency is the number of zero crossings
(or sign changes)

78
79
2D-WHT
WHT transform pair
n1

1 N 1 N 1  bi ( x ) pi (u ) bi ( y ) pi ( v )
WH (u, v) 
N

x 0 y 0
f ( x, y )( 1) i0
n1

1 N 1 N 1  bi ( x ) pi (u ) bi ( y ) pi ( v )
f ( x, y ) 
N

u 0
 WH
v 0
(u , v )( 1) i 0

80
White +
Black -

81
 Separable means that the basis function
can be expressed as a product of terms
that depend only on one of the variable
pairs, r,u or c,v, and that this separability
also allows us to perform the 2-D
transformation by two 1-D transforms

82
Haar Transform
 The Haar transform has rectangular waves
as basis functions
 Basis vectors contain not just +1 and -1,
but also contain zeros
 The Haar transform is derived from the
Haar matrices
 Each row in matrices represents a one-
dimensional basis vector

83
 Basis vectors for a Haar transform of two
basis vectors (N = 2), four basis vectors
(N = 4) and eight basis vectors (N = 8) are:

84
 The Haar basis vectors can be extended
to higher orders by following the same
patterns shown in the previous slide
 As the order increases the number of
zeros in the basis vectors increase
 This has the unique effect of allowing a
multiresolution decomposition of an input
image
 The Haar transform retains both spatial
and sequency information

85
Haar Transform

a) Original image b) Haar transform image


( Log Remapped )

Note: Haar provides edge information at increasing levels of resolution

86

You might also like