Digital Image Analysis and Processing CPE 0907544 Filtering in the - - PowerPoint PPT Presentation

digital image analysis and processing cpe 0907544
SMART_READER_LITE
LIVE PREVIEW

Digital Image Analysis and Processing CPE 0907544 Filtering in the - - PowerPoint PPT Presentation

Digital Image Analysis and Processing CPE 0907544 Filtering in the Frequency Domain Part I Introduction Chapter 4 Sections : 4.1-4.6 Dr. Iyad Jafar Outline Background Preliminary Concepts Sampling The 1D Discrete Fourier


slide-1
SLIDE 1
  • Dr. Iyad Jafar

Digital Image Analysis and Processing CPE 0907544

Filtering in the Frequency Domain – Part I Introduction

Chapter 4 Sections : 4.1-4.6

slide-2
SLIDE 2

Outline

Background Preliminary Concepts Sampling The 1D Discrete Fourier Transform The 2D Discrete Fourier Transform Essential Properties of the 2D Fourier

Transform

2

slide-3
SLIDE 3

Background

 In 1807, the French mathematician Jean Fourier

proposed that any periodic function that satisfies some mild mathematical conditions can be expressed as the sum of sines and/or cosines of different frequencies and amplitudes

 Now, we know this as Fourier series  Even aperiodic functions that have finite energy can be

represented as an integral of sines and/or cosines multiplied weighting function. This formulation is known as Fourier transform

 Both formulations have an important feature

 A function represented in Fourier series or transform can be

fully reconstructed into its original form without any loss of information

3

slide-4
SLIDE 4

Background

 The use of Fourier analysis was in the field of heat

diffusion.

 The usefulness of Fourier transform is of greater

importance and applicability in many fields

 The availability of digital computers and the discovery

  • f the Fast Fourier Transform (FFT) revolutionized the

field of signal processing

 Our focus in this course will be on Fourier Transform

as we will be working with images of finite duration (energy).

 Specifically, we will use Fourier transform as a tool to

study filtering in the frequency domain

4

slide-5
SLIDE 5

 Complex Numbers

 A complex number C is represented by

C = R + jI

 Complex numbers can be viewed as a point in the

complex plane

 Representation of complex number in polar coordinates

C = |C|ejθ = |C| (cos θ + j sin θ)

where

|C| = (R2+I2)1/2 θ = tan-1(I/R)

Preliminaries

5

Real Imaginary Magnitude Phase

slide-6
SLIDE 6

Preliminaries

 Impulses

 A unit impulse of continuous variable located at t=t0 is

defined as constrained to

 Sifting property

6

, t t δ(t t ) 0 , t t            δ(t t )dt = 1

 

f (t )δ(t t )dt = f(t )

 

slide-7
SLIDE 7

Preliminaries

 Impulses

 In the discrete domain

constrained to and sifting property becomes

7

1 , t t δ(t t ) 0 , t t           δ(t t ) = 1

 

f (t )δ(t t ) = f(t )

 

slide-8
SLIDE 8

Preliminaries

 Impulses

 Impulse Train

 A set of infinite, periodic impulses that are ∆T apart

8

T n

s (t ) = δ(t n T )

  

 

slide-9
SLIDE 9

Preliminaries

 The Fourier Series of Periodic Functions

 The Fourier series of a continuous periodic function f(t)

with period T is where

9

2πn j t T n n

f (t ) = c e

 

2 2 2

1

T / πn j t T n T /

c = f (t ) e dt , n = 0, 1, 2,... T

 

 

slide-10
SLIDE 10

Preliminaries

 The Fourier Transform of Functions of One

ContinuousVariable

 The Fourier transform of a continuous function f(t) of a

continuous variable t

 We can reconstruct f(t) back using

10

 

2 j πμt

f (t ) = F(μ) = f (t ) e dt

  

 

1 2 j πμt

F( μ) = f (t ) = F( μ) e dμ

  

slide-11
SLIDE 11

Preliminaries

 The Fourier Transform of One Continuous

Variable

 Example 4.1. Compute the Fourier transform of the

