Image and Multidimensional Signal Processing Colorado School of Mines

advertisement
Colorado School of Mines
Image and Multidimensional
Signal Processing
Professor William Hoff
Dept of Electrical Engineering &Computer Science
Colorado School of Mines
Department of Electrical Engineering and Computer Science
http://inside.mines.edu/~whoff/
Fourier Transform
Part 2: two dimensional discrete
transforms
2
Colorado School of Mines
Department of Electrical Engineering and Computer Science
Fourier Transforms – 2D
• 2D continuous
F (u, v)  

f ( x, y)  





 
 
f ( x, y)e j 2 (ux _ vy ) dx dy
F  f ( x, y )  F (u, v)
F 1 F (u, v)  f ( x, y )
F (u, v)e j 2 (uxvy ) du dv
• 2D discrete
F (u, v) 
M 1 N 1
  f ( x, y ) e
 j 2  ux / M  vy / N 
x 0 y 0
1
f ( x, y ) 
MN
M 1 N 1
  F (u, v) e
u 0 v 0
j 2  ux / M  vy / N 
for u  0,1,..., M  1
and v  0,1,..., N  1
for x  0,1,..., M  1
and y  0,1,..., N  1
• Notes
– u = (u,v) is spatial frequency and direction
– F(0,0) is the “dc” component (ie sum of values)
3
Colorado School of Mines
Department of Electrical Engineering and Computer Science
Linearity property
•
The 2D DFT is
F (u, v) 
M 1 N 1
  f ( x, y) e
 j 2  ux / M  vy / N 
x 0 y 0
•
Linearity means
af1 ( x, y)  bf 2 ( x, y)  aF1 (u, v)  bF2 (u, v)
•
Proof
F  af1  x, y   bf 2  x, y   

`M 1 N 1
  af  x, y   bf  x, y  e
1
x 0 y 0

`M 1 N 1
2
  af  x, y  e
x 0 y 0
1
 j 2  ux / M  vy / N 
 j 2  ux / M  vy / N 

