Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 35

Digital Imag

e
Processing
Lect #12
1-D Fourier Transform
The Fourier Transform of a continous function f (t )

F (  )  { f (t )}   f (t )e  j 2t dt


The Inverse Fourier Transform of F (  )



f (t )   {F (  )}   F (  )e j 2t d 
1

Fourier Transform: One Continuous Variable

 W /2
F ( )   f (t )e  j 2 t
dt   Ae  j 2t dt
 W / 2

A  j 2 t W / 2 A
 e    e jW  e  jW 
j 2 W / 2 j 2
sin(W )
 AW
(W )

3
Prelims
The Fourier transform of a unit impulse located at the origin:

F (  )    (t )e  j 2t dt


 e  j 2 0
=1
The Fourier transform of a unit impulse located at t  t0 :

F (  )    (t  t0 )e  j 2t dt


 e  j 2t0
=cos(2 t0 )  j sin (2 t0 )
2-D Impulse and Sifting Property: Continuous
 if t  z  0
The impulse  (t , z ),  (t , z )  
0 otherwise
 
and    
 (t , z )dtdz  1

The sifting property


 
 
 
f (t , z ) (t , z )dtdz  f (0, 0)
and
 
 
 
f (t , z ) (t  t0 , z  z0 )dtdz  f (t0 , z0 )
01/04/2022 5
2-D Impulse and Sifting Property: Discrete

1 if x  y  0
The impulse  ( x, y ),  ( x, y )  
0 otherwise

The sifting property


 


x  y 
f ( x, y ) ( x, y)  f (0, 0)

and
 


x  y 
f ( x, y ) ( x  x0 , y  y0 )  f ( x0 , y0 )

01/04/2022 6
2-D Fourier Transform: Continuous
 
F (  , )    f (t , z )e  j 2 ( t  z ) dtdz
 
T /2 Z /2
  Ae  j 2 ( t  z ) dtdz
T / 2  Z /2

 sin(T )   sin( T ) 
 ATZ     T 
  T  

01/04/2022 7
2-D Sampling and 2-D Sampling Theorem

2  D impulse train:
 
sT Z (t , z )     (t  mT , z  nZ )
m  n 

01/04/2022 8
2-D Sampling and 2-D Sampling Theorem

Function f (t , z ) is said to be band-limited if its Fourier transform


is 0 outside a rectangle established by the intervals [-max ,max ]
and [- max , max ], that is
F (  , )  0 for |  |  max and |  |  max

Two-dimensional sampling theorem:


A continuous, band-limited function f (t , z ) can be recovered with
no error from a set of its samples if the sampling intervals are
1 1
T< and Z<
2 max 2 max
01/04/2022 9
2-D Sampling and 2-D Sampling Theorem

01/04/2022 10
Moiré patterns
A moiré pattern
formed by
incorrectly down-
sampling the
former image

01/04/2022 11
The Discrete Fourier Transform (DFT) of One
Variable

M 1
F (  )   f ( x)e  j 2 x / M ,  0,1,..., M  1
x 0

M 1
1
f ( x) 
M
 F
 0
(  ) e j 2 x / M
, x  0,1, 2,..., M  1

01/04/2022 12
2-D Discrete Fourier Transform and Its
Inverse
DFT:
M 1 N 1  j 2 (  x / M  y / N )

F (  , )    f ( x, y )e
x 0 y 0

  0,1, 2,..., M  1;  0,1, 2,..., N  1;


f ( x, y ) is a digital image of size M  N.

IDFT:
M 1 N 1 j 2 (  x / M  y / N )
1
f ( x, y ) 
MN
  F ( , )e
x 0 y 0

01/04/2022 13
Properties of the 2-D DFT

1. Relationships between spatial and frequency


intervals
Let T and Z denote the separations between samples,
then the seperations between the corresponding discrete,
frequency domain variables are given by
1
 
M T
1
and  
N Z
01/04/2022 14
Properties of the 2-D DFT

2. Translation and rotation


f ( x, y )e j 2 ( 0 x / M  0 y / N )  F (   0 ,  0 )
and
f ( x - x0 , y - y0 )  F (  , )e  j 2 (  x0 / M  y0 / N )

3. Periodicity
2  D Fourier transform and its inverse are infinitely periodic
F (  , )  F (   k1M , )  F (  ,  k2 N )  F (   k1 M ,  k2 N )
f ( x, y )  f ( x  k1M , y )  f ( x, y  k2 N )  f ( x  k1M , y  k2 N )

