Digital Image Processing Lecture

Download Report

Transcript Digital Image Processing Lecture

S. Mandayam/ DIP/ECE Dept./Rowan University
Digital Image Processing
0909.452.01/0909.552.01
Fall 2001
Lecture 4
October 1, 2001
Shreekanth Mandayam
ECE Department
Rowan University
http://engineering.rowan.edu/~shreek/fall01/dip/
S. Mandayam/ DIP/ECE Dept./Rowan University
Plan
• Image Enhancement
• Spatial Filtering
Low-pass
High-pass
• Detection of Discontinuities
• Edge detection (Sobel, Prewitt and Laplacian masks)
• Image Spectrum
• 2-D Fourier Transform (DFT & FFT)
• Spectral Filtering
Low-pass
High-pass
S. Mandayam/ DIP/ECE Dept./Rowan University
DIP: Details
Digital Image Processing
Digital Image Characteristics
Spatial
Gray-level
Spectral
Histogram
DFT
DCT
Pre-Processing
Enhancement
Point Processing
Masking
Restoration
Filtering
Degradation Models
Inverse Filtering
Compression
Information Theory
Lossless
Lossy
LZW (gif)
Transform-based (jpeg)
Segmentation
Edge Detection
Description
Shape Descriptors
Texture
Morphology
Wiener Filtering
S. Mandayam/ DIP/ECE Dept./Rowan University
Image Preprocessing
Restoration
Enhancement
Spectral
Domain
Spatial
Domain
Point Processing
• >>imadjust
• >>histeq
Spatial filtering
• >>filter2
Filtering
• >>fft2/ifft2
• >>fftshift
• Inverse filtering
• Wiener filtering
S. Mandayam/ DIP/ECE Dept./Rowan University
Spatial Filtering (Masking)
Portion of
a digital image
Mask
z1 z2 z3
w1 w2 w3
z4 z5 z6
w4 w5 w6
z7 z8 z9
w7 w8 w9
Replace
with
R
= w1z1 + w2z2 + ….. +w9z9
S. Mandayam/ DIP/ECE Dept./Rowan University
Low-pass Filters
Moving Average Filter
(1/9)* 1
1
1
1
1
1
1
1
1
Median Filter
z1 z2 z3
z4 z5 z6
z7 z8 z9
Replace
with
R
= median(z1, z2 , ….. , z9)
S. Mandayam/ DIP/ECE Dept./Rowan University
High-pass Filters
Basic HP Filter
(1/9)* -1 -1 -1
-1 8 -1
Gradient Filter
z1 z2 z3
z4 z5 z6
z7 z8 z9
-1 -1 -1
1
0
-1 0
1 -1
0
0
demos/demo2spatial_filtering/highpassdemo.m
S. Mandayam/ DIP/ECE Dept./Rowan University
Detection of Discontinuities
Point Detection
-1 -1 -1
-1 8 -1
-1 -1 -1
Line Detection (Prewitt’s Gradient)
-1 -1 -1
-1 0
1
0
0
0
-1 0
1
1
1
1
-1 0
1
demos/demo2spatial
_filtering/prewitt.m
S. Mandayam/ DIP/ECE Dept./Rowan University
Edge Detection
Sobel Masks
-1 -2 -1
-1 0
1
0
0
0
-2 0
2
1
2
1
-1 0
1
demos/demo2spatial_filtering/edgegradientdemo.m
>>edgedemo
>>edge
S. Mandayam/ DIP/ECE Dept./Rowan University
Recall: 1-D CFT
Continuous Fourier Transform (CFT)

W (f )  Fw ( t )   w ( t ) e  j2ft dt

W (f )  X (f )  j Y (f )
W ( f )  W ( f ) e j ( f )
Amplitude
Spectrum
Frequency, [Hz]
Phase
Spectrum
Inverse Fourier Transform (IFT)
w(t)  F

W(f )   W(f ) e j2ft df
-1

S. Mandayam/ DIP/ECE Dept./Rowan University
Recall: 1-D DFT
Equal time intervals
• Discrete Domains
• Discrete Time:
• Discrete Frequency:
k = 0, 1, 2, 3, …………, N-1
n = 0, 1, 2, 3, …………, N-1
Equal frequency intervals
• Discrete Fourier Transform
 2   nk

j
 
N 1
X[n ]   x[k ] e  N  ;
k 0
n = 0, 1, 2,….., N-1
• Inverse DFT
 2   nk
j
 
1 N 1
x[k ] 
 X[n ] e  N  ; k = 0, 1, 2,….., N-1
N n 0
S. Mandayam/ DIP/ECE Dept./Rowan University
How to get the frequency axis in the DFT
• The DFT operation just converts one set of number,
x[k] into another set of numbers X[n] - there is no
explicit definition of time or frequency
 X0 
X[n ]   . 


X N 1 
 x0 
x[k ]   . 


 x N 1 
(N-point FFT)
• How can we relate the DFT to the CFT and obtain
spectral amplitudes for discrete frequencies?
n=0
1
2
3
4
f=0
n=N
f = fs
fs
N
Need to
know fs
S. Mandayam/ DIP/ECE Dept./Rowan University
DFT Properties
• DFT is periodic
X[n] = X[n+N] = X[n+2N] = ………
• I-DFT is also periodic!
x[k] = x[k+N] = x[k+2N] = ……….
• Where are the “low” and “high” frequencies on the
DFT spectrum?
n=0
N/2
n=N
f=0
fs/2
f = fs
S. Mandayam/ DIP/ECE Dept./Rowan University
1-D FFT Demo
http://engineering.rowan.edu/~shreek/spring01
/ecomms/demos/dft.m
>>fft
S. Mandayam/ DIP/ECE Dept./Rowan University
2-D Continuous Fourier Transform

F(u, v) 


 j 2 (ux vy )
dxdy
 f ( x, y ) e
x   y  
u
x
y
Spatial
Domain
v
Spatial
Frequency
Domain
S. Mandayam/ DIP/ECE Dept./Rowan University
2-D Discrete Fourier Transform
N 1 N 1
2 (ux  vy ) 

F(u, v)    f ( x, y ) exp  j

N

x 0 y 0
u=N/2
u=N
v=N
v=N/2
v=0
u=0
>>fft2
>>ifft2
S. Mandayam/ DIP/ECE Dept./Rowan University
2-D DFT Properties
• Conjugate symmetry
demos/demo3dft_properties/con_symm_and_trans.m
• Rotation
demos/demo3dft_properties/rotation.m
• Separability
demos/demo3dft_properties/separability.m
>>fftshift
S. Mandayam/ DIP/ECE Dept./Rowan University
v=-N/2
Spectral Filtering:
Radially Symmetric Filter
u=-N/2
u=0
D(u,v)
v=N/2
v=0
D0
• Low-pass Filter
demos/demo4freq_filtering/lowpass.m
u=N/2
S. Mandayam/ DIP/ECE Dept./Rowan University
Lab 2: Spatial & Spectral
Filtering
http://engineering.rowan.edu/~shreek/fall01/dip/lab2.html
S. Mandayam/ DIP/ECE Dept./Rowan University
Summary