tutorials 12,13 discrete signals and systems
DESCRIPTION
Tutorials 12,13 discrete signals and systems. Technion, CS department, SIPC 236327 Spring 2014. Discrete LSI system. Linear Space invariant. Discrete LSI system. Linear Space invariant. Example. - PowerPoint PPT PresentationTRANSCRIPT
Technion, CS department, SIPC 236327Spring 2014
Tutorials 12,13discrete signals and systems
1/39
• Linear
• Space invariant
Discrete LSI system
2/39
𝐻1 𝐷 nx ny
• Linear
• Space invariant
Discrete LSI system
3/39
nmg , nmf , 𝐻2 𝐷
• For compression, a rule to predict the pixel value is used:
Is the system linear? Space invariant?
Example
4/39
• System is defined with its impulse response
Discrete LSI system
5/39
nhxknhkxnyk
*
𝛿 [𝑛 ]
𝑛
• Infinite support
• DTFT
Cyclic convolution
6/39
• Finite support
• DFT• Efficient implementation
Convolution
knhkxnhxk
* NknhkxnhxN
k
mod1
0
12
10
01211012
23011210
12
10
NxNx
xx
hhNhNhNhhNhNh
hhhhhhNhh
NyNy
yy
Q: How can we use this system to calculate a linear convolution?A: Zero padding, and truncation of the result.
Exercise
7/39
]0,0,0,3,2,1,0[]0,0,0,4,3,2,1[]3,2,1,0[*]4,3,2,1[
H nx nyx )( ny
Q: If both signals are of length N, how many zeros will we add?
A: N-1 zeros
Q: How can we use this system to calculate a cyclic convolution?A: Duplicate one signal, and truncation of the result.
Exercise
8/39
H nx nyx )*( ny
]3,2,1,0[*]3,2,1,4,3,2,1[]3,2,1,0[]4,3,2,1[ Q: If both signals are of length N, how much should we
duplicateA: N-1 cells
Infinite support Infinite supportContiniuous Continuous
Finite support Finite supportDiscrete Discrete
Discrete Fourier Transform (DFT, FFT)
9/39
)(txFourier)(tx
][nx ][nxDFT
מתבצעות בדרך הרגילה DFT-1 וDFTהתמרות ה•
המקדמים מחזוריים:•[ בד"כ N-1,0לכן במקום להתייחס לתחום ]•
[.N/2,N/2-1מסתכלים על התחום ]-
DFT
10/39
1
0
/2
1
0
/2/2
1
0
*
1][
11,][
,
N
k
Nkni
N
n
NkniNkni
N
n
ekXN
nx
enxN
eN
nxkX
ngnfngnf
...2,1,0, mmNkXkX
DFTהפעלת
11/39
0 50 100-1
-0.5
0
0.5
1
t
x[t]
-50 0 500
5
10
15
20
k|X
[k]|
DFTדוגמאות
12/39
10,2cos
10,
00
00
NknNkDFT
NnnnDFT
• Fourier transform– Time domain – non-periodic infinite signals– Continuous time (t)– Continuous frequency (f)– Formulas
Summary – Fourier Transforms
13/39
TransformFourier )( )(
TransformFourier Inverse )()(
2
2
dtetxfX
dkefXtx
fti
fti
• DTFT: Discrete Time Fourier Transform– Time domain – non-periodic infinite signals– Discrete time (n)– Continuous frequency (f)– Formulas
Summary – Fourier Transforms
14/39
ansformFourier tr DT ][ )(
ansformFourier tr DT inverse )(21][
2
-n
2
fni
fti
etxfX
dfekXnx
מד נל
לא
קורסב
• Fourier series– Time domain – periodic infinite signals– Continuous time (t)– Discrete frequency (f)– Formulas
Summary – Fourier Transforms
15/39
fixed is , 1 Lperiod has
)(T1 ),(][
][)(
)2()2(
)2(
ff
x(t)
dtetxetxkX
ekXtx
T
ktfiktfi
k
ktfi
• DFT or Discrete Time Fourier Series– Time domain – periodic infinite signals– Discrete time (n)– Discrete frequency (f)– Formulas
Summary – Fourier Transforms
16/39
N period a have X[k] and x[n]
1][
11,][
1
0
/2
1
0
/2/2
N
k
Nkni
N
n
NkniNkxi
ekXN
nx
enxN
eN
nxkX
DFT ומערכת LSI
17/39
nhxny nx nh kX kH
kHkXkY
• We have an N-length filter with impulse response h[n].We create a new filter as follows:
Express F[k] with H[k], where H[k]=DFT{h[n]},F[k]=DFT{f[n]}
• Instructions: calculate
Exercise
18/39
][][)1(][ nNhnhnf n
]}[{]}[)1{(
nNhDFTnhDFT n
• Noisy image of size 256X256Im_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
19/39
mm fnAnmnoise 2cos],[
Example – added noise in line 100
20/39
radA
325.137.22
100
100
Example – discrete frequency filtration
21/39
Example – discrete frequency filtration - smoothing
22/39
Example – discrete frequency filtration – smoothing vs median (8 pixels)
23/39
No noise but image is blurred
• DFT of the noise in line i
Example – discrete frequency filtration
24/39
elsekeA
elsekeAniNoiseDFT
N
nN
AfnAniNoise
ii
i iiN
ikN
i
iiii
032
032),(
256
322cos2cos),(
3222
• 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 frequency
Example – discrete frequency filtration
25/39
Example – discrete frequency filtration
26/39
Original signal in frequency domain
Filtered signal in frequency domain
• Noise removed completely
• Original image not fully restored– We cannot restore the
attenuated frequencies
Example – discrete frequency filtration
27/39
Example – discrete frequency filtration
28/39
Smoothing filter of 8 pixels
Notch filter
• 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
29/39
Notch filter in freq. domain
Technion, CS department, SIPC 236327Spring 2014
Tutorials 12,13discrete signals and systemsPart II: 2D
30/39
2D convolution:
2D - definitions
31/39
mnhxmny ,*, mnx , mnh ,
k l
lnkmhlkxnmhx ,,,*
• Cyclic 2D-convolution:
• 2D DFT:
32/39
nmhxnmy ,, nmx , nmh ,
lkX , lkH ,
lkHlkXlkY ,,,
1
0
1
0modmod ,,,
M
k
N
lNM lnkmhlkxnmhx
1
0
1
0
22
, ,1,M
m
N
n
Nnli
Mmki
lk eenmxMN
nmxDFT
2D - definitions
• DFT is linear, we have an operation matrix:
• 2D-DFT can be implemented as:
• If the input is separable:
33/39
nXDnXDFT
TDnmDXnmXDFT ,,
lk nXDFTmXDFTnmXDFT
nXmXnmX
21
21
,,
2D - notes
• Noisy image 512X512
• The noise:Add 100 gray levels for all 16i lines
Example
34/39
mean 4X4
Example
35/39
Noisy image Average filteroriginal + noise
mean 16X16
Example
36/39
Noisy image Average filteroriginal + noise
• How does the noise look like in the frequency domain?
Example
37/39
else
kkmknmnr
0,16161
,
• 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
38/39
After freq. filtration
לפני סינון תדרDFT of image + noise
39/39
לפני סינון תדר (הגדלה של מרכז)
40/39
אחרי סינון תדר (הגדלה של מרכז)
41/39
Image filtration
42/39
000011000
h
000110000
h
000101000
21h
• Roberts
• Prewitt
• Sobel
Edge detection of Image A
43/39
AGAG yx *0110
*10
01
AGAG yx *111
000111
*101101101
AGAG yx *121
000121
*101202101
22 ),(),(),( nmGnmGnmG yx
Edge detection of Image A
44/44
Original Roberts
SobelPrewitt
Unsharp masking – edge enhancement
45/44
LInkInOut
L
*
010141
010