01/04/2022 15
Properties of the 2-D DFT
periodicity

01/04/2022 16
Shifting the Fourier transform

f ( x ) e j 2 (  0 x / M )  F (    0 )
0  M / 2, f ( x)(1) x  F (   M / 2)

f ( x, y )(1) x  y  F (   M / 2,  N / 2)
Properties of the 2-D DFT
Fourier Spectrum and Phase Angle

2-D DFT in polar form


F (u, v) | F (u, v) | e j (u ,v )
Fourier spectrum
1/2
| F (u, v) |  R (u, v)  I (u, v) 
2 2

Power spectrum
P(u, v) | F (u, v) |2  R 2 (u, v)  I 2 (u, v)
Phase angle
 I (u, v) 
 (u,v)=arctan  
 R (u , v ) 

01/04/2022 18
the Fourier image is symmetrical to its center, two points corresponding to the
frequency of the stripes in the original image. Note that the two points lie on a
horizontal line through the image center, because the image intensity in the spatial
domain changes the most if we go along it horizontally.
01/04/2022 20
01/04/2022 21
Phase Angles

01/04/2022 22
Example: Phase Angles and The Reconstructed

01/04/2022 23
another example: amplitude vs. phase

A = “Aron” P = “Phyllis”
FA = fft2(A) FP = fft2(P)

log(abs(FA)) log(abs(FP))

angle(FA) angle(FP)

ifft2(abs(FA), angle(FP)) ifft2(abs(FP), angle(FA))

Adpated from http://robotics.eecs.berkeley.edu/~sastry/ee20/vision2/vision2.html


FFT using MATLAB
0 >> I = imread(‘test.png’); % Load grayscale image
0 >> F = fftshift(fft2(I)); % Shifted transform
0 >> imshow(log(abs(F)),[]); % Show log magnitude
0 >> imshow(angle(F),[]); % Show phase angle
An Example of Convolution

It causes the
wraparound
error

It can be solved
by appending
zeros

01/04/2022 26
Zero Padding

► Consider two functions f(x) and h(x) composed of A and B


samples, respectively

► Append zeros to both functions so that they have the same


length, denoted by P, then wraparound is avoided by choosing

P ≥A+B-1

01/04/2022 27
Zero Padding

► Let f(x,y) and h(x,y) be two image arrays of sizes A×B and
C×D pixels, respectively. Wraparound error in their
convolution can be avoided by padding these functions with
zeros

 f ( x, y ) 0  x  A -1 and 0  y  B -1
f p ( x, y )  
 0 A  x  P or B  y  Q

h( x, y ) 0  x  C -1 and 0  y  D -1
h p ( x, y )  
 0 C  x  P or D  y  Q

Here P  A  C  1; Q  B  D  1
01/04/2022 28
The Basic Filtering in the Frequency Domain

Why is the spectrum at almost


±45 degree stronger than the
spectrum at other directions?

01/04/2022 29
The Basic Filtering in the Frequency Domain

► Modifying the Fourier transform of an image

► Computing the inverse transform to obtain the processed


result

g ( x, y )  1{H (u , v) F (u, v)}

F (u , v) is the DFT of the input image


H (u , v) is a filter function.

01/04/2022 30
The Basic Filtering in the Frequency Domain

► In a filter H(u,v) that is 0 at the center of the transform and 1


elsewhere, what’s the output image?

01/04/2022 31
The Basic Filtering in the Frequency Domain

01/04/2022 32
Summary:
Steps for Filtering in the Frequency Domain
1. Given an input image f(x,y) of size MxN, obtain the
padding parameters P and Q. Typically, P = 2M and Q = 2N.

2. Form a padded image, fp(x,y) of size PxQ by


appending the necessary number of zeros to f(x,y)

3. Multiply fp(x,y) by (-1)x+y to center its transform

4. Compute the DFT, F(u,v) of the image from step 3

5. Generate a real, symmetric filter function, H(u,v), of


size PxQ with center at coordinates (P/2, Q/2)

01/04/2022 33
Summary:
Steps for Filtering in the Frequency Domain
6. Form the product G(u,v) = H(u,v)F(u,v) using array
multiplication

7. Obtain the processed image

 
g p ( x, y )  real  1  G (u , v)   ( 1) x  y

8. Obtain the final processed result, g(x,y), by extracting


the MxN region from the top, left quadrant of gp(x,y)

01/04/2022 34
An Example:
Steps for Filtering in the Frequency Domain

01/04/2022 35

You might also like