function f(t) shown below

11

slide-12
SLIDE 12

Preliminaries

 The Fourier Transform of One Continuous

Variable

 Example 4.1 – continued  Usually we work with the

magnitude of F(u)

12

sin(πμW ) F(μ) = AW = AW sinc(πμW ) πμW

sin(πμW ) F(μ) = AW = AW sinc(πμW ) πμW

slide-13
SLIDE 13

Preliminaries

 The Fourier Transform of One Continuous

Variable

 Example 4.2. Compute the Fourier transform of the

unit impulse located at t=0

13

 

2

1

j πμt

δ(t ) = F(μ) = δ(t ) e dt

  

 

 

δ(t ) 

slide-14
SLIDE 14

Preliminaries

 The Fourier Transform of One Continuous

Variable

 Example 4.3. Compute the Fourier transform of the

unit impulse located at t=t0

14

 

2 2 j π μ t j π μ t

δ(t t ) = F(μ) = δ(t t ) e dt e

   

   

 

δ(t t )  

2 j π au

δ(t a ) e

 

slide-15
SLIDE 15

Preliminaries

 The Fourier

Transform of One Continuous Variable

 Example 4.4. Compute the inverse Fourier transform

  • f the following function

15

F( μ) = δ( μ a) 

 

1 2 2 j π μ t j π a t

F( μ) = δ( μ a ) e dμ = e

  

 

2 j π a t

e δ( μ a)

 

slide-16
SLIDE 16

Preliminaries

 The Fourier

Transform of One Continuous Variable

 Example 4.5. Compute the Fourier transform of

sin(2πat) and cos(2πat)

16

 

1 sin(2 πat) δ(μ a ) δ(μ a ) 2 j    

 

1 cos(2 πat) δ(μ a ) δ(μ a ) 2    

slide-17
SLIDE 17

Preliminaries

 The Fourier

Transform of One Continuous Variable

 Example 4.6. Compute the Fourier transform of the

impulse train with period ∆T

17

 

1

  

   

T n

n S (t ) = S(μ) = δ( μ ) T T

T n

s (t ) = δ(t n T )

  

 

slide-18
SLIDE 18

Preliminaries

 ConvolutionTheorem

 The convolution of two continuous functions f(t) and

h(t) where t is a continuous variable is given by

 It

can be easily shown that convolution in the spatial/time domain is equivalent to multiplying the Fourier transforms of the two functions in the frequency domain

18

f(t) h(t) F(μ) H(μ)   f (t) h(t) = f (τ ) h(t-τ )dτ

 

slide-19
SLIDE 19

Preliminaries

 ConvolutionTheorem – cont’d

 Similarly, convolving two functions in the frequency

domain is defined as

 It can be easily shown that convolution in the frequency

domain is equivalent to multiplying the two functions in the original domain

19

  f(t) h(t) F(μ) H(μ) F(μ) H(μ) = F(τ ) H(μ-τ )dτ

 

slide-20
SLIDE 20

Sampling

 Sampling is required to convert continuous signals

into discrete form

 Collecting samples of a signal/function f(t) that are

spaced by ∆T can be viewed as multiplying the signal by an impulse train s∆T(t) with period ∆T

20

x

Δ

Δ

 

 

~ T n

f(t ) f(t ) s (t ) = f(t )δ(t n T )

slide-21
SLIDE 21

Sampling

 The value of each sample fk can be computed by

integration

21

Δ Δ

 

 

k

f f ( t ) δ(t-n T)dt = f (k T )

slide-22
SLIDE 22

Sampling

 The Fourier

Transform of Sampled Function

 Let F(u) denotes the Fourier transform of f(t), then

according to convolution theorem, the Fourier transform is the convolution between F(u) and the Fourier transform of s∆T(t) where

22

 

Δ

          

~ ~ T

F( μ ) f ( t ) f ( t )s ( t ) = F( μ ) S( μ )

 

1

T n

n s (t ) = S(μ) = δ( μ ) T T

  

   

slide-23
SLIDE 23

Sampling

 The Fourier