`M 1 N 1
  bf  x, y  e
x 0 y 0
 j 2  ux / M  vy / N 
2
 aF  f1  x, y    bF  f 2  x, y    aF1 (u , v)  bF2 (u , v)
4
Colorado School of Mines
Department of Electrical Engineering and Computer Science
Matlab Examples
• Important functions
– fft2, ifft2 – 2D forward and inverse Fourier transform
– fftshift – shifts the zero frequency point from (1,1) to the center of
the image, for visualization only
– abs – takes the magnitude of a complex number
– log – enhances small values by taking the natural log (for visualization)
I = double(imread('moon.tif'));
imshow(I, []);
F = fft2(I);
figure, imshow(log(abs(fftshift(F))),[]);
5
Colorado School of Mines
Department of Electrical Engineering and Computer Science
Notes:
• High spatial frequencies
correspond to small image
detail, sharp edges, & noise
• A sharp edge will result in high
energy perpendicular to the
edge
6
Colorado School of Mines
Department of Electrical Engineering and Computer Science
Examples
• Look at the Fourier spectra of these images
From: http://www.ux.uis.no/~tranden/brodatz.html
• Note
– These images are from the book “Textures: A Photographic Album for
Artists and Designers” by Phil Brodatz (1966)
– The images are widely used as a standard signal processing and image
processing texture dataset
7
Colorado School of Mines
Department of Electrical Engineering and Computer Science
A symmetry property of the DFT
• The Fourier transform of a real image is conjugate symmetric
f ( x, y) real  F * (u, v)  F (u, v)
So when we display the
magnitude of F, it is
symmetric
• Proof
F (u, v) 
M 1 N 1

f ( x, y ) e  j 2  ux / M  vy / N 
F * (u, v)  F (u, v)
x 0 y 0
 M 1 N 1

*
F (u, v)     f ( x, y ) e  j 2  ux / M vy / N  
 x 0 y 0

*
M 1 N 1
   f * ( x, y ) e  j 2  ux / M vy / N 
x 0 y 0
M 1 N 1
   f ( x, y ) e
 j 2    u  x / M    v  y / N 
x 0 y 0
 F (u , v)
8
Colorado School of Mines
Department of Electrical Engineering and Computer Science
Symmetry Properties of the 2D DFT
9
Colorado School of Mines
Department of Electrical Engineering and Computer Science
Translation Property
•
Translation of one of the functions results in a phase shift in its Fourier
transform pair:
f ( x  x0 , y  y0 )  F (u, v)e  j 2 ( x0u / M  y0v / N )
(discrete)
f ( x, y )e j 2 (u0 x / M v0 y / N )  F (u  u0 , v  v0 )
•
You can show this by substituting into the equations for the discrete Fourier
transform
F (u, v) 
M 1 N 1

f ( x, y ) e  j 2  ux / M vy / N 
x 0 y 0
1
f ( x, y ) 
MN
•
M 1 N 1
  F (u, v) e
j 2  ux / M  vy / N 
u 0 v 0
Similarly, for the continuous case
f ( x  x0 , y  y0 )  F (u, v)e  j 2 ( x0u  y0v )
(continuous)
f ( x, y )e j 2 (u0 x v0 y )  F (u  u0 , v  v0 )
10
Colorado School of Mines
Department of Electrical Engineering and Computer Science
Example - Translation to center
• For visualization, we often shift the DFT of an image so that the
zero (DC) frequency is at the center
• Show that
F (u  M 2, v  N 2)

f ( x, y)(1) x y
• Recall the translation property:
f ( x  x0 , y  y0 )
 F (u, v)e  j 2 ( x0u / M  y0v / N )
f ( x, y )e j 2 (u0 x / M v0 y / N )

F (u  u0 , v  v0 )
11
Colorado School of Mines
Department of Electrical Engineering and Computer Science
Rotation Property
•
Similarly, using polar coordinates of the form
x  r cos
•
y  r sin 
u   cos  v   sin 
Results in the following transform pair for rotation
f (r,  0 )  F (,   0 )
•
Show on image example
I = double(imread('moon.tif'));
imshow(I, []);
F = fft2(I);
figure, imshow(log(abs(fftshift(F))),[]);
Irotate
figure,
Frotate
figure,
= imrotate(I, 45.0, 'crop');
imshow(Irotate, []);
= fft2(Irotate);
imshow(log(abs(fftshift(Frotate))),[]);
12
Colorado School of Mines
Department of Electrical Engineering and Computer Science
Differentiation property
• For continuous Fourier transforms
n
     
    f ( x, y)
 x   y 
m
 ( j 2 u )m ( j 2 v) n F (u, v)
• Example: Laplacian
 2 f ( x, y)  2 f ( x, y)
 f ( x, y) 

2
x
y 2
2
 ?
13
Colorado School of Mines
Department of Electrical Engineering and Computer Science
The Fourier Transform Pair of the 2D Rectangle
•
1D Rectangle
rect(W )  W
•
sin( uW )
( uW )
2D rectangle
rect(T , Z )  TZ
sin( uT ) sin( vZ )
( uT ) ( vZ )
14
Colorado School of Mines
Department of Electrical Engineering and Computer Science
15
Colorado School of Mines
Department of Electrical Engineering and Computer Science
16
Colorado School of Mines
Department of Electrical Engineering and Computer Science
DFT Properties (1 of 2)
17
Colorado School of Mines
Department of Electrical Engineering and Computer Science
DFT
Properties
(2 of 2)
18
Colorado School of Mines
Department of Electrical Engineering and Computer Science
Sampling and Aliasing in 2D
• We often subsample an image
– When we originally digitize it
– When we shrink it
• We can reconstruct the image exactly from the samples if the
samples are “dense” enough
• The sampling theorem says that the sampling rate must be more
than twice the maximum frequency of the image (this is the “Nyquist
rate”)
• If the sampling rate is lower, we can get errors in the reconstructed
image (called “aliasing”)
19
Colorado School of Mines
Department of Electrical Engineering and Computer Science
In 2D
20
Colorado School of Mines
Department of Electrical Engineering and Computer Science
Example of aliasing
21
Colorado School of Mines
Department of Electrical Engineering and Computer Science
Example of aliasing
Subsampling without low pass filtering
Original image
Matlab’s “imresize” with no prefiltering
Subsampling after low pass filtering
Matlab’s “imresize” with lowpass prefiltering
22
Colorado School of Mines
Department of Electrical Engineering and Computer Science
Summary / Questions
• The Fourier spectrum (ie, the magnitude of its Fourier transform) of
an image shows important characteristics of the image.
– Periodic structures in the image show up as peaks in the spectrum.
– Energy at high spatial frequencies correspond to small image detail,
sharp edges, & noise.
– A sharp edge will result in high energy perpendicular to the edge.
• What is the significance of the (0,0) component of the spectrum?
• Why does the spectrum of an image appear symmetric?
23
Colorado School of Mines
Department of Electrical Engineering and Computer Science
Download