discrete signals and systemswebcourse.cs.technion.ac.il/236327/spring2015/ho/wcfiles/...discrete...
TRANSCRIPT
• Linear
𝐻1𝐷 𝑎𝑥 𝑛 + 𝑏𝑤 𝑛 = 𝑎𝐻1𝐷 𝑥 𝑛 + 𝑏𝐻1𝐷 𝑤 𝑛
• Space invariant
For 𝐻1𝐷 𝑥 𝑛 = 𝑦 𝑛 : 𝐻1𝐷 𝑥 𝑛 − 𝑛0 = 𝑦 𝑛 − 𝑛0
Discrete LSI system
2/39
𝐻1𝐷 nx y n
• Linear𝐻2𝐷 𝑎𝑓 𝑚, 𝑛 + 𝑏𝑤 𝑚, 𝑛 = 𝑎𝐻2𝐷 𝑓 𝑚, 𝑛 + 𝑏𝐻2𝐷 𝑤 𝑚, 𝑛
• Space invariant𝐻2𝐷 𝑓 𝑚, 𝑛 = 𝑔 𝑚, 𝑛
yields𝐻2𝐷 𝑓 𝑚 −𝑚0, 𝑛 − 𝑛0 = 𝑔[𝑚 −𝑚0, 𝑛 − 𝑛0]
Discrete LSI system
3/39
nmg , nmf , 𝐻2𝐷
• Infinite support• Related to DTFT
(Do not confuse with DFT)
Cyclic convolution
5/39
• Finite support• 𝑦 = 𝑇𝑐𝑥
• Related to DFT• Efficient implementation
(Linear) Convolution
knhkxnhxk
* Nknhkxnhx
N
k
mod
1
0
1
2
1
0
0121
1012
2301
1210
1
2
1
0
Nx
Nx
x
x
hhNhNh
NhhNhNh
hhhh
hhNhh
Ny
Ny
y
y
Infinite support Continuous
Finite support Discrete
Discrete Fourier Transform (DFT)
6/39
)(txFourier)(tx
][nx ][nxDFT
Infinite support
Continuous
Finite support
Discrete
:המקדמים מחזוריים•
.[N/2,N/2-1-]ניתן להתייחס לתחום[N-1,0]לכן במקום להתייחס לתחום •
7/39
12 /
0
12 /
0
1: [ ]
1: [ ]
Ni kn N
n
Ni kn N
k
DFT X k x n eN
Inverse DFT x n X k eN
...2,1,0, mmNkXkX
Discrete Fourier Transform (DFT)
ExamplesDFT
9/39
0
0 0
221
0
0
, 0, ..., 1
1 1knknN
j jN N
n
DFT n n n N
X k n n e eN N
0 0
0 00 0
2 2
0 0
0
2 22 2 21 1
0 0
0 0
2 2 1cos , 0 1 cos
2
1 1 1 1
2 2
2
k kj n j n
N N
k k k kk k knN Nj n j n j j n j n
N N N N N
n n
k kDFT n k N x n n e e
N N
X k e e e e eN N
Nk k k k
• Noisy image of size 256X256
Im_out[m,n]=Im_in[m,n]+noise[m,n]
• Harmonic noise:
• f = 1/(8 pixels)
• Amplitude A and phase φ are random and independent for each line.
Example – Discrete Frequency Filtration
11/39
mm
fnAnmnoise 2cos],[
Example – Discrete Frequency Filtration:Smoothing vs Median (8 pixels)
15/39
No noise but image is blurred
• DFT of the noise in line i
Example – Discrete Frequency Filtration
16/39
2
2 32
32( , ) cos 2 cos 2
256
3232( , )00
ii
i i i i
Niki
N ii
Noise i n A fn A nN
N
A e kA e kDFT Noise i nelseelse
• Design an LSI filter– Such filter multiplies each frequency with a complex
number.
– Can handle each frequency separately.
• In this example, we want to handle frequencies 32 and -32.– Notch filter: attenuates specific frequencies.
Example – Discrete Frequency Filtration
17/39
Example – Discrete Frequency Filtration
18/39
Original signal in
frequency domainFiltered signal in
frequency domain
• The noise was significantly removed.
• Original image was not fully restored– We cannot restore the
attenuated frequencies
Example – Discrete Frequency Filtration
19/39
• Filter in freq. domain:
Filter=ones(1,256);
Filter(32+1)=0;
Filter(224+1)=0;
• Filtration:
For k=1:size(I,1),
Y=fft(I(k,:)).*Filter;
I(k,:)=ifft(Y);
end
Example –Frequency Filtration - Implementation
21/39
Notch filter in freq. domain
• Cyclic 2D-convolution:
• 2D DFT:
24/39
nmhxnmy ,, nmx , nmh ,
lkX ,
lkH ,
lkHlkXlkY ,,,
1
0
1
0
modmod,,,
M
k
N
l
NMlnkmhlkxnmhx
1
0
1
0
22
,,
1,
M
m
N
n
N
nli
M
mki
lkeenmx
MNnmxDFT
2D - Definitions
• Matrix form of 1D DFT that operates on a vector 𝑥:
• 2D-DFT can be implemented as:
where 𝑋 is a matrix.
• For a separable input signal:
25/39
1DDFT x Dx
2
T
DDFT X DXD
2 1 1 1 2,D D Dk l k lDFT X DFT x DFT x
2D - Notes
1 2,X m n x m x n
• How does the noise look like in the frequency domain?
Example
29/39
1 , 16 16 ,
,0 ,
for n k or m k kr n m
else
• Filter implementation in the freq. domain:
H=ones(512,512);for n=1:32:512
H(n,1) = H(1,n) = 0;endH(1,1) = 1;
• Image filtration:out = ifft( fft(img).*H );
Example
32/39
Image after freq. filtration
• Roberts
• Prewitt
• Sobel
Edge Detection of The Image 𝐴
35/39
AGAGyx
*01
10*
10
01
AGAGyx
*
111
000
111
*
101
101
101
AGAGyx
*
121
000
121
*
101
202
101
22),(),(),( nmGnmGnmG
yx