Transform of Sampled Function

 Carrying out convolution in frequency domain

23

1 Δ 1 Δ 1 Δ

           

           

     

~ n n n

F( μ ) F( μ ) S( μ ) F( τ )S( μ τ )dτ n = F( τ ) δ( μ τ )dτ T T n = F( τ )δ( μ τ )dτ T T n = F( μ ) T T

slide-24
SLIDE 24

Sampling

 The Fourier

Transform of Sampled Function

 The previous formulation implies that the Fourier

transform of a sampled function is simply an infinite, periodic sequence of copies of F(u)that are centered at multiples of 1/∆T

24

Sampling

slide-25
SLIDE 25

Sampling

 The Sampling

Theorem

 If f(t) represents a function whose Fourier transform

F(u) is band-limited, i.e. F(u) = 0 , u >= |umax|, then the

  • riginal spectrum can be recovered from the sampled

spectrum if the sampling rate is at least twice the maximum frequency in F(u)

 We have three different cases

 Under-sampling (1/∆T < 2umax)  Critically sampling; sampling at Nyquest rate (1/∆T = 2umax)  Over-sampling (1/∆T > 2umax)

25

1  

max

2μ T

slide-26
SLIDE 26

Sampling

 The Sampling

Theorem

26

Over-Sampling Critical-Sampling Under-Sampling

slide-27
SLIDE 27

Sampling

 Recovering f(t) from its SampledVersion

 To recover f(t) we can multiply the sampled spectrum

with a function

 Accordingly  And f(t) can be computed using the inverse Fourier

transform

27

Δ         

max max

T , -μ μ μ H( μ) 0 , otherwise 

~

F(u ) F( μ)H( μ)

 

1 2   

j πμt

f (t ) = F( μ) = F( μ) e dμ

slide-28
SLIDE 28

Sampling

 Recovering f(t) from its Sampled

Version

28

slide-29
SLIDE 29

Sampling

 Aliasing

 When we sample with a rate less than the Nyquest rate ,

the replicas of the function transform will overlap. This affects the recovery of the original function.

29

slide-30
SLIDE 30

The Discrete Fourier Transform (DFT) of one Variable

 For a sampled function f(t), the Fourier transform is

given by

 However, This gives a continuous function that has to be

sampled in the frequency domain.

 If we take M samples between 0 and 1/∆T

then, the Fourier transform becomes Which is called the Discrete Fourier Transform (DFT) and its the inverse is

30 2 Δ   

 

~ j π μ n T n n

F( μ) f e Δ  m μ , m = 0,1,2,...,M-1 M T

1 2   



M j π m n / M m n n

F f e , m =0,1,2,...,M-1

1 2

1

 

 

M j π m n / M n m m

f F e , n = 0,1,2,...,M-1 M

slide-31
SLIDE 31

 The Discrete Fourier Transform (DFT) of one

Variable

 A better and convenient representation is to replace m

and n with x and u, and to use the functional notation instead of subscripts for simplicity

 DFT  IDFT

31 1 2

1

 

 

M j π μ x / M u

f ( x) F( μ)e , x = 0,1,2,...,M-1 M

1 2   



M j π μ x / M x

F( μ) f ( x)e , μ =0,1,2,...,M-1

The Discrete Fourier Transform (DFT) of one Variable

slide-32
SLIDE 32

 The Discrete Fourier Transform (DFT) of one

Variable

 The DFT of a sampled

function is periodic since the continuous transform is periodic

 The inverse DFT is periodic also, since we have sampled

the spectrum. Thus, the M samples represent one period in of inverse.

32

  F( μ) F( μ kM )   f ( x) f ( x kM )

The Discrete Fourier Transform (DFT) of one Variable

slide-33
SLIDE 33

 Relationship Between Sampling and Frequency

intervals

 If the samples spacing is ∆T and we have M samples, then

the duration of f(x) is given by

 In the frequency domain, the spacing ∆u is  The frequency range spanned by M components of the

DFT

 Note the inverse relationship between the spacing in the

two domains

33

Δ  T M T 1 1 Δ Δ   μ M T T 1 Ω Δ Δ   M μ T

The Discrete Fourier Transform (DFT) of one Variable

slide-34
SLIDE 34

 The Discrete Fourier Transform (DFT) of one

Variable

 Example

4.7. Compute the DFT

  • f

f(x) = {0.5,1.5,3.5,3.5}

34

3 2  



j π μ x / M x

F( μ ) f ( x )e , μ =0,1,2,3

3 2

1 2 3 9

j π x / M x

μ F( ) f ( x)e f ( ) f ( ) f ( ) f ( )

 

       

3 2 4 2 4 2 4 2 4 2 4

1 1 1 2 3

     

      

j π x / x j π 0 / j π 1 / j π 2 / j π 3 /

μ F( ) f ( x)e f ( )e f ( )e f ( )e f ( )e = -3+2j

The Discrete Fourier Transform (DFT) of one Variable

slide-35
SLIDE 35

 The Discrete Fourier

Transform (DFT) of one Variable

 Example 4.7 – continued  Note how all samples of f(x) are used to compute the

value of the transform F(u) at each u

35

3 4 4 4 4 4 4 4 4 4 4

2 2 1 2 3

     

      

j π x / x j π 0 / j π 1 / j π 2 / j π 3 /

μ F( ) f ( x)e f ( )e f ( )e f ( )e f ( )e = -1+0j

3 6 4 6 4 6 4 6 4 6 4

3 3 1 2 3

     

      

j π x / x j π 0 / j π 1 / j π 2 / j π 3 /

μ F( ) f ( x)e f ( )e f ( )e f ( )e f ( )e = -(3+2j)

The Discrete Fourier Transform (DFT) of one Variable

slide-36
SLIDE 36

Example 4.8 – Compute the IDFT of F(u) in the example 4.7 to obtain f(x)

36

The Discrete Fourier Transform (DFT) of one Variable

slide-37
SLIDE 37

Convolution & Correlation

 Convolution with discrete signals is performed

by

 And correlation is given by

37

1  

  

M m

f ( x) h( x) f (m) h( x m)

1  

 

M m

f ( x) h( x) f (m) h( x m)

slide-38
SLIDE 38

2-D Fourier Transform

 The

Fourier Transform

  • f

a Continuous Function ofT woVariables

 The discussion so far has been for functions of one

variables

 Extension to continuous functions of two variables is

straight forward if we know that

38

           , t t and z=z δ(t t ,z z ) 0 , otherwise

   

 

 

f (t,z )δ(t t ,z z )dtdz= f(t ,z )

slide-39
SLIDE 39

2-D Fourier Transform

 The

Fourier Transform

  • f

a Continuous Function ofT woVariables

 The transform pair is given by

39

2     

  

j π(μt+υz)

F( μ,υ) f (t,z )e dtdz

2    

  

j π(μt+υz)

f (t,z ) F( μ,υ)e dμdυ

slide-40
SLIDE 40

2-D Fourier Transform

 The

Fourier Transform

  • f

a Continuous Function ofT woVariables

 Example 4.9.

40

 sin(πμT ) sin(πυZ ) F( μ,υ) ATZ πμT πυZ

slide-41
SLIDE 41

2-D Fourier Transform

 2-D Sampling and 2-D SamplingTheorem  We

can consider sampling a 2-D function as multiplying it with an impulse train

 Where the discrete impulse in 2-D is defined as

41

     

   

 

T Z m n

s (t,z ) = δ(t m T,z n Z )

1           , x x and y=y δ( x x ,x x ) 0 , otherwise

   

  

 

x y

f ( x,y )δ( x x ,y y ) f ( x ,y )

slide-42
SLIDE 42

2-D Fourier Transform

 2-D Sampling and 2-D Sampling

Theorem

 If we perform the convolution between the spectrum of

the impulse train and the spectrum of f(t,z) we conclude (as in the 1-D case) that the spectrum of the sampled function is an infinite periodic copies of the original of the spectrum F(u,v) that are centered at multiples of the sampling rates in the t and z directions

42

1 Δ Δ

   

   

 

~ m n

m n F (μ,υ ) = F( μ ,υ ) T Z T Z

slide-43
SLIDE 43

2-D Fourier Transform

 2-D Sampling and 2-D SamplingTheorem  Similar to the 1-D case, the spectrum of the sampled

function is just infinite replicas that are located at the multiples of sampling rate (1/∆T and 1/ ∆ Z) in both directions

 In order to avoid aliasing, the transform F(u,v) should

be band-limited and the sampling rate in both directions should be greater than or equal the maximum frequency component in all directions

43

1 1 2 2 Δ Δ  

max max

μ and v T Z

slide-44
SLIDE 44

2-D Fourier Transform

 2-D Sampling and 2-D Sampling

Theorem

44

Spectrum of Sampled Function Aliasing due to under-sampling

slide-45
SLIDE 45

2-D Fourier Transform

 The Discrete Fourier Transform of a Function

  • f T

woVariables

 The transform pair is given by

 And

45

1 1 2

0 1 2 1 0 1 2 1

    

    



M N j π(μx/M+υy/ N ) x y

F( μ,υ) f ( x,y )e μ , , ,...,M and υ , , ,...,N

1 1 2

1 0 1 2 1 0 1 2 1

M N j π(μx/M+υy/ N ) μ υ

f ( x,y ) F( μ,υ)e MN x , , ,...,M and y , , ,...,N

   

    



slide-46
SLIDE 46

Some Properties of the 2-D DFT

 Relationship Between Sampling and Frequency

Intervals

 Translation

46

1 1 Δ Δ Δ Δ   μ and υ M T N Z

2 2   

     

j π( μ x/ M υ y/ N ) j π( x μ/ M y υ/ N )

f ( x,y)e F(μ μ ,υ υ ) f ( x x ,y y ) F(μ,υ)e

slide-47
SLIDE 47

Some Properties of the 2-D DFT

 Periodicity

 We mentioned earlier that the spectrum of the sampled

2-D function and its inverse are periodic. In other words

 It is more convenient for processing and display to shift

the spectrum to the middle of domain by multiplying the sampled function by (-1)x+y

47

1 2 1 2

       F( μ,υ) F( μ k M,υ) F( μ,υ k N ) F( μ k ,υ k N )

1 2 1 2

       f ( x,y ) f ( x k M,y ) f ( x,y k N ) f ( x k ,y k N )

2

2 2 2 2 1 2 2

j π( μ x/ M υ y/ N ) jπ( x y ) ( x y )

f ( x,y )e F( μ μ ,υ υ ) if we let μ M / and υ N / f ( x,y )e F( μ M / ,υ N / ) f ( x,y )( ) F( μ M / ,υ N / )

  

           

slide-48
SLIDE 48

Some Properties of the 2-D DFT

 Periodicity

48

Spectrum of f(t) before multiplying by (-1)x+y Spectrum of f(t) after multiplying by (-1)x+y

slide-49
SLIDE 49

Some Properties of the 2-D DFT

 Periodicity

49

Spectrum of f(t) without multiplying by (-1)x+y Spectrum of f(t) x (-1)x+y F(0,0) F(0,0)

slide-50
SLIDE 50

Some Properties of the 2-D DFT

 Fourier Spectrum and Phase Angle

 The 2-D DFT is complex in general and usually it is

expressed as two separate functions in the frequency domain

 The magnitude  The phase  The power spectrum is defined as  The magnitude of F(0,0) (dc component) is proportional

to the average value of f(x,y) and is typically the largest component in the spectrum

50

1 2 2 2

      F( μ,υ) R ( μ,υ) I ( μ,υ)        I( μ,υ) φ( μ,υ) arctan R( μ,υ)

2 2 2

P( μ,υ) F( μ,υ) R ( μ,υ) I ( μ,υ)   

0 0 F( , ) MN f ( x,y ) 

slide-51
SLIDE 51

Some Properties of the 2-D DFT

51

Image Spectrum without shifting Spectrum after shifting Spectrum After shifting and log transformation

slide-52
SLIDE 52

Example: Effect of translation and rotation

Some Properties of the 2-D DFT

52

Image Spectrum Phase

slide-53
SLIDE 53

Some Properties of the 2-D DFT

 Fourier Spectrum and Phase Angle

 The components of the spectrum of the DFT reflects

the amplitudes

  • f

the sinusoids that combine to represent the images.

 A large amplitude at any frequency implies greater

prominence of that frequency in the image, and vice versa.

 The phase of the spectrum is a measure of the

displacement of various sinusoids with respect to their

  • rigin.

 We can say that the magnitude of the DFT is an array

whose components determine the intensities in the image while the phase angle carry the information about where discernable objects are located

53

slide-54
SLIDE 54

Some Properties of the 2-D DFT

 Fourier Spectrum and Phase Angle

54

Image Magnitude of Spectrum Phase of Spectrum Image Reconstructed Using Magnitude only Image Reconstructed Using Phase only

slide-55
SLIDE 55

Some Properties of the 2-D DFT

 The need for Zero padding

 The discrete 2-D convolution theorem states that  In this course we will be multiplying functions (F(u,v) and

H(u,v)) in the frequency domain to perform some tasks.

 This is equivalent to convolving f(x,y) and h(x,y)  Although it sounds simple, the periodicity of the IDFT

for the two functions causes a serious problem

 Let’s investigate using 1-D example

55

    f ( x,y) h( x,y ) F( μ,υ)H( μ,υ) and f(x,y)h(x,y) F( μ,υ) H( μ,υ)

slide-56
SLIDE 56

Some Properties of the 2-D DFT

 The need for Zero padding

 Assume that we want to convolve two aperiodic

functions each of which is 400 samples

 Note that the convolution result is 799 points

56

1  

  

M m

f ( x) h( x) f (m) h( x m)

slide-57
SLIDE 57

 The need for Zero padding

 Now consider convolving two periodic functions each of

which is 400 samples

 Note that the convolution result is also periodic but

each period doesn’t correspond to the result in the previous slide

Some Properties of the 2-D DFT

57

slide-58
SLIDE 58

 The need for Zero padding

 A simple solution is to zero-pad both functions f(x,y)

and h(x,y) such that they are of equal size P that satisfies where A and B are the size of the original functions

 If we perform convolution after zero-padding the result

will be periodic and each period contains the desired result

Some Properties of the 2-D DFT

58

1    P A B

slide-59
SLIDE 59

 The need for Zero padding

 For two 2-D functions f(x,y) and h(x,y) with sizes AxB

and CxD, zero-padding should be performed in both directions such that the new size is PxQ

 If the two function/arrays/images are of the same size,

padding is achieved by

 The padded zeros are to be removed once we have the

final result

Some Properties of the 2-D DFT

59

1 1       P A C and Q B D 2 1 2 1     P M and Q N

slide-60
SLIDE 60

 The need for Zero padding - Example

Some Properties of the 2-D DFT

60

Original |F(u,v)| H(u,v) |F(u,v)| x H(u,v) Output IDFT DFT

slide-61
SLIDE 61

 The need for Zero padding - Example

Some Properties of the 2-D DFT

61

Original - padded |F(u,v)| H(u,v) |F(u,v)| x H(u,v) Output IDFT DFT

slide-62
SLIDE 62

 The need for Zero padding - Example

 Note

 More blurring in the image that was padded  Blurring near the image borders is symmetric in the padded

case

Some Properties of the 2-D DFT

62

Output without padding Output with padding

slide-63
SLIDE 63

Summary of 2-D DFT Properties

63

slide-64
SLIDE 64

Summary of 2-D DFT Properties

64

slide-65
SLIDE 65

Summary of 2-D DFT Properties

65

slide-66
SLIDE 66

Summary of 2-D DFT Properties

66

slide-67
SLIDE 67

Summary of 2-D DFT Properties

 Symmetry

67

slide-68
SLIDE 68

Related Matlab Functions

 Check Matlab documentation for the

following functions

real imag abs atan2 fft2 ifft2 fftshift

68